Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
*This page is under construction\- You are welcome to help and complete it*

Welcome to the Apache Tuscany SCA User guide. Here you will find information aimed to help you first develop a simple SCA calculator application and then enhance it with more advanced features and concepts. This guide is based on Java SCA implementation in Tuscany.

It is assumed that you are familiar with basic SCA concepts.

This is a work in progress, so please contribute and comment so we can make this valuable to you {section}{column:width=50%}{column}

\\
{panel:title=Apache Tuscany SCA User Guide|borderStyle=solid|borderColor=#6699ff|titleBGColor=#D5EFFF|bgColor=#ffffff}
Getting Started
* [Introduction|#Intro]
* [WhyQuick Guide to SCA?|#Why |Quick Guide to SCA?]
* [DownloadingBuild your Javacalculator SCA|#Downloading Java SCA]

Example Application
application| #build your calculator application]
  ** [Exampleget overviewstarted|#Example#get overviewstarted]
  ** [#RunningExperience therunning Calculator Sample]
* [Running additional samples|Running the samples] (this was already here... may need to move out)

Using Tuscany SCA
* [#Building your own Calculator Application]
* [Building an Application|Building an Application] (this was already here... may need to move out)
* Packaging a standalone Tuscany application
* Running a standalone Tuscany application
* Adding extensions to the standalone environment
* [#Building a Tuscany Web Application]
* Implementing SDO
* Implementing Web Services
* Using Extensionsapplication|#Experience running calculator application]
  ** [Build your  Calculator application in Java|#Build your  Calculator application in Java]
     *** What you will learn
     *** Example walk through
  ** Build a Calculator application using different languages
  ** Build a Calculator application using web services
\\
 
{panel}{section}

h3. {anchor:Intro}{color:#0099cc}Introduction{color}

Service Component Architecture (SCA) defines technologies for creating services and assembling them into higher-order service networks. SCA provides a language-independent way to compose and deploy service networks. SCA also defines language-specific client programming models for service authoring including Java, Spring, C++, and PHP. This user guide is for Java SCA implementation in Tuscany.

This user guide will help you buildbecome afamiliar simplewith applicationSCA calledconcepts calculatorand samplewalks inyou Java.through Itsteps thenof modifiesbuilding ityour toSCA useapplication. multiple languages in the same application.

h3. {anchor:DownloadingBuild Javayour SCAcalculator application} {color:#0099cc}DownLoading SCA{color}

Download [Tuscany Java SCA release|http://incubator.apache.org/tuscany/sca_downloads.html].
This sample is going to be tested with the latest release of Tuscany.

h3. {anchor:Example Overview} {color:#0099cc}Example OverviewBuild your calculator application{color}

We will use the calculator sample to walk through steps for building an SCA application. As the name indicates, this sample performs the calculator operation. It is given two numbers and asked to perform an operation on those numbers.

This application consists of the calculator applicatoin and the SCA client that invokes it. We will focusstart onwith thea Calculatorsimple application itself.

*Step 1* Define howvariation of the calculator applicationexample canand beextend brokenit downto intoinclude distinct operations/components, let's say Add, Subtract, Multiply and Devide

!java_imp.jpg!

*Step 2* Define interfaces for each component in SCDL file

*Step 3* Implement each component 

*Step 4* Create the composite application*

more advanced SCA features.

h3. {anchor:Runningget the Calculator Sample}started} {color:#0099cc}Running the Calculator SampleGet started{color}

[Note: We need to provide instruction for how to run sample without getting into IDE]

3 + 2=5.0
3 - 2=1.0
3 * 2=6.0
3 / 2=1.5* Download [Tuscany Java SCA release|http://incubator.apache.org/tuscany/sca_downloads.html].
Please download the latest release. 
* Download prequisits 
  ** [JDK 5.0|http://java.sun.com/javase/downloads/index.jsp]
  ** [Maven 2.04|http://maven.apache.org/download.html]

h3. {anchor:RunningExperience therunning Calculatorcalculator Sampleapp}{color:#0099cc}RunningExperience therunning Calculatorcalculator Sampleapp{color}

TheseCalculator areis preliminary steps...details such as from where to download are forthcoming
#  Downloadprovided as a sample under SCA Java distribution. Let's first run the sample file.
#  Unzip it to a local folder such as C:\Temp
#  In Eclipse, select File \-> Import \-> General \-> Existing Projects into Workspace
#  Click Next.
#  Select the Select root directory option and click the "Browse" button to point to C:\Temp.
#  Select CalcultorSample directory and click Finish. The project is created.
#  Expand the CalcultorSample. Expand "src/main/java/calculator", right-click CalculatorClient.java and select Run as ... \--> Java Application. You will see   the following output in the console viewbefore we go about
buidling it. It is easy!

* go do the directory ..\samples\calculator
* issue the command:
{code}
run java -cp target\sample-calculator.jar;..\..\lib\tuscany-sca-manifest.jar calculator.CalculatorClient
{code}

You should see the following result:

3 + 2=5.0
3 - 2=1.0
3 * 2=6.0
3 / 2=1.5

h3. {anchor:BuildingBuild your own Calculator Applicationapplication in Java}{color:#0099cc}BuildingBuild your own Calculator application in ApplicationJava{color}

Topics to include?

Creating Java SCA Components
Creating the implementation for the Java SCA components
Creating the composite file
Creatomg a client to invoke the service
Packaging a Standalone Tuscany Application?
Building a Tuscany Web Application?

h3. {anchor:Step1:Diagram} {color:#0099cc}Step1: Diagram{color}

h4. What you will learn
This example illustrates how to define the model, define and implement components and wire them to create a composite application called calculator. This example uses the use of SCA to wire components together inside a composite. All connections between the components are local and are defined using Java interfaces.

h4. Example walk through
*Step 1 - Define your application:* Think about how your application can be broken down into smaller functions/services. In this case, calculator application can be divided into four blocks: Add block, Substract block, Multiply block and Divide block. Each block is a logical unit of operation that can be used in the overall application.

h3. {anchor:Step2:*Step 2 - Define components} {color:#0099cc}Step2: Define components{color}

:* Now that you have identified the blocks of functionality in your application, you are ready to create each block. A block is called a component in SCA programming model. A component is the smallest unit of function in your application that provides a service. A component can reference other components and can also be referenncedreferred to by other components. A group of components can logically be bundled together to form a composite which is a deployable unit in SCA.

Let's tartstart with the add component. A component has an implementation associated with it. This implementation can be in any language, in this case it is a Java implementation.

[Note: Add the correct diagram to show add component and its interfaces.]

h4. {color:#0099cc}Components{color}

[Note: We need to replace this with Java relevant information. This is for C++]
Compents are the building blocks for creating SOA Applications. They contain the information that defines the program logic or implementation (component implementation), how the component interacts with other components (component type) and defines how it fits in with the other parts of the soluion (composition/assembly).
* A service header file that defines the operationswork thatto can be invoked on the component
* An implementation header file that defines the implementation and extends the service header file
* A C+\+ implementation of the service that implements the operations defined in the service header file
* Proxy and wrapper header and implementation files generated by the Tuscany C+\+ SCAGEN tool
* A service definition in a .componentType file
* An SCDL component definition within an SCDL composite file. Usually this composite file will contain multiple components configured and assembled together.

h4. {color:#0099cc}Service Component Descritpion Language (SCDL){color}


h4. {color:#0099cc}Create a client to invoke the service.{color}

# Create a file and name it CalculatorClient.java 

Your component, composite and subsystem are now ready to be invoked. Create a client that will call the service. E.g. the Calculator client (in the CalculatorClient.cpp file) contains code similar to the following:
{code}
package calculator;

import org.apache.tuscany.api.SCAContainer;
import org.osoa.sca.CompositeContext;
import org.osoa.sca.CurrentCompositeContext;

/**
* This client program shows how to create an SCA runtime, start it,
* locate the Calculator service and invoke it.
**/
public class CalculatorClient {
public static void main(String[] args) throws Exception {
  SCAContainer.start("Calculator.composite");
  CompositeContext context = CurrentCompositeContext.getContext();
  CalculatorService calculatorService =
  context.locateService(CalculatorService.class, "CalculatorServiceComponent");
  // Calculate
  System.out.println("3 + 2=" + calculatorService.add(3, 2));
  System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
  System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
  System.out.println("3 / 2=" + calculatorService.divide(3, 2));
  SCAContainer.stop();
 }
}
{code}

h3. {anchor:A look at calculator Sample code}{color:#0099cc}A look at the Calculator Sample{color}

These are preliminary steps...details such as from where to download are forthcoming
#  Download the sample file.
#  Unzip it to a local folder such as C:\Temp
#  In Eclipse, select File \-> Import \-> General \-> Existing Projects into Workspace
#  Click Next.
#  Select the Select root directory option and click the "Browse" button to point to C:\Temp.
#  Select CalcultorSample directory and click Finish. The project is created.
#  Expand the CalcultorSample. Expand "src/main/java/calculator", right-click CalculatorClient.java and select Run as ... \--> Java Application. You will see   the following output in the console view:

3 + 2=5.0
3 - 2=1.0
3 * 2=6.0
3 / 2=1.5

h3. {anchor:Building a Tuscany Web Application}{color:#0099cc}Building a Tuscany Web Application{color}

You can run Tuscany inside of a Web application running in any standard Web container such as Apache Tomcat. Once configured, the application is portable across container implementations.done by this component. This implementation can be in any language, in this case it is a Java implementation.


{HTMLcomment:hidden}{children:sort=creation}{HTMLcomment}