Application Integration Guide > ResourceAdapter > ResourceAdapter

ResourceAdapter

With the ResourceAdapter, you can use the ApplicationInterface from Enterprise JavaBeans (EJB). Due to technical limitations, you cannot use the ApplicationInterface directly from an EJB. The ResourceAdapter does not run in the Enterprise JavaBean Container. It is therefore not bound to these limitations.

Using the ResourceAdapter and the ApplicationInterface differs in only two points:

All other classes are used in the same way as when the ApplicationInterface is directly accessed.

Connection Establishment

The J2EE Server administers a pool of connections in the Java Connector Architecture (JCA). The EJB must request a connection from it (if required). The J2EE Server either uses a suitable connection from the pool or generates a new one via the ResourceAdapter which is then stored in the pool.

The computer and port number of a communication process are required for establishing a connection via the ApplicationInterface.

Connection uc4 = Connection.open("PC01",2080);

Both parameters are part of the configurationA set of constituent components that make up a system. This includes information on how the components are connected including the settings applied. if the connection is established via the ResourceAdapter. You obtain a pre-configured instance of a ConnectionFactory via a JNDI Lookup. At this point in time, it is not necessary that a connection to the communication process exists.

Context initctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) initctx.lookup("java:comp/env/eis/UC4");

Logon

The JCA distinguishes two logon types:

  1. Component-managed sign-on
    The EJB supplies login data.
  2. Container-managed sign-on
    The J2EE Server supplies login data. The EJB does not require access data such as user nameName of the Automation Engine user. or passwordA secret combination of characters for a Automation Engine user..

Login data is required in order to establish the connection using the ApplicationInterface. The method isLoginSuccessful can be used to query whether the login procedure was successful.

CreateSession login = uc4.login(98,"MEIER","UC4","pass",'D');
if (!login.isLoginSuccessful()) {
...
}

When establishing a connection using the AE.ResourceAdapter, the method getConnection of a factory is used (supplied via a JNDI Lookup) to execute a TCP/IP connection plus login. The following methods are possible:

Usage

Java classes of the ApplicationInterface are used in the same way as when the ApplicationInterface is used directly (except for connection establishment). A simple example is shown below; it executes the object MM.DAY.

Context initctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) initctx.lookup("java:comp/env/eis/UC4");
AdapterConnection uc4 = factory.getConnection();

ExecuteObject execute = new ExecuteObject(new UC4ObjectName("MM.DAY"));
uc4.sendRequestAndWait(execute);
...
uc4.close();

 

See also: