为了减少篇幅例子代码没有全部罗列,只选择粘贴了代码中的关键部分.
编写访问tuxedo service的ejb
关键函数介绍
创建本地接口文件,远程接口文件以及bean文件,公布以下远程方法:
1)public CallDescriptor Tpacall(String service, TypedFML32 in_params)
throws TPException, TPReplyException, RemoteException;
2)public TypedFML32 Tpgetrply(CallDescriptor cd)
throws TPException, TPReplyException, RemoteException;
3)public TypedFML32 Tpcall(String service_name, TypedFML32 in_params)
throws TPException, TPReplyException, RemoteException;
Tpcall : 同步调用tuxedo service.
Tpacall : 异步调用tuxedo service.
Tpgetrply: 等待异步调用service的返回结果.
关键函数代码
import weblogic.wtc.jatmi.Reply;
import weblogic.wtc.jatmi.TypedFML32;
import weblogic.wtc.jatmi.TPException;
import weblogic.wtc.jatmi.TPReplyException;
import weblogic.wtc.gwt.TuxedoConnection;
import weblogic.wtc.gwt.TuxedoConnectionFactory;
import weblogic.wtc.jatmi.Ferror;
import weblogic.wtc.jatmi.CallDescriptor;
import weblogic.wtc.jatmi.ApplicationToMonitorInterface;
private TuxedoConnection tuxConn = null;
函数setUpConnection
public TuxedoConnection setUpConnection() throws TPException
{
Context ctx = null;
TuxedoConnectionFactory tcf = null;
try
{
ctx = new InitialContext();
tcf= (TuxedoConnectionFactory)ctx.lookup(TUXEDOCONN_JNDI_NAME);
}
catch (NamingException ne)
{
throw new TPException(TPException.TPENOENT, \
}
try
{
tuxConn = tcf.getTuxedoConnection();
}
catch (TPException e)
{
throw new TPException(TPException.TPENOENT, \
}
return tuxConn;
}
函数Tpcall
public TypedFML32 Tpcall(String service_name, TypedFML32 in_params) throws TPException, TPReplyException
{
Reply tuxReply = null;
TypedFML32 tuxRtn = null;
try
{
if (tuxConn == null) tuxConn = this.setUpConnection();
}
catch (TPException e)
{
System.out.println(\
throw e;
}
try
{
tuxReply = tuxConn.tpcall(service_name, in_params, 0);
}
catch (TPReplyException tre)
{
System.out.println(\
throw tre;
}
catch (TPException te)
{
System.out.println(\
throw te;
}
catch (Exception ee)
{
System.out.println(\
throw new TPException(TPException.TPESYSTEM, \
}
tuxRtn = (TypedFML32)tuxReply.getReplyBuffer();
return tuxRtn;
}
函数Tpacall
public CallDescriptor Tpacall(String service_name, TypedFML32 in_params) throws TPException, TPReplyException
{
CallDescriptor tuxRtn = null;