Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop SCA composites


Use existing Java EE modules and components as SCA implementations

We can use the Service Component Architecture (SCA) programming model to invoke business services in Java EE components.

The SCA programming model supports Java EE integration. We can expose EJB stateless session beans as SCA services. We can take advantage of SCA annotations to enable the Java EE components, such as session beans, message driven beans, or web components to consume SCA services. You also can rewire EJB references to SCA services. Thus, you can enable an existing Java EE component so that it is recognized as an SCA component and so that the component can participate in an SCA composite.


Procedure

  1. Use non-SCA enhanced Java EE applications as SCA component implementations.
  2. Use SCA enhanced Java EE applications as SCA component implementations.

    For this step, create an application.composite file. Then, determine the Java EE component type to consume SCA services. Depending on the Java EE component type, use SCA annotations:

    If the application uses security, specify security roles and runAs identity in the Java EE application implementation instead of in the composite. Authorization policy is enforced by the implementation.

  3. Rewire EJB references to SCA references.
  4. Deploy an SCA composite using a Java EE application as a component implementation.

    We can deploy an SCA composite that uses an implementation.jee defining a Java EE application as a component implementation. Deploy the SCA composite that uses the application as a component implementation along with the EAR file. Add the SCA composite and Java EE application as composition units of a business-level application.

    1. Import the EAR file as an asset.
    2. Import the SCA composite JAR file as an asset.

    3. Create an empty business-level application.

    4. Add the EAR file asset to the business-level application.

    5. Add the SCA composite asset to the business-level application. Map the SCA composite to the same target server as the EAR file.

    6. If you are rewiring EJB references, set the starting weight of the EAR file to a greater value than the starting weight of the SCA composite. The SCA composite then starts before the EAR file.

    When deploying an SCA JAR contribution that has a deployable SCA composite with implementation.jee for one or more of its SCA components, ensure that the following requirements are met:

    • Deploy the SCA deployable composite and all the Java EE applications used for the SCA component implementation in the same business-level application.

    • Add all the Java EE applications referenced by the archive attribute of the implementation.jee directive to the business-level application before adding the SCA deployable composite.
    • Map all the deployed components of an SCA business-level application to the same target server or cluster.

    • When using an SCA enhanced EAR file that requires injection of values for SCA references, properties, context or component names in Java EE modules such as stateless session beans, servlets, or JSP files, the deployed SCA asset must start before the Java EE asset. If necessary, set the weights of the composition units so that the deployed SCA asset starts before the Java EE asset.

    • If you update Java EE composition units, deploy the SCA composition unit again to apply the changes in the SCA component that uses Java EE implementation.

  5. Start the business-level application.


Results

You now have defined and deployed Java EE components to take advantage of the SCA programming model. The SCA composite and the EAR file are deployed and started, and the Java EE application is able to participate in the SCA domain.

Invoke the EJB services exposed as SCA services using the SCA programming model.


Example

The product provides the HelloJee sample to show how to use SCA annotations within Java EE components so that these components can consume SCA services.

This sample uses the HelloJeeEar.ear, HelloJeeEnhancedEar.ear, and HelloJeeSca.jar SCA sample files.

To download HelloJee sample files from a product website:

  1. Go to the Samples, v8.0 information center.

  2. On the Downloads tab, click FTP or HTTP in the Service Component Architecture section.

  3. In the authentication window, click OK.

  4. From the SCA.zip compressed file, download prebuilt HelloJeeEar.ear, HelloJeeEnhancedEar.ear, and HelloJeeSca.jar files in the SCA/installableApps directory.

    To build your own deployable files, download the SCA/HelloJee directory and follow instructions in SCA/HelloJee/documentation/readme.html to build the files.

Briefly, to deploy the HelloJee sample, do the following:

  1. Import as assets the HelloJeeEar.ear, HelloJeeEnhancedEar.ear, and HelloJeeSca.jar files.

  2. Create a business-level application named HelloJeeBla.

  3. Add the HelloJeeEar.ear and HelloJeeEnhancedEar.ear assets to the business-level application.

  4. Add the HelloJeeSca.jar asset to the business-level application. When adding the asset, ensure that it is targeted to the same server or node as the EAR files added in step 3. If you are adding the JAR file using the admin console, ensure that components HelloJeeEnhancedComponent and HelloJeeComponent are listed on the Set Java EE composition unit relationships page. Also ensure that HelloJeeEnhancedComponent associates with the HelloJeeEnhancedEar composition unit and HelloJeeComponent associates with the HelloJeeEar composition unit.

  5. Start the business-level application.
  6. Run the sample application. Open a web browser on a URL that accesses a sample. The following URLs use localhost for host name and 9080 for port number. Use the host name and WC_defaulthost port number that is correct for your installation.

    • Access the non-SCA enhanced EJB as is: http://localhost:9080/HelloJeeWeb/JeeEjbClient
    • Access the non-SCA enhanced EJB as an SCA service: http://localhost:9080/HelloJeeWeb/JeeScaClient
    • Access the SCA enhanced EJB as is: http://localhost:9080/HelloJeeEnhancedWeb/JeeEEjbClient
    • Access the SCA enhanced EJB service or reference as an SCA service or reference and demonstrate SCA annotations: http://localhost:9080/HelloJeeEnhancedWeb/JeeEScaClient


Related


Use non-SCA enhanced Java EE applications as SCA component implementations
Use SCA enhanced Java EE applications as SCA component implementations
Rewiring EJB references to SCA references
Use SCA annotations with web modules
Use SCA annotations with session beans
Use SCA annotations with message-driven beans
Import assets
Create SCA business-level applications
Example: Create an SCA business-level application with scripting
Start business-level applications
Start business-level applications using scripting
Samples, v8.0 information center


Related


SCA annotations
Service Component Architecture specifications and APIs

+

Search Tips   |   Advanced Search