关闭

JCO SERVER CONNECTION

标签: serverpropertiessapexceptionfunctionjava
1871人阅读 评论(0) 收藏 举报
分类:

JCO SERVER CONNECTION使用说明

JCo(Sap Java Connect 2010-01-09 22:03:02 阅读66 评论0   字号: 订阅

1.    Jco Server  Connection实现要点

1)       Implement the JCoServerFunctionHandler and the coding to be executed when the call is received.

2)       Create an instance for your JCoServer implementation and start it with start().

 

1.1. 建立与sap端的连接

static

    {

        Properties connectProperties = new Properties();

        connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "10.52.41.3");

        connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "02");

        connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "800");

        connectProperties.setProperty(DestinationDataProvider.JCO_USER, "CRCTEST");

        connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "12345678");

        connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en");

        createDataFile(DESTINATION_NAME1, "jcoDestination", connectProperties);

       

        connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "3");

        connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");

        createDataFile(DESTINATION_NAME2, "jcoDestination", connectProperties);

       

        Properties servertProperties = new Properties();

        servertProperties.setProperty(ServerDataProvider.JCO_GWHOST, "10.52.41.3");

        servertProperties.setProperty(ServerDataProvider.JCO_GWSERV, "3302");

        servertProperties.setProperty(ServerDataProvider.JCO_PROGID, "JCODEMO");

        servertProperties.setProperty(ServerDataProvider.JCO_REP_DEST, "ABAP_AS_WITH_POOL");

        servertProperties.setProperty(ServerDataProvider.JCO_CONNECTION_COUNT, "2");

        createDataFile(SERVER_NAME1, "jcoServer", servertProperties);

    }

ServerDataProvider.JCO_GWHOST 设置的server端的ip地址,ServerDataProvider.JCO_GWSERV设置的是sap端的端口号。

1.2. StfcConnectionHandle类处理RFC

StfcConnectionHandle类继承JCoServerFunctionHandle接口,并重写了handleRequestJCoServerContext serverCtxJCoFunction function)方法。

New 一个DefaultServerHandlerFactory.FunctionHandlerFactory 对象,使用registerHandlerFunction NamestfcConnectionHandler)方法,前面一个参数是sap端所要调用的函数,后面一个参数是StfcConnectionHandler类的一个实例。

然后使用server namesetCallHandlerFactoryDefaultServerHandlerFactory.FunctionHandlerFactory factory)方法,就可以用server.start()了。

补充handleRequestJCoServerContext serverCtxJCoFunction function)功能:

function.getImportParameterList()用来获取sap call Function 传递过来的exporting参数。

function.getExportParameterList().setValue()用来设置importing参数。

 

 

1.3. Simple Server Connection With Exception Listener Server Connection tRFC Server Connection

1.3.1.    With Exception Server Connection Simple Server Connection 的基础上,register Listener Class.

MyThrowableListener eListener = new MyThrowableListener();

server.addServerErrorListener(eListener);

server.addServerExceptionListener(eListener);

 

MyThrowableListener 继承JCoServerErrorListener JCoServerExceptionListener 两个接口,重写了serverErrorOccurred() 和serverExceptionOccurred()方法。

 

1.3.2.    tRFC Server Connection Simple Server Connection的基础上,通过TIDHandler实现事务型Connection

 

myTIDHandler = new MyTIDHandler();

server.setTIDHandler(myTIDHandler);


 JCO SERVER CONNECTION使用说明 - wangjia007bond - 青空飞鸟

MyTIDHandler类继承JCoServerTIDHandler 接口,重写了checkTID(),commit(),rollback(),confirmTID(),execute()方法。

使用了一个HashTable存储statusCREATED, EXECUTED, COMMITTED, ROLLED_BACK, CONFIRMED ),TIDState state = availableTIDs.gettid)。如果statusnull,则改变为CREATED,返回TRUE;如果statusCREATED或者ROLLED_BACK,则返回TRUE,其他返回FALSE

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:263481次
    • 积分:3852
    • 等级:
    • 排名:第8282名
    • 原创:110篇
    • 转载:54篇
    • 译文:0篇
    • 评论:61条
    最新评论