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 Java EE Server administers a pool of connections in the Java Connector Architecture (JCA). The EJB must request a connection from it (if required). The Java EE 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 configuration 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:
LoginAnmeldedaten für Zielsysteme. Auch ein eigener Objekttyp in der Automation Engine. 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:
AdapterConnection uc4 = factory.getConnection();
The configuration of the ResourceAdapter is used for the Server, port, client, department and language. The Java EE Server supplies the user name and password which have been used to log on to the Java EE Server (Single Sign-on).
AdapterConnection uc4 = factory.getConnection(97, "SMITH", "UC4", "pass", 'E')
With this method, all login data is entered in the EJB. This data has a higher priority than data used for configuring the ResourceAdapter. If one or several parameters are not indicated, the corresponding one of the configuration is used. If the attempt to log on was not successful, a ResourceException is triggered whose text describes the error in more detail.
AdapterConnection uc4 = factory.getConnection(97, "UC4", 'E')
Only the client, department and language must be indicated in the EJB. User name and password are supplied by the Java EE Server (see method 1).
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: