Using non-SCA enhanced Java EE applications as SCA component implementations

You can use an existing Java Platform, Enterprise Edition (Java EE) application as a Service Component Architecture (SCA) component without requiring SCA annotations or composite files.

Before you begin

Identify the Java EE application that contains business logic in Enterprise JavaBeans (EJB) or Web modules to enable in the SCA environment.

A Java EE application is also called an enterprise application or enterprise archive (EAR) file.

About this task

The SCA programming model supports Java EE integration. You can expose EJB stateless session beans as SCA services by enabling an existing enterprise application module to be recognized as an SCA component and participate in an SCA composite.

You can use an enterprise application as an SCA component implementation, without requiring any SCA annotations or composite files in the application. Such an application is denoted as a non-SCA enhanced enterprise application.

The EJB business interfaces of stateless session beans configured in EJB modules are exposed as SCA services. The EJB business interfaces of EJB references configured in EJB and Web modules are exposed as SCA references.

The component type of a non-SCA enhanced enterprise application is defined as follows:

Procedure

  1. Create a component in an SCA composite definition. Specify the implementation.jee component type and set the archive attribute to the name of the asset object.

    For example, the composite definition for a implementation.jee component named ImplJeeComponent that uses the MyJEE.ear archive resembles the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"; autowire="false"
        name="ImplJeeSCAComposite" targetNamespace="' class='inlinelink' target="_blank">http://jee">
      <component name="ImplJeeComponent">
        <implementation.jee archive="MyJEE.ear"/>
      </component>
    </composite>
  2. Optional: Write client code that looks up and invokes a derived SCA service.

    A client can look up and invoke a derived SCA service. For example, suppose the ImplJeeComponent component has a stateless session bean named Bean1 with a remote interface Intf1 in an EJB module in the enterprise application. Invoke the service with code such as the following:

    CompositeContext compositeContext = CurrentCompositeContext.getContext();
    Intf1 myEjb = compositeContext.getService(Intf1.class, "ImplJeeComponent/Bean1_Intf1");
    retStr = ejb.myOperation();
  3. Optional: Define a reference to a derived service in an SCA component composite. Use the injected value of a matching @Reference SCA annotation to invoke an EJB service as an SCA service.

    Instead of writing client code to look up and invoke the derived SCA server (step 2), you can define a reference to the derived service in an SCA component composite. An SCA service in a component can use the injected value of a matching @Reference SCA annotation to invoke the EJB service as a SCA service.

    For example, the ImplJeeComponent component might invoke an EJB service as a SCA service using the following code. The SCA component reference code resembles:
    <reference name="MyRef" target="ImplJeeComponent/Bean1_Intf1>
    The SCA service code resembles:
    @Reference public Intf1 MyRef;
    .....
    String retStr = MyRef.myOperation();
    ....

Results

The enterprise application is available as an SCA component type. Any SCA component can refer to the derived services.

What to do next

Deploy the enterprise application and the SCA composite that uses the application as composition units of the same business-level application. You can use the administrative console or wsadmin commands to create the business-level application and add the enterprise application and the SCA composite as composition units.

The product provides the HelloJee sample. The sample has a non-SCA enhanced EJB. If you selected to install Samples during creation of a profile enabled by the feature pack, the product adds several SCA sample files to the app_server_root/samples/SCA and app_server_root/installableApps directories. For details on deploying the HelloJee sample, refer to app_server_root/samples/SCA/HelloJee/documentation/readme.html. Also, the Example section in the Using existing Java EE modules and components as SCA implementations topic summarizes how to deploy the HelloJee sample and access the non-SCA enhanced EJB.




In this information ...


Related reference

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Jun 12, 2013 3:32:32 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v700osgijpa&product=was-nd-mp&topic=tsca_jee_nonenhanced
File name: tsca_jee_nonenhanced.html