
Chapter 3: Java Support Samples
Creating a Java application for data delivery
/** A delivery AIM receives a transaction from a SFM and dispatches the data to a receiving end point.
* This application implements the DelAcqAimInterface which defines the default entry points of the application (initialize, deinitialize, servproc and servayt).
* @see DelAimInterface
* @see DfcSfmProxy
* @since 1.0
* @version 1.0
*/public class DelAimSample implements DelAimInterface {
/** Utility variable to store last transaction serial number received by SFM*/
private String m_sLastSerial="";\
/** Utility variable used for sucessfull return value*/
private int iRet = 1;
/** Creates a new instance */
public DelAimSample() {
}
/** This function is inherited from the DelAimInterface
* The delivery application is given a chance to initialize the connection to
an end point for delivery * @return Positive for success
* @see DelAimInterface
*/
public int initialize() {
System.out.println("-->DelAimSample::Called on initialize()");
return 1;
}
/** This function is inherited from the DelAimInterface
* SFM will call this function in order to check if the application is ready to deliver data.
* User code is responsible for setting up the value of the outpout argument lastSerial to the last known good transaction serial number
* @return Positive for ready to deliver, else negative or zero.
* @see DelAimInterface
*/
public int servayt(ServAytArguments oArguments) {
System.out.println("-->DelAimSample::Called on servayt()");
System.out.println(" oArgs.flavor =" + oArguments.flavor);
System.out.println(" oArgs.lastSerial =" + oArguments.lastSerial);
// More elegant solutions will look for the serial number into a lastID file or repository.
oArguments.lastSerial=m_sLastSerial;
return iRet;
}
/** This function is inherited from the DelInterface
* This function is called by Sfm to deliver the transaction. The ServProcArguments wrapper contains all of the specific information for the transaction.
* @return Positive for sucess, -1 for failure, -999 for Cancel transaction upon return, -998 for Skip transaction upon return
* @see DelAimInterface
*/
public int servproc(ServProcArguments oArguments){
System.out.println("-->DelAimSample::Called on servproc()");
System.out.println(" oArgs.delFlavor =" + oArguments.delFlavor);
System.out.println(" oArgs.serial =" + oArguments.serial);
System.out.println(" oArgs.source =" + oArguments.source);
System.out.println(" oArgs.data =" + new String(oArguments.data));
System.out.println(" oArgs.route =" + oArguments.route);
System.out.println(" oArgs.errorText =" + oArguments.errorText);
System.out.println(" oArgs.fkey =" + oArguments.fkey);
System.out.println(" oArgs.options =" + oArguments.options);
System.out.println(" oArgs.priority =" + oArguments.priority);
System.out.println(" oArgs.sfmFlavor =" + oArguments.sfmFlavor);
m_sLastSerial=oArguments.serial;
oArguments.errorText="Hello from the delivery app!";
return iRet;
}
/** This function is inherited from the DelAimInterface
* The delivery application is given a chance to close the connection with an end point application
* @see DelAimInterface
*/
public void deinitialize() {
System.out.println("-->DelAimSample::Called on deinitialize()");
}}
Copyright © 2005. Sybase Inc. All rights reserved.
|
|
View this book as PDF 