In this tutorial we will show how you can create your own JCA Connector project to connect to a remote TCP Server and deploy it on JBoss AS 7.1.1.
The Java Connector Architecture (JCA) defines a standard architecture for connecting the Java EE platform to heterogeneous Enterprise Information Systems (EIS). Examples of EISs include Enterprise Resource Planning (ERP), mainframe transaction processing (TP), database and messaging systems.
The IronJacamar project implements the Java Connector Architecture 1.6 specification and is available in a stable version, and a developer version.
In order to create your own Adapter, you need to define your Contract in a Resource Adapter Connection class, define a Factory for creating your Connection to the Resource Adapter and provide the Connector Managed classes which are used to creates a new physical connection to the underlying EIS resource manager and communicate with it.
The following picture shows the list of classes which we will create in our project:
For this purpose create a new Connector Project from Eclipse (You can also use an ordinary Java Project, however the Connector project has the advantage of automatically publishing the project as RAR archive to JBoss ):
Choose a meaningful name for your Connector project and click Finish
We will not expose all the project classes but just the core parts of it (You can download all the project classes at the bottom of this article).
The first step will be defining your connector exposed methods in the Connection class
Next, your main concern will be implementing the Managed Connection class which contains the actual implementation for our method write which writes to a Socket stream and returns the data from the stream.
Finally, the RAConnectionImpl holds the actual Socket connection to the remote server, which sends data to the server and reads back the output from the remote socket.