<weblogic-connector
xmlns=http://www.bea.com/ns/weblogic/90>
<jndi-name>eis/TuxedoConnector</jndi-name>
...
<outbound-resource-adapter>
<connection-definition-group>
<connection-factory-interface>javax.resource.cci.ConnectionFactory</connection-factory-interface>
<connection-instance>
<jndi-name>eis/TuxedoConnectionFactory</jndi-name>
</connection-instance>
</connection-definition-group>
<outbound-resource-adapter>
</weblogic-connector>
Listing 2 shows a Connection Factory lookup and Connection instance code example.
The "ctx.lookup()" call uses the string configured in
"jndi-name".
The DMConfigChecker utility is used to encrypt configuration file passwords. It checks the Tuxedo JCA Adapter configuration file syntax and replaces all the unencrypted password elements with the encrypted password. If necessary, this utility can also generate a key file which is used to encrypt/decrypt the passwords.
Interaction ix;
TuxedoInteractionSpec ixspec;
...
ix = c.reateInteraction()
ixspec = new TuxedoInteractionSpec();
Listing 4 shows a client application
synchronously invoking the "
TOUPPER" service.
Listing 5 shows the "
TOUPPER" service using a STRING buffer type for input and output.
Listing 6 shows the actual "
TOUPPER" service request, resource release, and reply data retrieval.
Listing 7 shows a CCI client application program example.
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ejb.CreateException;
import javax.resource.cci.ConnectionFactory;
import javax.resource.cci.Connection;
import javax.resource.cci.Interaction;
import javax.resource.cci.Interactionspec;
import javax.resource.ResourceException;
import weblogic.wtc.jatmi.TPException;
import weblogic.wtc.jatmi.TPReplyException;
import com.oracle.tuxedo.adapter.TuxedoReplyException;
import com.oracle.tuxedo.adapter.cci.TuxedoStringRecord;
import com.oracle.tuxedo.adapter.cci.TuxedoInteractionSpec;
...
public String Toupper(String string_to_convert) throws TPException, TuxedoReplyException
{
Context ctx;
ConnectionFactory cf;
Connection c;
Interaction ix;
TuxedoStringRecord inRec;
TuxedoStringRecord outRec;
TuxedoInteractionSpec ixspec;
try {
ctx = new InitialContext();
cf = ctx.lookup("eis/TuxedoConnectionFactory");
c = cf.getConnection();
ix = c.createInteraction();
ixspec = new TuxedoInteractionSpec();
ixspec.setFunctionName("TOUPPER");
ixspec.setInteractionVerb(InteractionSpec.SYNC_SEND_RECEIVE);
inRec = new TuxedoStringRecord();
outRec = new TuxdeoStringRecord();
inRec.setRecordName("MyInputData");
outRec.setRecordName("MyOutputData");
outRec.setString(string_to_convert);
ix.execute(ixspec, inRec, outRec);
ix.close();
c.close();
String returned_data = outRec.getString();
return returned_data;
}
catch (NamingException ne) {
throw new TPException(TPException.TPESYSTEM,
"Could not get TuxedoConnectionFactory");
}
catch (ResourceException re) {
throw new TPException(TPException.TPESYSTEM,
"ResourceException occurred, reason: " + re);
}
}
Listing 8 shows a VIEW32 definition file example.
In the above example, this command creates a "View32.java" Java file (package name "
tuxedo.test.simpapp"),in the current working directory. If the VIEW32 file contains a nested view32 structure, a corresponding Java file is generated for each nested view.
Listing 9 shows how to create and start a user transaction. The transaction times out after 300 seconds.
Listing 11 shows a client application invoking the "
TOUPPER_32" service using asynchronous interaction.
Listing 12 shows the "
TOUPPER_32" service using a VIEW32 Typed Buffer for input and output.
Listing 13 shows the actual "
TOUPPER_32" service request, resource release, and reply data retrieval.
Listing 14 shows a transaction client application program example.
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ejb.CreateException;
import javax.resource.cci.ConnectionFactory;
import javax.resource.cci.Connection;
import javax.resource.cci.Interaction;
import javax.resource.cci.Interactionspec;
import javax.resource.ResourceException;
import weblogic.wtc.jatmi.TPException;
import weblogic.wtc.jatmi.TPReplyException;
import com.oracle.tuxedo.adapter.TuxedoReplyException;
import com.oracle.tuxedo.adapter.cci.TuxedoView32Record;
import com.oracle.tuxedo.adapter.cci.TuxedoInteractionSpec;
import tuxedo.test.simpapp.View32;
...
private void cleanup(UserTransaction utx, Interaction ix, Connection c)
{
try {
if (utx != null) utx.rollback();
if (ix != null) ix.close();
if (c != null) c.close();
}
catch (Exception e) {
/* ignore */
}
}
public String Toupper(String string_to_convert) throws TPException, TuxedoReplyException
{
Context ctx;
ConnectionFactory cf;
Connection c;
UserTransaction utx;
View32 myData;
View32 myDataBack;
Interaction ix;
TuxedoView32Record inRec;
TuxedoView32Record outRec;
InteractionSpec ixspec;
try {
ctx = new InitialContext();
cf = ctx.lookup("eis/TuxedoConnectionFactory");
c = cf.getConnection();
utx = (UserTransaction)ctx.lookup("java:comp/UserTransaction");
utx.setTransactionTimeout(300);
utx.begin();
ix = c.createInteraction();
ixspec = new TuxedoInteractionSpec();
ixspec.setFunctionName("TOUPPER_V32");
ixspec.setInteractionVerb(InteractionSpec.SYNC_SEND);
myData = new View32();
myData.setTEST_SHORT((short)4);
myData.setTEST_STRING(string_to_convert);
inRec = new TuxedoView32Record(myData);
inRec.setRecordName("MyInputData");
ix.execute(ixspec, inRec);
ixspec.setInteractionVerb(InteractionSpec.SYNC_RECEIVE);
outRec = (TuxedoView32Record)ix.execute(ixspec, inRec);
utx.commit();
ix.close();
c.close();
myDataBack = (View32)outRec.getView32();
String returned_data = myDataBack.getTEST_STRING();
return returned_data;
}
catch (NamingException ne) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPESYSTEM,
"Could not get TuxedoConnectionFactory");
}
catch (ResourceException re) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPESYSTEM,
"ResourceException occurred, reason: " + re);
}
catch (javax.transaction.RollbackException rbe) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPETRAN, "Exception: " + rbe);
}
catch (javax.transaction.NotSuppotedException hre) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPETRAN, "Exception: " + nse);
}
catch (javax.transaction.HeuristicRollbackException hre) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPETRAN, "Exception: " + hre);
}
catch (javax.transaction.HeuristicMixException hme) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPETRAN, "Exception: " + hme);
}
catch (javax.transaction.SystemException se) {
cleanup(utx, ix, c);
throw new TPException(TPException.TPETRAN, "Exception: " + se);
}
}
To develop a synchronous CCI-based Tuxedo JCA Adapter local managed transaction client program using a VIEW32 Typed Buffer, you must do the following steps:
Listing 15 shows how to create a new Tuxedo JCA Adapter Local Transaction instance from the Oracle Tuxedo Connection (
com.oracle.tuxedo.adapter.cci.TuxedoJCALocalTransaction).
Listing 17 shows how to create and start a managed local transaction. The transaction times out after 15 seconds.
Listing 18 shows the client application
synchronously using the "
TOUPPER" service.
Listing 19 shows the "
TOUPPER" service using a STRING Typed Buffer for input and output.
Listing 20 shows the actual "
TOUPPER" service request, resource release, and reply data retrieval.
Listing 21 shows a local transaction client application program example.
Listing 24 shows the actual "
TOUPPER" service request and data retrieval reply.
Listing 26 shows a JATMI client application program example.
public Reply service(TPServiceInformation svcinfo)
throws TPException, TPReplyException, RemoteException;
Listing 28 shows an example of how input data is retrieved using
TPServiceInformation (shown in
Listing 27).
The required prefix (tuxedo.services) and the EJB name (
TolowerHome) are configured in the
<EXPORT> <SOURCE> element of the Tuxedo JCA Adapter configuration file as shown in
Listing 32.
<Export name="TOLOWER">
<RemoteName>TOLOWER</RemoteName>
<SessionName>session_1</SessionName>
<Type>EJB</Type>
<Source>tuxedo.services.TolowerHome</Source>
</Export>
Listing 33 shows an EJB client application program example.
Listing 34 shows an example of how input data is retrieved using
TPServiceInformation (shown in
Listing 27).
The <SOURCE> element contains the fully qualified class name, and the
<SourceLocation> element contains the full path name to the
.JAR file that contains the class. The
.JAR file must be configured in the CLASSPATH.
<Export name="TOLOWER_POJO">
<RemoteName>TOLOWER_POJO</RemoteName>
<SessionName>session_1</SessionName>
<Type>POJO</Type>
<Source>com.oracle.tuxedo.test.MyTolower</Source>
<SourceLocation>c:\tuxedo\jca\test\myapp.jar</SourceLocation>
</Export>
Listing 39 shows a POJO client application program example.
Listing 40 shows an example that enables AUTOTRAN on imported resource
TOUPPER with transaction timeout set to 15 seconds.
Listing 41 shows an example that enables AUTOTRAN on every imported resource with transaction timeout set to 15 seconds.
Listing 42 shows an example
ra.xml file snippet that links the configuration file with the Tuxedo JCA Adapter.
Listing 43 shows an Tuxedo JCA Adapter
DMCONFIG file example that accesses:
Note:
|
TOUPPER_V32 is a VIEW32 Typed Buffer service. TOUPPER is a STRING Typed Buffer service.
|
Listing 44 provides an AUTOTRAN configuration example.
Listing 45 shows an example of a property that enables AUTOTRAN.
Listing 46 and
Listing 47 show
UBBCONFIG and
BDMCONFIG file snippet examples required to expose services inside an Oracle Tuxedo Application Domain and inter-domain requests.
Note:
|
The MDB interface is similar to the existing EJB supported by Tuxedo JCA Adapter; however, they are not the same.
|
This is different from a JMS-based
MDB; it uses the
service() interface instead of the
onMessage() interface.
Listing 49 shows an
MDB code example that implements the “
Tolower” service for an Oracle Tuxedo client.
From menu Window select
Open Perspective, and then select
J2EE.
From menu “File” select
New, then select
Project…. Expand
EJB by clicking it, and then highlight
EJB Project. Click
Next.
In EJB Project menu fill in
Project Name” with “EchoMDB. Click
Next. The “
Select Project Facets” menu will be shown.
In “Select Project Facets” menu, make sure “
EJB Module” version is “
2.1”, “
Java” version is “
5.0”, and “WebSphere EJB (Extended” version is “
6.1”, and make sure these three are selected. Click on “
Next”.
In “EJB Module” menu uncheck “
create an EJB Client JAR module to hold the client interface and classes” since inbound EJB is invoked by Tuxedo JCA Adapter, it is not required. Click on “
Finish”.
Right click on project EchoMDB in the
Project Explorer. Select
Properties from the context menu,
the Properties for EchoMDB window appears as shown in
Figure 1.
Select Add External JARs… from the “Java Build Path”. Add the following two Jar files from Tuxedo JCA Adapter RAR file. (If you have not unzipped the RAR file, do so now.)
In the left Window pane under the Project Explorer, expand the newly created MDB project EchoMDB. Right click
EchoMDB, select
New, and then select
Other. Select
Enterprise Bean and click
Next. The
Create an Enterprise Bean popup window appears as shown in
Figure 2.
Click Next. The “Message Driven Bean type” popup window appears as shown in
Figure 3. Select
Other Type and then click
Browse. Enter
TuxedoMDBService and select from the list shown in
Figure 3, then click
OK.
The Message Driven Bean type popup window appears. Click
Finish.
Expand ejbModule in the left window pane until you see
EchoMDBBean.java. EchoMDBBean.java must be modified to perform the ECHO service. Double click
EchoMDBBean.java and the edit window pane with default editor appears as shown in
Figure 4.
Edit the method service() at the end of the class file as shown in
Listing 2.
Right click project EchoMDB in the Project Explorer, and then select
Deploy as shown in
Figure 5. This compiles it into class in the build directory.
In the Export popup window, select EJB JAR file. Click
Next. The
EJB Jar Export popup window appears as shown in
Figure 7. Select
EchoMDB from the drop down menu, and enter the complete path of the jar file name in the
Destination: text field. Click
Finish.
The Save Resources popup window appears as shown in
Figure 8 click “OK”.
Where eis/echo is the JNDI name of
EchoMDB.
When a Java conversational client initiates a tpconnect() call, the Oracle Tuxedo "C" language conversational server service routine is invoked; however, before the service routine is invoked the Oracle Tuxedo system implements a
RECEIVE command implicitly and puts all the data and events into the input argument of the service routine.
If the Java client initiates tpconnect (TPSENDONLY), the Oracle Tuxedo server will have data in
TPSVCINFO->data, and
TPSVCINFO->len. The
TPSENDONLY flag is translated to
TPRECVONLY and conveyed in the
TPSVCINFO->flags field. In this case, the
TPRECVONLY flag can be ignored by the server service routine, and the server should continue initiating
tprecv() until it receives a
TPEV_SENDONLY event.
If the Java client initiates tpconnect(TPRECVONLY), the Oracle Tuxedo server will have both event and data in
TPSVCINFO. The event is in the
TPSVCINFO->flags field, and user data is in
TPSCVINFO->data, the data length is in
TPSVCINFO->len. The server should start initiating
tpsend() until it either finishes the conversation with
tpreturn(), or returns control to the client with
tpsend(TPRECVONLY).