Use this task to learn how to use Enterprise JavaBeans (EJB) bindings in SCA applications.
Support is provided for EJB bindings in 2.x and 3.x-style beans, for service, reference, and reference target.
The EJB bindings do not support interface.wsdl files.
<?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://neworder/sca/jdbc" name="NewOrderComposite"> <component name="NewOrderEJB3ServiceComponent"> <implementation.java class="neworder.sca.jdbc.NewOrderServiceImpl" requires="managedTransaction.local"/> <service name="NewOrderService" requires="suspendsTransaction"> <interface.java interface="neworder.sca.jdbc.NewOrderService"/> <binding.ejb ejb-version="EJB3"/> </service> </component> </composite>
InitialContext ctxt = new InitialContext(); Object remoteObj = ctxt.lookup("ejb/sca/ejbbinding/NewOrderEJB3ServiceComponent/NewOrderService#neworder.sca.jdbc.NewOrderServiceRemote"); NewOrderServiceRemote newOrderRemote = (NewOrderServiceRemote) PortableRemoteObject.narrow(remoteObj, NewOrderServiceRemote.class);
<?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" targetNamespace="http://erww.workload" name="ConvertComposite"> <component name="ConvertInputOutputServiceComponent"> <implementation.java class="convert.inputoutput.sca.ConvertInputOutputServiceImpl" <reference name="priceQuoteSessionReference"> <interface.java interface="priceQuoteSession.PriceQuoteSession"/> <binding.ejb uri="corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/session/PriceQuoteSessionFacadeBean"/> </reference> </component> </composite>
Different binding.ejb attributes can be used for service side EJB bindings or reference side EJB bindings. The following information explains how the default value is calculated for each side:
The service side EJB binding applies only to Java archive (JAR)-packaged SCA applications.
/sca/ejbbinding/component_name/service_nameTherefore, the URI can be calculated as:
corbaname:iiop:localhost:2812/NameServiceServerRoot#ejb/sca/ejbbinding/component_name/service_nameYou can use it to look up home.
sca/ejbbinding/component_name/service_name
corbaname:iiop:localhost:2812/NameServiceServerRoot#ejb/sca/ejbbinding/component_name/service_name#package.qualified.interface of SCA Java interface with prefix of Remote or Local to the class nameYou can use it directly to get the business interface.
<session name="ServiceNameBean" component-id="sca/ejbbinding/component_name/service_name"/>
When an SCA service is exposed through an EJB service binding, the service is exposed through an enterprise bean. During deployment, the SCA runtime generates a session bean for the service exposed through the EJB binding. The caller of the composite service can invoke this service by accessing the generated enterprise bean as if they are invoking any enterprise bean.
The generated enterprise bean for the composite service is in the directory, profile_root/installedApps/cell_name/composite_name.ear/. Callers need to include the client required classes, such as remote or home, of the generated bean in the classpath or bundle the classes in the JAR file.
uri="corbaname:iiop:host:port/NameServiceServerRoot#ejb/EJB3CounterSample/EJB3Beans.jar /StatelessCounterBean#com.ibm.websphere.ejb3sample.counter.RemoteCounter
uri="ejb/EJB3CounterSample/EJB3Beans.jar/StatelessCounterBean#com.ibm.websphere.ejb3sample.counter.RemoteCounter"or
uri="cell/clusters/cluster_name/ejb/EJB3CounterSample/EJB3Beans.jar /StatelessCounterBean#com.ibm.websphere.ejb3sample.counter.RemoteCounter"or
uri="cell/nodes/node_name/servers/server_name//ejb/EJB3CounterSample/EJB3Beans.jar /StatelessCounterBean#com.ibm.websphere.ejb3sample.counter.RemoteCounter"
Different patterns of the SCA EJB reference binding URI are based on the user setup and configurations. If the SCA EJB reference binding is accessing a stateless session bean on the same server, the EJB reference binding URI can be designated as the JNDI name, uri="ejb/com/app/resumebank/ResumeBankHome". If the SCA EJB reference binding is referencing another SCA service with an EJB binding in the same server, the URI can be designated as the JNDI name, uri="ejb/com/app/resumebank/ResumeBankHome" or you can use the reference target=componentName/serviceName instead of the URI.
uri="cell/clusters/cluster2/ejb/com/app/resumebank/ResumeBankHome" uri="cell/nodes/node_name/servers/server_name/ejb/com/app/resumebank/ResumeBankHome"
If the EJB reference binding is accessing a stateless session bean on a different cell (cross cell) or a mixed cell, you need to create a namespace binding, either an enterprise bean or Corba type, in the administrative console and use the name in namespace binding in EJB reference binding URI such as, uri="cell/persistent/name_in_namespace_binding". For example, uri="cell/persistent/neworder" where neworder is name in the namespace binding.