Skip Navigation Links | |
Exit Print View | |
![]() |
Importing an SNA Custom Handshake Class Java CAPS Documentation |
Importing an SNA Custom Handshake Class
Adding a Custom Handshake Class to a Project
Configuring the Adapter for a Custom Handshake Class
Importing a Custom Handshake Class into a Project
To further utilize the capabilities of the SNA Adapter, you can implement a custom handshake class in a deployed Project. After the default Collaboration is generated, you can then modify the Collaboration to suit your application’s needs. While you need to write your own code for both Inbound and Outbound SNA modes, the following code is also provided as the source for the class that is implemented in the SNA adapter.
package com.stc.connector.snalu62.api; import com.stc.connector.logging.LogFactory; import com.stc.connector.logging.Logger; import com.stc.connector.snalu62.exception.SNAApplicationException; /* * This is a sample class to implement the interface SNACustomerHandshake. * It implements a simple Accept_Conversation scenario for windows platform. */ public class SNACustomerHandshakeImplSampleAccept implements SNACustomerHandshake { public static final String version = "cvs $Revision: 1.1.2.1.2.2 $ $Date: 2005/11/10 21:40:15 $"; private Logger logger = LogFactory.getLogger("STC.eWay.SNALU62. " + getClass().getName()); private String logMsg; /** * Constructor * */ public SNACustomerHandshakeImplSampleAccept() { super(); } /** * @see com.stc.connector.snalu62.api.SNACustomerHandshake#startConversation (com.stc.connector.snalu62.api.SNACPICCalls) */ public void startConversation(SNACPICCalls cpic) throws SNAApplicationException { try { //do whatever checking logics before/after the following CPIC call on your desires cpic.cmsltp(); //do whatever checking logics before/after the following CPIC call on your desires cpic.cmaccp(); if (!cpic.getConversationAttributes().returnCodeIs(0) && // 0: CM_OK !cpic.getConversationAttributes().returnCodeIs(35)) { //35: CM_OPERATION_INCOMPLETE logMsg = "SNACustomerHandshakeImplSampleAccept.startConversation(): The return code is <" + cpic.getConversationAttributes().getReturnCode() + ">."; logger.error(logMsg); throw new SNAApplicationException(logMsg); } if (cpic.getConversationAttributes().returnCodeIs(35)) { //35: CM_OPERATION_INCOMPLETE logger.info("SNACustomerHandshakeImplSampleAccept.startConversation(): About to call cmwait ..."); //do whatever checking logics before/after the following CPIC call on your desires cpic.cmwait(); } if (!cpic.getConversationAttributes().returnCodeIs(0) || !cpic.getConversationAttributes().convReturnCodeIs(0)) { // 0: CM_OK logMsg = "SNACustomerHandshakeImplSampleAccept.startConversation(): The return_Code is <" + cpic.getConversationAttributes().getReturnCode() + "> and the conversation_Return_Code is <" + cpic.getConversationAttributes().getConvReturnCode() + ">. SNA conversation is not established."; logger.error(logMsg); throw new SNAApplicationException(logMsg); } //do whatever other logics on your desires here //... } catch (Exception e) { logMsg = "SNACustomerHandshakeImplSampleAccept.startConversation(): Failed. Got exception [" + e.toString() + "]."; logger.error(logMsg, e); throw new SNAApplicationException(logMsg, e); } } }
Note - The above code has been wrapped for display purposes.
package com.stc.connector.snalu62.api; import com.stc.connector.logging.LogFactory; import com.stc.connector.logging.Logger; import com.stc.connector.snalu62.exception.SNAApplicationException; /** * This is a sample class to implement the interface SNACustomerHandshake. * It implements a simple Initialize_Conversation scenario for windows platform. */ public class SNACustomerHandshakeImplSampleInitialize implements SNACustomerHandshake { public static final String version = "cvs $Revision: 1.1.2.1.2.2 $ $Date: 2005/11/10 21:40:15 $"; private Logger logger = LogFactory.getLogger("STC.eWay.SNALU62." + getClass(). getName()); private String logMsg; /** * Constructor * */ public SNACustomerHandshakeImplSampleInitialize() { super(); } /** * @see com.stc.connector.snalu62.api.SNACustomerHandshake#startConversation (com.stc.connector.snalu62.api.SNACPICCalls) */ public void startConversation(SNACPICCalls cpic) throws SNAApplicationException { try { //do whatever checking logics before/after the following CPIC call on your desires cpic.cminit(); //do whatever checking logics before/after the following CPIC call on your desires cpic.cmssl(); //do whatever checking logics before/after the following CPIC call on your desires cpic.cmallc(); if (!cpic.getConversationAttributes().returnCodeIs(0)) { // 0: CM_OK logMsg = "SNACustomerHandshakeImplSampleInitialize. startConversation(): The return_Code is <" + cpic.getConversationAttributes().getReturnCode() + ">. SNA conversation is not established."; logger.error(logMsg); throw new SNAApplicationException(logMsg); } //do whatever other logics on your desires here //... } catch (Exception e) { logMsg = "SNACustomerHandshakeImplSampleInitialize.startConversation(): Failed. Got exception [" + e.toString() + "]."; logger.error(logMsg, e); throw new SNAApplicationException(logMsg, e); } } }
Note - The above code has been wrapped for display purposes.