Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop SCA composites > Use existing Java EE modules and components as SCA implementations


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

We can use an existing Java EE application as a Service Component Architecture (SCA) component without requiring SCA annotations or composite files.

Identify the Java EE application that contains business logic in EJB or web modules to enable in the SCA environment.

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

The SCA programming model supports Java EE integration. We 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.

We 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. We can use the admin 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. 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.
Use existing Java EE modules and components as SCA implementations
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


Related


SCA annotations
Service Component Architecture specifications and APIs

+

Search Tips   |   Advanced Search