Previous | Home | Next


Working with SCA applications

In this chapter, we discuss how to work with Service Component Architecture (SCA) applications. We introduce the basic elements of an SCA application and how to package and export SCA applications.


SCA application introduction

Support for SCA offers a way to construct applications based on service-oriented architecture (SOA). The support in WAS V8.5 uses the Apache Tuscany open-source technology to provide an implementation of the published SCA specifications. WAS supports the Open SOA Collaboration SCA specification (OSOA SCA 1.0) and the SCA OASIS programming model (OASIS SCA 1.1).

The functions of these components are noted in the following list:


SCA component

Components both provide and consume services.

An SCA component consists of the following parts:

The component reads the property value from the configuration file when the component is instantiated. In WAS V8.5, the service implementation includes the following components:


SCA composite

Assemblies of components are formally grouped into composites. A composite is the set of components and wires (, the assembly of services). It is the basic deployment unit for SCA in WAS. The components, assemblies, internal wires, and service and reference definitions are written in an open XML language called Service Component Definition Language (SCDL).

The composite provides a scoping mechanism that defines a local boundary for components but that can also hide services provided in components that are not intended for other SOA applications. When defined, a composite can be reused to provide the implementation for other components in a nested fashion.

Services and references in a composite are bound to specific protocols (such as web services) using bindings. The bindings are part of the SCDL definition, and the business logic (implementation) does not need this detail.

An SCA composite includes the following elements:

An application can contain one composite or several different composites. The components of a composite can run in a single process on a single computer or can be distributed across multiple processes on multiple computers. The components might all use the same implementation language or they can use different languages.

An SCA composite is typically described in a configuration file, the name of which ends in .composite. The composite definition, named SupportFeeds.composite, located in the project root folder of the AtomContentFeed composition unit in the RAD8AtomFeeds sample application.

A composite file in a WAR file must be named default.composite. A composite file not in a WAR file can have any name.


SCA contribution

An SCA contribution contains artifacts that are needed for an SCA domain. Contributions are sometimes self-contained, in that all of the artifacts necessary to run the contents of the contribution are found within the contribution itself. However, the contents of the contribution can make one or many references to artifacts that are not contained within the contribution.

These references might be to SCA artifacts or to other artifacts, such as Web Services Description Language (WSDL) files, XSD files, or to code artifacts such as Java class files.

An SCA contribution is typically described in a contribution file, named sca-contribution.xml in the META-INF directory.

<?xml version="1.0" encoding="UTF-8"?>
<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">

<deployable composite="ns1:SupportFeeds"
xmlns:ns1="http://itso.rad.feeds"></deployable>
</contribution>


Preparing to use the sample application

The concepts in this chapter are illustrated using the RAD8AtomFeeds sample application, which is included with Rational Application Developer for WebSphere Software V8 Programming Guide, SG24-7835.


Downloading the application

To download the sample application:

  1. Go to the following website:

      http://www.redbooks.ibm.com/abstracts/sg247835.html?Open

  2. Click the Additional Material link.

  3. Click the sg247835.zip file, and select Save to save the compressed file to your computer.

  4. Extract the contents of the compressed file.

    The SCA artifacts are in the 7835codesolution\sca directory.


Importing the application to the development tool

To use the sample application for our exercise, import both files into IBM Rational Application Developer:

  1. Start IBM Rational Application Developer.

  2. To import the code, click...

      File | Import | General section | Existing projects into workspace | Next

  3. Click Browse next to the Select Archive file field, and browse to the sca directory where you extracted the sample code. Select the RAD8AtomFeeds.zip file, and click Open.

  4. Click Select All to select all projects in the file. Click Finish. If you are prompted to migrate the workspace, accept and complete the migration wizard.


Completing the service definition

The last action is to make sure the interface for the composite is complete by completing the following steps:

  1. Open the composite by double-clicking SCA 1.0 Content | Composites | http://itso.rad.feeds | SupportFeeds.

  2. Click the Service icon (green arrow) in the AtomFeedFetcher component and then select the Properties view.

  3. Switch to (by clicking) the Interface tab and verify the Interface is of type Java and that it has the value com.ibm.itso.support.feeds.Fetcher. If not, correct the fields, and save and close the composite.


Packaging an SCA application for deployment

Files that are contained in the sample SCA application package, as shown in the Enterprise Explorer view in IBM Rational Application Developer.

SCA applications are displayed in the Enterprise Explorer view of the IBM Rational Application Developer with features in a manner that makes working with the components easy. The SCA Content section contains entries for the contributions and composites, making them visible and selectable to open for editing. This is simply a structural view of the files. The SCA contribution file, SCA composite, and SCA composite diagram files (all located beneath the META-INF folder in are not normally visible as raw files.

We changed the view properties for the Enterprise Explorer view to show them to you in this format. So, you see these files twice, once by file name and once as an element under the SCA Content folder double clicking...

...opens the same file that opens if we double-clicked...

The same is true for the composite.

To use these settings, click the View menu. Click Customize view. Click the Filter tab, and clear SCA 1.0 resources.

The composites are created by the developer as part of the application development process.

The developer adds components to the composite, writes the implementation code for the components, and adds the interface files. These development activities are independent of deployment activities. The contribution file is related to packaging for deployment and must be created to deploy the application.

We can see the composite and components. Selecting any of the components in the composite shows the properties in the lower window. The AtomFeedFetcher component is selected, and in the properties window, we can see the implementation class listed.


Create the contribution

Before we can export the project for deployment, create the contribution file. This is a simple process using the IBM Rational Application Developer.

To create the contribution file:

  1. In the Enterprise Explorer, expand...

      SCA 1.0 Content. Right-click Contributions | New | SCA 1.0 Contribution

  2. In the New Contribution Wizard window, select the composites to be deployed , and click Finish.


Exporting the SCA application for deployment

To export the contribution as an SCA archive file:

  1. Right-click the project, and select Export.

  2. In the Export dialog box, select Service Component Architecture 1.0 | SCA Archive File

  3. Select the project to export, and click Finish.

    Now, we can deploy the RAD8AtomFeeds.jar SCA archive file.


Deploying an SCA application

A typical SCA solution consists of a combination of web, EJB, and SCA applications. The web and EJB modules are deployed as enterprise applications, and the SCA composites are deployed as assets in a business-level application.


Importing the SCA archive file as an asset

The first step in deploying the application is to import the SCA archive file into the application server environment as an asset.

To import an asset:

  1. Click Applications | Application Types | Assets. In the Assets window,

  2. Select the SCA archive file

  3. Provide the required options. In this example, take the default values...

    The following lists explains the fields of note from Figure 26-16:

    When the asset is imported, the binaries are extracted by default to PROFILE_HOME/installedAssets/asset_name/BASE. We can change this location by specifying a new one here.
    The default setting for the file permissions to be assigned to the extracted asset binaries is the Allow executables to execute setting. We can select another option or provide a customized setting.
    Click the Manage Relationships button to specify assets to which this asset is related.
    Selecting this option enables validation of the references specified in the asset when it is imported. The asset is examined to ensure that references are defined in the scope of the deployment target of the asset. Some examples of these references are data sources or references contained in deployment descriptors (such as resource and resource environment references).

  4. In the Summary page, click Finish to import the file and save the modification to the master configuration. The new SCA archive file is now listed as an asset.


Create a new business-level application

To create a new business-level application:

  1. Click...

      Applications | Application Types | Business-level applications | New.

  2. Enter a new name for the business-level application. Click Apply. Save the change to the master configuration.


Add the new asset to the business-level application

Add the new asset, as a composition unit, to the RAD8AtomFeed business-level application by completing the following steps:

  1. Click Applications | Application Types | Business-level applications and then click RAD8AtomFeeds.

  2. In the Deploy assets section, click Add | Add Asset.

  3. Choose the asset to deploy to this business-level application.

  4. Review the options for the composite unit. In this example, we use the default values.

    Backing ID Displays the unique identifier for the composition unit that will be registered in the application domain. We cannot change this field.
    Name Name for the composition unit.
    Starting weight Order in which composition units are started when the server starts. The composition unit with the lowest number is started first.
    Start composition unit upon distribution Whether to start the composition unit when it is distributed to other locations. Applies only to assets and shared library composition units.
    Restart behavior on update (of the composition unit):
    ALL Restart the composition unit after the entire composition unit is updated.
    DEFAULT Restart the composition unit after the part of the composition unit is updated.
    NONE Does not restart the composition unit after the composition unit is updated.

  5. The next window allows you to select the target server for deployment. Select the server in the Available column, and click the right arrow to move it to the Selected column. Click Next.

  6. The next window allows you to manage relationships with an existing composition unit. A relationship declares a dependency of this composition unit to another asset deployed as a shared library. In this example, we have none to declare. Click Next.

  7. The last window is a summary window. Review your selections and then click Finish.

  8. Save the update to the master configuration.


Starting and verifying the business-level application

The last step is to start the business-level application and to verify that it is available by completing the following steps:

  1. Click...

      Applications | Application Types | Business-level applications | RAD8AtomFeeds application | Start

    The application starts...

  2. Verify the offered service from a web browser by entering the following URL:

      http://hostname:port/supportFeeds

Typically, the hostname is the localhost and the port has the value 9080.


Additional resources for learning


Deploying SCA composites in the information center

Samples and Tutorials with SCA using IBM Rational Application Developer