Introduction
JCA, the J2EE Connector Architecture, is an initiative towards EAI, Enterprise Application Integration. It is a standardized architecture providing the J2EE Components to have plug and play access to heterogeneous EIS, Enterprise Information Systems. Examples of EIS are ERP (Enterprise Resource Planning), Transaction Processing Systems, Legacy Database Systems etc. In the following section we will discuss about the major problems that the programmers had to face for the EIS Integration and the role of JCA.
also read:
- Java EE Tutorials
- Java EE 7 Tutorials
- Java EE Interview Questions
EIS Integration
An Enterprise Information System provides the information infrastructure for an enterprise. This information may be in the form of records in the database, business objects in an ERP, a workflow object in a Customer Relationship Management (CRM) System or a transaction program in a transaction processing application. Prior to the Internet economy, many companies had heavily invested in Business and Management Information Applications Systems.
Examples of such systems can be:-
- ERP, Enterprise Resource Planning applications, such as SAP, BAAN etc.
- CRM, Customer Relationship Management applications, such as Seibel and Clarify.
- Database applications such as DB2 and Sybase.
- Main Transaction processing applications, such as CICS.
- Legacy Database Systems such as IBM’s IMS.
Before the JCA, most vendors supported a variety of custom adapters for integrating their EIS. Basically these adapters provided custom native interfaces, which were complex to incorporate and limited to only one EIS. Because of this the application programmers had to deal with as many adapters as the number of EIS their application communicates to. Some of the limitations are listed below:-
- Application programming for the EIS was proprietary in nature, because there was no generic platform for integration with the open architectures.
- Custom adapters lacked support for Connection Management, which is very crucial for large scale Web Applications, where thousands of customers interact every second. Because of which programmers had to implement connection pooling in their code which is a shear waste of time and money of the enterprises.
- There was no standard infrastructure solution available to provide a vendor-neutral Security Mechanism and Generic Transaction Mechanism support to multiple EIS resource managers.
In order to address the above problems Sun Microsystems released the J2EE Connector Architecture, JCA that provides a standard architecture for integration of J2EE Servers with heterogeneous EIS resources. It provides a common API and a common set of services within a consistent J2EE Environment.
The following diagram shows the J2EE application server with the JCA Components and some Enterprise Information Systems:-
In the above diagram, there is a Web Container and an EJB Container in the J2EE Application Server. There are also some blocks for Resource Adapters. Resource adapters play the role of intermediaries between the J2EE Application / Web Components and the EIS. The programmers communicate with the Resource Adapters using the CCI API, Common Client Interface API. This is very similar to the JDBC API where the J2EE Components communicate with the relational database drivers using the JDBC API.
In this architecture, the J2EE Application Server implements the JCA Services like Connection Management, Transaction Management and Security Management etc. Whereas the EIS vendors implements the Resource Adapters specific to their products. This way the programmers need to code their programs in vendor neutral manner to communicate with heterogeneous EIS resources from different vendors.
Elements of the J2EE Connector Architecture
The JCA is implemented by J2EE compliant Application Servers and the Resource Adapters are provided by the EIS vendors.
The Resource Adapter is an EIS specific, pluggable J2EE Component in the Application Server, which provides an interface for the J2EE Components to communicate with the underlying EIS.
There are the following elements and Services in a JCA implementation:-
- System-level Services: – It defines the standard interface between the J2EE Components and the J2EE Aplication Server provider and the EIS Vendor. This contract specifies the roles and responsibilities of the Resource Adapter and the Application Server, so that they can co-ordinate with each other for the System level services like Connection Pooling, Security and Transactions. Furthermore this allows for any JCA compliant Resource Adapter to be pluggable to any J2EE Compliant Application Server.
- CCI, Common Client Interface: – This is an API which is used by the J2EE Components and other non managed Java Applications (like standalone Java programs and Java Applets) to communicate with the Resource Adapters, which in turn communicate to the underlying EIS.
- Packaging and Deployment Interfaces: – Packaging and Deployment Interfaces allow the Resource Adapters to be able to plug into any Application Server.
The following diagram shows all the components of the J2EE Connector Architecture. It shows how the components communicate with each other.
The CCI, Common Client Interface is part of the implementation of the Resource Adapters. The J2EE components use this API in order to communicate with the underlying EIS resource. Because of the System Level contracts the J2EE Application Servers provide the services like Connection Pooling, Transaction Management and Security Management and the programmers can stay away from the implementation of these services.
There are two types of environments based on the type of client application using the Resource Adapter. These are: –
- Managed Environment: – This includes the multi tired J2EE based Web Applications that may have several Web / Application Components communicating to the Resource Adapters. Such applications are called as the Managed Applications in the JCA context.
- Non-Managed Environment: – In a two tired architecture, where the application client directly uses the application, the Resource Adapter provides the system level services to its clients. Such applications are referred as Non Managed applications.
Resource Adapter
The Resource Adapter is a component in the J2EE Connector Architecture that sits between the J2EE Components and the EIS. This module is implemented with the EIS specific library, which can be written in Java or with native interface components. Basically it implements two things, first is the Common Client Interface, CCI so that when the developers invoke the methods of this library in their code, the invocations can be resolved by the implementations inside the Resource Adapter, and second is the implementation of the functionality through which it connects to the underlying EIS resource and get the work done for the method invocations. The Resource Adapters are required to support the System Level contracts as is required by the Application Servers. There are mainly two types of contracts that a Resource Adapter implements in order to get compliant with the JCA. These are: –
- Application-Level Contracts: – Application Contract basically defines the CCI that the Resource Adapter must implement in order for the J2EE Components and the non-managed components to communicate to the underlying EIS resource.
- System-Level Contracts: – This defines a set of System Contracts which enable the Resource Adapter to plug-in into the Application Server and utilize its services to manage connections, transactions and Security. The three basic contracts are discussed below: –
- Connection Management: – The Connection Management contract specifies the following things: –
- Connection to the Resource Adapters for managed and non-managed components can be made by using consistent application programming techniques, which remain same every time.
- The Resource Adapter provides the Connection Factory and Connection Interface based on the CCI, which in turn is specific to the EIS.
- Provide a generic mechanism for the J2EE components to consume the Application Server services like Transaction, Security and last but not the least the Connection Pooling etc.
- Transaction Management: – This contract extends the Application Server’s transactional capabilities to the underlying EIS Resource Managers. An EIS Resource Manager manages a set of shared EIS resources to participate in a transaction. It can manage the following two types of transactions: –
- XA Transaction: – XA Transactions are controlled and coordinated by external Transaction Managers. A JTA XATransaction Management contract exists between the JCA compliant Resource Adapters and its underlying Resource Manager. The participating EIS resource also supports XA Transactions by implementing an XAResource in their Resource Adapter. The JTA XAResource interface enables two resource managers to participate in transactions coordinated by an external Transaction Manager. This allows the transactions to be managed by a transaction manager which is external to the Resource Adapter.
- Local Transactions: – These transactions do not require any external Transaction Manager, because it is managed internally, either by the J2EE Application Server (container managed) or by the J2EE component (component managed). In Component Managed Transactions the component uses JTA UserTransaction interface or a transaction API specific to the EIS. When an application component requires an EIS Connection, the Application Server starts a local transaction using the currently available transaction context. Upon closure of the connection by the application component, the server commits or rolls back depending upon success or failure of the transaction.
- Security Management:- This contract defines ways to implement security between the Application Server and the EIS resource. There are the following mechanisms used to protect the EIS against unauthorized access and other security threats:-
- Use of user identification, authentication and authorization.
- Use of open network communication security protocols like Kerberos which provide end to end security with authentication and confidentiality services.
- Implementing an EIS specific security Service.
- Connection Management: – The Connection Management contract specifies the following things: –
EIS Sign-On
A Sign-on process is required while creating a new connection to EIS. Based on the security context, authentication and authorization is done for the user to obtain appropriate access. A re-authentication is required in case the Security Context is changed for the user. The following steps are required for sign on:-
- Identity of the initiating user, or Resource Principal, is determined. This helps finding the security context of the user using which the connection will be established to the EIS.
- Resource Principal is authenticated if the connection is not already authenticated.
- Establish a secure connection between the Application Server and the EIS Resource using secure mechanisms like SSL or Kerberos etc. At this point the connection is associated with the initiating user. All subsequent invocations will happen under this context.
This sign-on process can be Application Managed or it can be Container Managed. In case of Application Managed sign-on process, the application component itself provides the security credentials to the EIS Resource Adapter. While in the later case it becomes the duty of the application to find out the Resource Principal of the initiating user and present information of this Resource Principal to the EIS Resource Adapter in the form specific to the JAAS, Java Authentication and Authorization Service.
Packaging and Deploying a Resource Adapter
The Resource Adapters module is packaged as a .rar file, similar to the .ear files for the J2EE Application Modules. There are proper deployment and packaging interfaces that allow a Resource Adapter to plug-in to any J2EE compliant Application Server. The following diagram illustrates the process of packaging and deployment of Resource Adapters module into the Application Server.
The exact steps involved in packaging and deployment are listed below: –
- The EIS Resource Adapter provider, usually the EIS Vendor, implements the Resource Adapter as a set of Interfaces and utility classes implementing the CCI API and the EIS functionality. These implementations take care of the JCA contracts that the Resource Adapter need to follow for JCA compliance.
- All the components of the Resource Adapter, including the source files are packaged into a .rar file, called as Resource Adapter Module. The deployment descriptor of the Resource Adapter specifies the contract between the Resource Adapter provider and the one who deploys the Resource Adapter.
- In the actual deployment process the Resource Adapter is deployed in the Application Server and then it is configured with the Application Server and the underlying EIS environment.
Lets now discuss these steps in greater detail:-
Packaging a Resource Adapter
The Resource Adapters are proper J2EE components packaged in .rar files. One or more Resource Adapters can be staged in one directory and then packaged as .rar files. The following steps are usually involved for packaging a Resource Adapter:-
- Compile the Resource Adapter Java files into a staging directory.
- Create a .jar file to add the class files created in the above step.
- Create an ra.xml deployment descriptor file in the META-INF subdirectory. Add entries for the Resource Adapter.
- Create a J2EE Application Server specific deployment descriptor in the same directory and add the entries for the Resource Adapter.
- Create the Resource Adapter module .rar file by executing the following command: –
jar cvf JavaBeatResourceAdapter.rar -C staging-dir
Now this .rar file can be deployed to the Application Server or packaged inside an application’s .jar file. The packaged Resource Adapter includes the following: –
- Java Classes and Interfaces that implement the functionality of the JCA contract and the underlying EIS resource.
- Some helper classes used by main implementation classes.
- Platform dependent native libraries required by the Resource Adapter.
- Meta information about the above elements.
- Documentation.
After installation of the .rar file, the directory structure of the Application Server looks like the following: –
\AppServerHomeDir \config \JavaBeatDomain \applications \JavaBeatResourceAdapter.rar
There are basically two deployment descriptors packaged within a .rar file of the Resource Adapter Module. These are the ra.xml, which specifies the general information about the Resource Adapter, and the ABCAppServer.xml, which specifies operational parameters required for the Application Server.
Ra.xml, the Resource Adapter deployment descriptor
Following is a deployment descriptor for an ABC Resource Adapter, we will discuss about all the xml elements in this file after this example: –
<connector> <display-name>ABCResourceAdapter<display-name> <vendor-name>Java Beat</vendor-name> <spec-version>1.0</spec-version> <eis-type>JDBC Database</eis-type> <version>1.5</version> <resourceadapter> <managedconnectionfactory-class>com.sun.connector.javabeat.NoTxManagedConnectionFactory</managedconnectionfactory-class> <connectionfactory-interface>javax.sql.Datasource</connectionfactory-interface> <connectionfactory-impl-class> com.sun.Connector.abc.JdbcDataSource</connectionfactory-impl-class> <connection-interface>java.sql.Connection</connection-interface> <connection-impl-class>com.sun.connector.abc.JdbcConnection</connection-impl-class> <transaction-support>NoTransaction</transaction-support> <config-property> <config-property-name>ConnectionURL</config-property-name> <config-property-type>java.lang.String</config-property-type> <config-property-value>jdbc:cloudspace:rmi:CloudscapeDB:create=true</config-property-value> </config-property> <authentication-mechanism> <authentication-mechanism-type>BasicPassword</authentication-mechanism-type> <credential-interface>javax.resource.security.PasswordCredential</credential-interface> </authentication-mechanism> <reauthentication-support>false</reauthentication-support> </resourceadapter> </connector>
The first block of the descriptor is:-
<display-name>ABCResourceAdapter<display-name> <vendor-name>Java Beat</vendor-name> <spec-version>1.0</spec-version> <eis-type>JDBC Database</eis-type> <version>1.5</version>
It lists general information about the Resource Adapter, like its name, Vendor’s name, specification version, the type of the EIS resource that this Adapter is representing and the version of the JCA supported.
Then the name of the class that implements the javax.resource.spi.ManagedConnectionFactory interface is listed in the element.
The ConnectionFactory interface and the implementation class are mentioned thereafter in the following block of the descriptor:-
<connectionfactory-interface>javax.sql.Datasource</connectionfactory-interface> <connectionfactory-impl-class> com.sun.Connector.abc.JdbcDataSource</connectionfactory-impl-class>
The Connection implementation class for the java.sql.Connection interface is com.sun.connector.abc.JdbcConnection.
The level of transaction support can be either NoTransaction, or LocalTransaction or XATransaction. In this example the Resource Adapter does not support transaction which is specified by the NoTransaction value in the element.
Certain properties of ManagedConnectionFactory can be configured by specifying a name and type of the property and then providing a value of the property as follows: –
<config-property> <config-property-name>ConnectionURL</config-property-name> <config-property-type>java.lang.String</ config-property-type> <config-property-value>jdbc:cloudspace:rmi:CloudscapeDB:create=true</ config-property-value> </config-property>
The last section of the deployment descriptor specifies the authentication mechanisms supported by the Resource Adapter provider. In this case only BasicPassword method is supported. The Security Credential interface is javax.resource.security.PasswordCredential. There is no re-authentication support with this Resource Adapter.
<authentication-mechanism> <authentication-mechanism-type>BasicPassword</authentication-mechanism-type> <credential-interface>javax.resource.security.PasswordCredential</credential-interface> </authentication-mechanism> <reauthentication-support>false</reauthentication-support>
The Resource Adapter can be deployed in two ways as discussed below: –
- By using the deploytool command line or the deploytool UI console using the following command: –
-
Deploytool -deployConnector %J2EE_HOME%\lib\connector\abc-ra.rar <HostName>
-
- Deploying as a Web Application archive file, i.e. .ear file. In this method the .rar file is included into the .ear file just as we include a .jar or .war file in it. And then the .ear file is deployed in the Application Server. To identify the .rar module in the package the following line is added into the application.xml file: –
-
<connector>abcresourceadapter.rar</connector>
-
JCA Advantages
J2EE Connector Architecture has emerged as the primary technology for providing a vendor neutral platform for the programmers to communicate with multiple EIS resources without changing their components at all. There are the following scenarios in which the technology offers a potential solution: –
- Enterprise Application Integration: – While integrating multiple EIS applications there are many challenges that need to be taken care of. These include, transaction, security and scalability issues. Multiple EIS vendors providing their own proprietary APIs for integration, which creates much bigger problem of embedding code specific to each vendor into the application components. But with the JCA technology, the EIS vendors are now required to provide with a Resource Adapters obeying the JCA contracts. And the programmers need to understand just the CCI API, required to communicate with the similar Resource Adapter of all the different EIS resources.
- Web-Enabled Enterprise Portals: – Enterprise portals usually unifies all the information, services, applications and processes for all the members of an enterprise, including the employees, clients, partners and customers etc. Such a portal needs to integrate all the heterogeneous EIS resources, such as database systems, information systems etc. which handle all information of the enterprise. In such a scenario the JCA technology solves the problem by seamlessly integrating the different EIS resources by introducing the concept of Resource Adapters and the CCI API. It also helps by providing the EIS sign-on mechanism that supports generic and application specific authentication mechanism.
- Business to Business Integration: – Business to Business integration requires end-to-end process automation and allows application interaction with an enterprise and across partners through the internet. In order to support the external partner interactions, the backend internal business systems need to be seamlessly integrated into the same process. With the help of JCA the backend EIS resources and end to end processes can be integrated without much difficulty.
Summary
In this article we discussed about the concept of JCA, J2EE Connector Architecture, how it helps in solving the problems faced in EAI, Enterprise Application Integration, by introducing the concept of Resource Adapters, and the CCI API to facilitate communication between the J2EE Application Components and the underlying EIS, Enterprise Information Systems. We also discussed about the deployment details of the Resource Adapters by looking into two main deployment descriptors required in the process.
This technology is aimed to solve the problems and challages that the industry face while working with heterogeneus EIS, Enterprise Information Systems. In the next article we will discuss about this technology in more detail, which would be aimed at professional programmers in the J2EE domain.