Jump to: navigation, search

SCA/SCA Component/SCA First Steps With Composite Designer

The objective of this tutorial is to show how to develop a simple SCA application using the STP/SCA Composite Designer.

You can download a pdf version of this tutorial: "First Steps with the SCA Composite Designer".

The tutorial illustrates how to:

  • Install the STP/SCA plugins and Apache Tuscany
  • Define an SCA assembly with the SCA Composite Designer
  • Refine properties in an SCA assembly
  • Define an SCA assembly with different implementation technologies
  • Define an RMI binding
  • Run and test SCA assemblies with Tuscany


Prerequisites

In order to be able to test the sample SCA application, you need to :

  • install Apache Tuscany on your machine,
  • set up Eclipse for Tuscany.

The SCA Restaurant Application

The following figure shows the SCA assembly of the application that you will create. RestaurantOverview.png

This composite, named restaurant, is a composition of five components:

RestaurantServiceComponent
Allows you to see the Menus proposed by the restaurant.
It allows also to compute the bill for a particular menu.
MenuServiceComponent
Provides different menus. A Menu is defined by a description and the price without taxes.
BillServiceComponent
Computes the price of a menu with the different taxes.
VATServiceComponent
Computes the VAT (Value Added Tax).
TipServiceComponent
Computes the tip.

First SCA Application

Create a new Java Project

First, create a Java Project to hold the Restaurant application:

  1. Select File > New > Java Project.
  2. Set "Restaurant" as the Project name. For Project layout, select Create separate folders for sources and class files. Click on the Next button.
  3. Click on the Finish button.

Create a new SCA Composite diagram

To create an SCA diagram:

  1. Right-click the project and select New > Other....
  2. In the New wizard, select SCA Composite Diagram in the SCA Tools folder (Other folder if there is no SOA Tools folder) and click Next.
  3. Choose a folder and type a unique name for the diagram in the File name field and click Finish.

The new created file is automatically open with the SCA Composite Designer. To open the Properties view, do a right click on the diagram and the select Show Properties View. Restaurant1.PNG

In accordance with the SCA specifications, the composite and the composite file have the same name. The name of the composite is automatically set

Now, you should see the following project structure:

RestaurantProjectStructure.PNG

Create a Restaurant Composite

Add a first component named RestaurantServiceComponent. You can do it with the Component creation tool which is in the palette or using the contextual menu.

Palette.PNG ContextualMenuNewComponent.PNG

Then, add MenuServiceComponent, BillServiceComponent, VatServiceComponent, and TipServiceComponent.

Next, add the following services:

  • a service named RestaurantService on the RestaurantServiceComponent,
  • a service named MenuService on the MenuServiceComponent,
  • a service named BillService on the BillServiceComponent,
  • a service named VatService on the VatServiceComponent,
  • a service named TipService on the TipServiceComponent.

In the next step, add the following references:

  • a reference named menuReference on the RestaurantServiceComponent,
  • a reference named billReference on the RestaurantServiceComponent,
  • a reference named vatReference on the BillServiceComponent,
  • a reference named tipReference on the BillServiceComponent.

Now you can wire the services and references. From the palette, you can use :

  • the Wire creation tool: a Wire element is added,
  • the Wire target: target attribut of the Reference element is used.

The next step is to promote the restaurant service. Two ways are possible to promote a service (or a reference). You can:

  • create a new Service on the composite and then use the Promote creation tool from the palette to add a promotion link between the composite service and the promoted component service, or
  • right-click a component service, and select Promote menu item.

RestaurantPromote.PNG

Save your diagram. The Restaurant.composite_diagram contains the graphical part of your SCA assembly and the Restaurant.composite file contains the XML code that describes your SCA assembly.

You can open the Restaurant.composite file with the SCA Composite Model Editor. Right-click the Restaurant.composite file, select Open with > SCA Composite Model Editor. A multi page editor is opened. It offers a tree view and the source code of your SCA assembly. You can modify your SCA assembly with these two editors. They are synchronized with the SCA Composite Designer.

RestaurantTreeEditor.PNG RestaurantSourceEditor.PNG

Define interfaces and implementations

Test the Restaurant

Refine a property

Change Implementation and bindings