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 SCA enhanced Java EE applications as SCA component implementations
You can use an existing Java EE application as a Service Component Architecture (SCA) component after enhancing the application. Define an SCA composite that has components with implementation.ejb and implementation.web component types which refer to EJB and web modules within the Java EE application, and then promote services and references.
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 enterprise archive (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 rewire the SCA services over different bindings. We can rewire EJB references in EJB and web modules to SCA references. Also, you can use SCA annotations to enable Java EE components such as stateless session beans, message driven beans, servlets, listeners, filters, and JSP files to consume SCA services and properties.
Define a composite in a file named application.composite and place the file in the enterprise application META-INF directory.
Procedure
- Create a file named application.composite that defines components with component types of web and EJB modules of the enterprise application. Save the file to the enterprise application META-INF directory.
Use the implementation.web element to declare a service component that is implemented by the web component. The component contains information for the annotations.
To configure a web component implementation, use the following schema:
<implementation.web web-uri="web_module_name"/>Use the implementation.ejb element to declare a service component that is implemented by a session bean component.
To configure an EJB component implementation, use the following schema:
<implementation.ejb ejb-link="EJB_module_name"/>The components can contain one or more supported elements, such as <service>, <reference>, and <property> elements. In the composite definition, promote the services and references to be available in the SCA component using the enterprise application as the component type.
An example application.composite file for an enterprise application named MyEAR.ear follows. The file contains an EJB module named myEJB.jar with a bean named MyBean and a remote business interface named MyRemoteIntf. The file also contains a Web module named myWeb.war.
<?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0"; autowire="false" name="MyComposite" targetNamespace="' class='inlinelink' target="_blank">http://jee"> <service name="MyBean_MyRemoteIntf" promote="MyEJBComponent/MyBean_MyRemoteIntf"/> <reference name="MySCAReference1" promote="MyEJBComponent/MySCAReference1"/> <reference name="MySCAReference2" promote="MyWebComponent/MySCAReference2"/> <component name="MyEJBComponent"> <implementation.ejb ejb-link="MyEJB.jar#MyBean"/> <service name="MyBean_MyRemoteIntf"> <interface.java ... /> </service> <reference name="MySCAReference1" target="MySCAComponent1"> </component> <component name="MyWebComponent"> <implementation.web web-uri="MyWeb.war"/> <reference name="MySCAReference2" target="MySCAComponent2"> </component> </composite>
- Create a component in an SCA composite definition that has the implementation.jee component type and the archive attribute set to the name of the enterprise application asset object.
For the example enterprise application MyEAR.ear, create a component such as 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="MyEAR.ear"/> </component> </composite>- Inject the promoted references into @Reference annotations in the EJB and web modules. Also, rewire the promoted service, and reference the service from other SCA components.
For information about using a composite file to support annotations, refer to the following topics:
- Use SCA annotations with web modules
- Use SCA annotations with session beans
- Use SCA annotations with message-driven beans
- Use a client or an SCA service, invoke the promoted EJB as an SCA service.
Results
The enterprise application is available as an SCA component type. Any SCA component can refer to the promoted services. Java EE modules can access SCA services and properties using SCA annotations. We can rewire the services and reference them like any other SCA service.
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 an 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 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