Deployment patterns for Service Component Architecture applications

Deploy SCA applications with IBM Rational Application Developer to IBM WebSphere Application Server

Deployment Assembly support in IBM Rational Application Developer offers a good mechanism for mapping the deployment layout of Service Component Architecture (SCA) applications. This was previously implemented in Java Enterprise Edition projects but is now implemented by OSGi applications. This is an introductory guide for how to map the project dependencies used in an SCA application to provide deployment layout patterns supported by IBM WebSphere Application Server.

Victor A. Sosa Herrera (victorsh@mx1.ibm.com), Software Engineer, IBM

author photoVictor Sosa works at IBM in Guadalajara, Mexico. He is a service component architecture tools (SCA) developer for Rational Application Developer, focusing on WebSphere Application Server integration. He joined IBM in 2009 as a developer in the Retail Store Solutions department and moved to Rational soon after that. He has been actively promoting SCA value to business by presenting workshops, conferences, and technology showcases in various forums. Victor holds a bachelor's degree in computer science from Valle del Guadiana Institute of Technology in Durango, Durango, Mexico.



29 January 2013

IBM WebSphere Application Server deployment patterns

IBM® WebSphere® Application Server supports three ways to deploy Service Component Architecture (SCA) applications to fit different needs:

  • Single asset
  • Embedded asset
  • Shared asset

Single asset

Single asset is one Java archive (JAR) file. It contains all files, classes, and other artifacts that the application needs to work properly. This is the simplest deployment pattern, because you need to create only one composition unit (CU) for that asset in one business-level application (BLA). This is the default deployment pattern used in IBM® Rational® Application Developer to deploy and publish SCA applications.

Embedded asset

With the embedded asset pattern, there is one main JAR file that contains a single or multiple JAR files. This is a way to keep your assets organized within the main JAR file that you will deploy. In WebSphere Application Server, this is more likely to single asset pattern in the way that you need to create one CU for the main asset and one BLA. Internally, WebSphere Application Server reads the contents of the asset and loads them all and includes them in the appropriate class loader.

Shared asset

Shared asset is a more complex pattern. This involves several independent JAR files that are not embedded. There is a main asset to be deployed (the SCA contribution asset) and secondary assets that will be used by the main asset. The secondary assets have resources that the main asset uses to work properly. Shared assets are imported into WebSphere Application Server in two ways:

  • If the shared asset contains an SCA contribution and it exports a namespace or a Java package that is then imported by the SCA contribution in the main asset, then WebSphere Application Server automatically maps that asset as a shared asset. No additional work is necessary here.
  • If it is a non-SCA asset, you can map it as a shared asset with the relationship directive of the importAsset command when importing the main asset.

In both cases, the shared asset must be deployed in WebSphere Application Server before importing the main SCA asset.


IBM Rational Application Developer tools

In addition to the deployment assembly features available on WebSphere Application Server, IBM Rational Application Developer has tools for mapping your deployment layout. You can choose during development how you will design the deployment layout of your SCA application.

Within Rational Application Developer, you map your SCA application and dependencies to be deployed as one asset (that is the default behavior in Rational Application Developer), a main asset that contains embedded assets or a main asset with several shared assets (but only the ones automatically generated by WebSphere Application Server). See the first bullet item in Shared Asset section). You can do this by adding deployment assembly support to your SCA project.

You can use deployment assembly to add dependencies in your project and to create a deployment layout to fit architectural goals. You can add a dependency to a project in the workspace, archives, folders, and Java build path entries.


Deployment scenario

The sample in this article is based on the Account Services Sample provided in IBM Rational Application Developer, but it will be enhanced to add assembly support to demonstrate the deployment patterns.

For convenience, you can import the projects into your workspace. You can find the projects in a zip file in the Downloads section.

The scenario covers three SCA projects:

ChequingAccount
Handles the checking account requests. This is deployed as an embedded JAR file inside of the main SCA asset.
 
SavingsAccount
Handles the savings account requests. This is deployed as an SCA shared asset. It will export a Java package to be imported in the contribution of AccountServices project.
 
AccountServices
Contains an SCA composite that wires and exposes the services provided by SavingAccount and ChequingAccount as a single service. It is the main SCA contribution project in which the layout will be configured.

The composition looks like Figure 1.

Figure 1. Composite
Composition in composite editor

Import the projects

To import the projects into your workspace, follow these steps:

  1. Click File and select Import.
  2. Expand General category.
  3. Select Existing projects into workspace.
  4. Click Next.
  5. Select Import from archive file.
  6. Click Browse.
  7. Browse the downloaded file that contains the projects.
  8. Click OK.
  9. Click Finish.

Add deployment assembly support

By default, SCA projects do not have deployment assembly support, so you need to add it. Use the context menu of the SCA project.

  1. Right-click on AccountServices, and expand Service Component Architecture 1.0 > Add Deployment Assembly support.
  2. In the Enhance SCA Project Wizard, select the three projects listed.
  3. Click Finish.

If you right-click the AccountServices project and select Properties > Deployment Assembly, you will see deployment assembly entries as in the screen capture in Figure 2.

Two things to notice here:

  • The project dependency for ChequingAccount and SavingsAccount projects is already there. This is because the initial AccountServices project had an entry for each of the projects shown here in the Java build path. Adding deployment assembly support will also migrate the entries in Project References.
  • The SCA Deployment Assembly page (Figure 2) has two check boxes for mapping the deployment patterns: Shared asset and Deploy as JAR.
Figure 2. SCA Deployment Assembly page
Deployment pattern controls

Deploying as a single asset

This is the default and simplest deployment task. If you do not further configure the deployment assembly, you will deploy a single asset. To do this, you just have to publish the application.

To review the publish job in the server, open WebSphere Application Server Administration Console and go to Applications > Application Types > Assets. You will see only one asset there.

Figure 3. Single deployed asset
One asset deployed in WebSphere Application Server

Remove the application from the server to move to the next section.

Deploying an embedded asset

The ChequingAccount project will be selected to be deployed as an embedded asset:

  1. Open Deployment Assembly page of AccountServices project.
  2. Select ChequingAccount, and check Deploy as JAR.
  3. Click OK and publish as usual.
  4. After the deployment, open the WebSphere Application Server Administration Console and go to Assets page. There, you will see only one asset.
  5. Select the AccountServices.jar item in the table, and select Export.
  6. On the next page, click the AccountServices.jar link, and save to your local system.
  7. Open the saved JAR file with a decompression utility. You will see that the ChequingAccount project was packaged as an embedded JAR file.
  8. Inspect the contents of the archives.
Figure 4. Embedded asset
ChequingAccount.jar in AccountServices.jar asset.

Remove the application from the server to move to the next section.

Deploying a shared asset

IBM Rational Application Developer supports the deployment of shared assets that are automatically mapped by IBM WebSphere Application Server. The application server looks for the following items in an asset to determine whether the asset is a candidate for this type of deployment (the first two steps apply to the shared asset; the remaining ones apply to the main SCA asset):

  1. Does the project have an sca-contribution.xml file in the META-INF folder? First, WebSphere Application Server needs to determine whether this is an SCA asset.
  2. Is the asset exporting any XML namespace or Java package through the sca-contribution.xml file? WebSphere Application Server reads the SCA contribution file looking for an export. If so, then it determines that the asset can be used as an SCA Shared Asset.
  3. Is this asset a deployable SCA asset? WebSphere Application Server looks for an SCA contribution file that contains deployable composites.
  4. Is there a missing artifact in the SCA composite at composition unit creation time? When creating the composition unit and can't find a Java or XML artifact, WebSphere Application Server looks in the SCA contribution file for an import element and tries to match the SCA import with the SCA exports it already knows. If there is a match, then it adds a composition unit of the shared asset.

Add the import and export statements in the SCA contribution files

In IBM Rational Application Developer, you need to add those import and export statements in the SCA contribution files of the projects. To export the Java package, follow these steps:

  1. Right-click on the SavingsAccount project, and select New > SCA 1.0 Contribution.
  2. Click Finish, and accept the default values in New SCA 1.0 Contribution wizard.
  3. In the Exports section, click Add, select export.java, and then click OK.
  4. In the export.java dialog window, click Browse, and select the org.example.components package.
  5. Click OK, and then OK again.
  6. Save your SCA contribution editor.

Your contribution should look like Figure 5.

Figure 5. Exports section in SCA Contribution editor
The Java package is exported in the contribution

Import the Java package

Now you need to import the Java package in the AccountServices project:

  1. Now, open the SCA contribution from the AccountServices project.
  2. Click Add from Imports section.
  3. In the Add Import dialog window, select import.java, and click OK.
  4. Click Browse, and select the org.example.components package from the SavingsAccount project.
  5. Click OK, and then click OK again.
  6. Save your contribution. It should looks like Figure 6.
Figure 6. Imports section in SCA Contribution editor
The Java package is imported in the contribution

Configure as a shared asset and deploy

  1. Open the Deployment Assembly page of the AccountServices project, select the SavingsAccount project, and you should see Shared asset check box enabled.
  2. Confirm that it is, and click OK.
  3. Now, deploy the AccountServices application.
  4. After deployment, open the WebSphere Application Server Administration console, and go to the Assets page. You should see two assets:
    • AccountServices.jar
    • SavingsAccount.jar
Figure 7. Shared asset and main asset in WebSphere Application Server
SavingsAccount.jar and AccountServices.jar
  1. Now go to the Business-Level Applications page, and click the AccountServices BLA.

You now should be able to see two composition units, one is for the AccountServices composite, and the other is for the shared asset for SavingsAccount that WebSphere Application Server created automatically.

Figure 8. Composition Units page segment
SavingsAccount.jar asset mapped as Shared library

Remove the application from the server.


SCA applications in Rational Application Developer 8.5.1

Rational Application Developer Version 8.5.1 supports the two versions of SCA Specification: V1.0 (OSOA) and V1.1 (OASIS).

The concepts and procedures depicted in this article apply to both versions, starting from Rational Application Developer 8.5.1. Just ensure that you select SCA 1.0 or 1.1 in the context menus.

SCA 1.1 projects created in Rational Application Developer v8.5.1 have deployment assembly support by default. However, SCA 1.1 projects created in Rational Application Developer v8.5 do not have deployment assembly support. You need to add the support as in the Add deployment assembly support task.

Summary

You can use IBM WebSphere Application Server to design the deployment of your SCA application in a variety of ways:

  • Single asset
  • Embedded JAR files within the main asset
  • Shared assets

IBM Rational Application Developer helps you map those deployment patterns during development without the need to create a deployment script to fit your architectural needs. This is done by adding deployment assembly support.


Downloads

DescriptionNameSize
Sample filedeployment_patterns_full_sample.zip40KB
Sample filedeployment_patterns_projects.zip38KB

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational, DevOps
ArticleID=856328
ArticleTitle=Deployment patterns for Service Component Architecture applications
publish-date=01292013