TAFJEE Entry Points
TAFJEE provides entry points to process OFS requests, invoke routines with parameters and trigger background program execution. This section provides details about the synchronous and asynchronous entry points in TAFJEE.
TAFJEE provides entry points in two ways:
- Synchronously by doing a Webservice or EJB invocation with TAFJClient API.
- Asynchronously by sending a JMS message with a JMS client or by using CALLJEE statement.
Synchronous Invocation
The two different entry points to synchronously process OFS requests and call routines from a client application are Webservices and EJB. Although both the methods can be used with TAFJClient API at ease, EJB invocation requires a bit more configuration and deployment knowledge.
The TAFJJEEClientFactory is the entry point to get a TAFJJEEClient for both Webservice and EJB invocation.
package com.temenos.tafj.jee.client; public class TAFJJEEClientFactory public static TAFJJEEClient getWebServiceClient(String hostname, String port) public static TAFJJEEClient getEjbClient(AppServerProvider appServer, String hostname, String port)
The TAFJJEEClient is the interface, which provides methods to process an OFS request, to call a subroutine or process a tRun invocation.
package com.temenos.tafj.jee.client; public interface TAFJJEEClient String[] callAt(String routineName, String[] parameters); String processOFS(String request); TRunCallObject trun(TRunCallObject parameter);
The AppServerProvider is an enumeration used by the factory to retrieve the EJB client corresponding to the application server version. As a helper, it also defines ports which are usually used by default for HTTP request and EJB lookup.
package com.temenos.tafj.jee.client; public enum AppServerProvider WEBLOGIC("7001", "7001"), //Weblogic 12.2 WEBSPHERE("9080", "2809"), //Websphere 9 JBOSS7EAP("8080","8080"); //JBoss EAP 7 private final String defaultHttpPort; private final String defaultEJBPort;

Webservice invocation is deployment agnostic. The call is done through the HTTP channel of the application server. The TAFJJEEClientFactory arguments to get a webservice client are the server hostname and http port of the application server. In case of a secured webservice, the user name and password need to be set at thecustomer level.
//Get a Webservice client from server 10.21.2.99 TAFJJEEClient client = TAFJJEEClientFactory.getWebServiceClient("10.21.2.99", "8080"); //Process an OFS request, method argument is the OFS request String response = client.processOFS("ENQUIRY.SELECT,,INPUTT/123456,%CURRENCY"); //Invoke a subroutine, method arguments are the Subroutine name and an array of subroutine parameters String[] response = client.callAt("EXCHRATE", new String[] { "1", "CHF", "500", "GBP", "", "", "", "", "", "" }); //Execute a program in background. A TRunCallObject instance is used to setup the invocation parameters (command and optional user input datas). //It returns a TRunCallObject which contains the response status (0 success / 1 failure) and eventual program output. import com.temenos.tafj.sb.TRunCallObject; //Execute program and get response back TRunCallObject response = client.trun(new TRunCallObject("PROGRAM.NAME ARG1 ARG2")); //In case of secured services, setup username and password for the BASIC Authentication client.setUser("tafj"); client.setPassword("tafjSecretPassword"); //In case of secured (BASIC authentication) services, user and password could be provided at client level client.setUser("tafj"); client.setPassword("tafjSecretPassword");

The EJB invocation depends on the application server version as EJB lookup requires specific parameters such as initial context name and port. The TAFJJEEClientFactory arguments are the application server version, server hostname and application server port for EJB lookup.
In case of unsupported application server version, you need to customize the EJB invocation.
//Get an EJB client from a JBoss7EAP deployment on server 10.21.2.99 TAFJJEEClient client = TAFJJEEClientFactory.getEjbClient(AppServerProvider.JBOSS7EAP, "10.21.2.99", "8080"); //Process an OFS request, method argument is the OFS request String response = client.processOFS("ENQUIRY.SELECT,,INPUTT/123456,%CURRENCY"); //Invoke a subroutine, method arguments are the Subroutine name and an array of subroutine parameters String[] response = client.callAt("EXCHRATE", new String[] { "1", "CHF", "500", "GBP", "", "", "", "", "", "" }); //Execute a program in background. A TRunCallObject instance is used to setup the invocation parameters (command and optional user input datas). //It returns a TRunCallObject which contains the response status (0 success / 1 failure) and eventual program output. import com.temenos.tafj.sb.TRunCallObject; //Execute program and get response back TRunCallObject response = client.trun(new TRunCallObject("PROGRAM.NAME ARG1 ARG2"));
The customer application classpath must contain:
- TAFJJEE_EJBClient.jar
- Application server client libraries to process the EJB lookup
Please refer to the EJB classpath setup section to get more details.
TAFJJEE_EJBClient.jar can be extracted from TAFJJEE_EAR.ear/APP-INF/lib.

The custom EJB invocation allows a specific initial context configuration and override the default EJBs name used during lookup—OFSProcessingBean, CallAtProcessingBean and TRunProcessingBean. The TAFJJEEClientFactory arguments are the initial context name to invoke, context provider URL and map of properties to be applied on the initial context.
//TAFJJEEClientFactory method to get a custom EJB client public static TAFJJEEClient getEjbClient(String INITIAL_CONTEXT_FACTORY, String PROVIDER_URL, Map<Object, Object> contextProperties) //TAFJJEEClient methods to parametrize the OFS and CALLAT bean name public void setOFSBeanName(String beanName); public void setCALLATBeanName(String beanName); public void setTRunBeanName(String beanName);
The following sample illustrates a JBoss 7 EAP custom invocation.
//Create the map of specific properties necessary to lookup an initial context from the application server Map<Object, Object> map = new HashMap<Object, Object>(); map.put("jboss.naming.client.ejb.context", true); //Factory invocation, the initial context name and URL are provided with the map of specific properties TAFJJEEClient client = TAFJJEEClientFactory.getEjbClient("org.jboss.naming.remote.client.InitialContextFactory", "http-remoting://localhost:8080", map); //TAFJJEEClient setup - specify the EJBs name to be used during lookup - note the cast from TAFJJEEClient to EJBClient ((com.temenos.tafj.j2ee.client.EJBClient)client).setOFSBeanName("TAFJJEE_EAR/TAFJJEE_EJB//OFSProcessingBean!com.temenos.tafj.sb.OFSProcessingBeanRemote"); ((com.temenos.tafj.j2ee.client.EJBClient)client).setCALLATBeanName("TAFJJEE_EAR/TAFJJEE_EJB//CallAtProcessingBean!com.temenos.tafj.sb.OFSProcessingBeanRemote"); ((com.temenos.tafj.jee.client.EJBClient)client).setTRunBeanName("TAFJJEE_EAR/TAFJJEE_EJB//TRunProcessingBean!com.temenos.tafj.sb.TRunProcessingBeanRemote"); //Classic OFS processing String response = client.processOFS("ENQUIRY.SELECT,,INPUTT/123456,%CURRENCY"); //Classic subroutine invocation String[] response = client.callAt("EXCHRATE", new String[] { "1", "CHF", "500", "GBP", "", "", "", "", "", "" }); //Classic tRun execution TRunCallObject response = client.trun(new TRunCallObject("PROGRAM.NAME ARG1 ARG2"));

For application server client libraries, the jars can be added manually to the customer application classpath or with maven whenever the dependencies are available in the maven repository.
Please refer to the application server documentation for more details about its customer libraries for remote invocation.
The following section provides examples of some application server customer libaries.
- JBoss 7EAP
Maven dependency: <dependency> <groupId>org.wildfly</groupId> <artifactId>wildfly-ejb-client-bom</artifactId> <version>10.1.0.Final</version> <type>pom</type> </dependency>
- WebLogic 12.2.X
$WEBLO_HOME/wlserver_12.2.X/wlserver/server/lib/wlthint3client.jar
- WAS 9.X
$WAS_HOME/runtimes/com.ibm.ws.ejb.thinclient_9.0.jar $WAS_HOME/runtimes/com.ibm.ws.orb_9.0.jar
You need to generate EJBs stubs for the TAFJ EJB client library and add it to the client application classpath to do remote EJB invocation in a Websphere environment from a thin client.
${was.home}/bin/createEJBStubs TAFJJEE_EJB.jar -newfile TAFJJEE_EJB_Stubs.jar -cp $CLASSPATH
Asynchronous Invocation
JMS can be used to process OFS request and invoke subroutine asynchronously. TAFJ is shipped with a standalone application—JMSInjector, which provides certain utilities to send and receive messages.
The following section provides code sample to write a simple JMS client application. As the code parts related to the JMS resources lookup are application server specific, certain changes may be required to suit the application server versions.
The client application classpath must contain the application server client libraries to process the JMS resources lookup.
The main purpose of the above sample is to describe the JMS client behavior:
- Lookup the JMS resources from the initial context.
- Get a JMS connection through the ConnectionFactory.
- Create a JMS session.
- Create a MessageProducer to send message to the targeted queue.
- Send the OFS request or invoke the subroutine by creating a Text message.
- Eventually create a Message Receiver to receive a response.

The configuration is the same, except for the parts related to initial context and JMS resources lookup.
... env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080"); ... ConnectionFactory jmsCF = (ConnectionFactory) initialContext.lookup("jms/RemoteConnectionFactory"); Destination queue = (Destination) initialContext.lookup("jms/queue/t24OFSQueue"); Destination replyQueue = (Destination) initialContext.lookup("jms/queue/t24OFSReplyQueue"); ...

The configuration is the same, except for the parts related to initial context and JMS resources lookup.
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); env.put(Context.PROVIDER_URL, "t3://localhost:7001"); ... ConnectionFactory jmsCF = (ConnectionFactory) initialContext.lookup("jms/ConnectionFactory"); Destination queue = (Destination) initialContext.lookup("jms/t24OFSQueue"); Destination replyQueue = (Destination) initialContext.lookup("jms/t24OFSReplyQueue"); ...

The configuration is the same, except for the parts related to initial context and JMS resources lookup.
In this code sample, a specific IBM connection factory object is used.
import com.ibm.websphere.sib.api.jms.JmsConnectionFactory; import com.ibm.websphere.sib.api.jms.JmsFactoryFactory; ... env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); env.put("org.omg.CORBA.ORBClass", "com.ibm.CORBA.iiop.ORB"); env.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:2809"); ... JmsConnectionFactory jmsCF = JmsFactoryFactory.getInstance().createQueueConnectionFactory(); jmsCF.setBusName("T24Bus"); jmsCF.setProviderEndpoints("localhost:7276:BootstrapBasicMessaging"); ... Destination queue = (Destination) initialContext.lookup("jms/t24OFSQueue"); Destination replyQueue = (Destination) initialContext.lookup("jms/t24OFSReplyQueue");
In this topic