The content of this guide is the following:
This chapter is provided for advanced JOnAS users concerned with EAI (Enterprise Application Integration). The Java Connector Architecture (Connectors) defines a way for enterprise applications (based on EJB, servlet, JSP or J2EE clients) to communicate with existing external Enterprise Information Systems (EIS). This requires the use of a third party software component called "Resource Adapter" for each type of EIS, which should be previously deployed on the application server. This chapter describes the way such a Resource Adapter should be deployed with JOnAS as the application server, and how a J2EE application can use it.
The Java Connector Architecture allows the connection of different Enterprise Information Systems (EIS) to an application server such as JOnAS. It is based on the Resource Adapter (RA), an architecture component comparable to a software driver, which connects the EIS, the application server, and the enterprise application (EJB components in the case of JOnAS as application server). The RA is generally made available by an EIS vendor, and it provides an interface (the Common Client Interface or CCI) to the enterprise application (EJBs) for accessing the EIS. The RA also provides standard interfaces for plugging into the application server, so that they can collaborate to keep all system-level mechanisms (transactions, security, and connection management) transparent from the application components.
The resource adapter plugs into JOnAS and provides connectivity between the EIS, JOnAS, and the application. The application performs "business logic" operations on the EIS data using the RA client API (CCI), while transactions, connections (including pooling), and security on the EIS is managed by JOnAS through the RA (system contract).
Using a Connector Resource Adapter with JOnAS involves the following steps:
<resource-ref> <res-ref-name>eis/MyEIS</res-ref-name> <res-type>javax.resource.cci.ConnectionFactory</res-type> <res-auth>Container</res-auth> </resource-ref>The mapping to the actual JNDI name of the connection factory (here
adapt_1
) is done in the JOnAS-specific deployment
descriptor with the following element:
<jonas-resource> <res-ref-name>eis/MyEIS</res-ref-name> <jndi-name>adapt_1</jndi-name> </jonas-resource>
This means that the bean programmer will have access to a connection factory instance using the JNDI interface via the java:comp/env/eis/MyEIS name:
// obtain the initial JNDI naming context Context inictx = new InitialContext(); // perform JNDI lookup to obtain the connection factory javax.resource.cci.ConnectionFactory cxf = (javax.resource.cci.ConnectionFactory) inictx .lookup("java:comp/env/eis/MyEIS<");The bean programmer can then get a connection by calling the method
getConnection
on the connection factory.
javax.resource.cci.Connection cx = cxf.getConnection();The returned connection instance represents an application-level handle to a physical connection for accessing the underlying EIS.
close
method on the Connection
interface:
cx.close();
Build a JOnAS-specific resource adapter configuration
file that will be included in the resource adapter.
This jonas-ra XML file is used to configure the resource adapter in
the operational environment and reflects the values of all properties
declared in the deployment descriptor for the resource adapter, plus
additional JOnAS-specific configuration properties. JOnAS provides a
deployment tool RAConfig
that is capable of
building this XML file from an RA deployment descriptor inside an RAR
file. Example:
RAConfig -j adap_1 raThese properties may be specific for each resource adapter and its underlying EIS. They are used to configure the resource adapter via its
managedConnectionFactory
class. It is mandatory that
this class provide getter and setter method for each of its supported
properties (as it is required in the Connector Architecture
specification). Refer to Configuring
Resource Adapters
for a complete description of the
JOnAS-specific configuration file, jonas-ra.xml.jonas.properties
file:
resource
in the
jonas.services
property.jonas.service.resource.resources
RAR file. If the '.rar' suffix is not used on the property, it
will be used when trying to allocate the specified Resource
Adapter.
jonas.service.resource.resources MyEIS.rar, MyEIS1
jonas.service.resource.autoload
in
jonas.properties is configured differently.jonas admin -a xxx.rar
.