Sun Adapter for SAP BAPI API

com.stc.connector.sapbapiadapter.sapbapi
Class FileTIDManagerImpl

java.lang.Object
  extended by com.stc.connector.sapbapiadapter.sapbapi.FileTIDManagerImpl
All Implemented Interfaces:
TIDManager

public class FileTIDManagerImpl
extends java.lang.Object
implements TIDManager

A File-based implementation of a SAP Transactional ID (TID) Manager.

Version:
$Revision: 1.17 $
Author:
Rajesh Dhingra

Nested Class Summary
static class FileTIDManagerImpl.TestFileTIDmanagerImpl
          A standalone tester helper
 
Field Summary
protected static char COMMITTED
          Const COMMITTED, state of the TID
protected static java.lang.String ENCODING
          Const ENCODING
protected static int INBOUND_RECORD_SEP_OFFSET
          Const INBOUND_RECORD_SEP_OFFSET
protected static int INBOUND_STATE_OFFSET
          Const INBOUND_STATE_OFFSET
protected static int INBOUND_TID_RECORD_SIZE
          Const INBOUND_TID_RECORD_SIZE
protected static char LF
          Line Feed
static int OUTBOUND_EID_OFFSET
          Const OUTBOUND_EID_OFFSET
protected static char RESERVED
          Const RESERVED, state of the TID
protected static char UNPROCESSED
          Const UNPROCESSED, state of the TID
 
Fields inherited from interface com.stc.connector.sapbapiadapter.sapbapi.TIDManager
EID_SIZE, TID_SIZE
 
Constructor Summary
protected FileTIDManagerImpl()
          Creates a new FileTIDManagerImpl object for local testing.
  FileTIDManagerImpl(Connector connector, boolean isServer)
          Creates a new FileTIDManagerImpl object.
 
Method Summary
 void confirmTID()
          Confirms the TID in SAP's database.
 java.lang.String createTID(java.lang.String eid)
          Creates a TID (using SAP's method) and stores it persistently, marking it as reserved (R).
static java.io.File getFullPath(java.lang.String fname)
          Converts a partial (maybe) pathname to a fully qualified abstract File object, normalized relative to e*Gate.
 boolean getLockErr()
           
 com.stc.connector.management.util.ObjectReference getMonitor()
          Gets the mbean object for alerts
protected  int indexOf(java.lang.StringBuffer sb, char ch, int fromIndex)
          Returns you an index of the char ch given.
static void main(java.lang.String[] args)
          Standalone tester for the FileTIDManagerImpl
 boolean onCheckTID(java.lang.String tid)
          Checks if the TID has been reserved (R) or committed (C).
 void onCommit(java.lang.String tid)
          Commits the TID into the persistent database.
 void onConfirmTID(java.lang.String tid)
          Confirms the TID in the persistent database.
 void onRollback(java.lang.String tid)
          Rollbacks the TID from the persistent database (marks it as unprocessed, U).
protected  java.lang.StringBuffer readOutboundTIDFile(java.io.RandomAccessFile tidRf)
          Reads the outbound EID/TID database file.
protected  java.lang.StringBuffer readTIDFileFully(java.io.RandomAccessFile raf)
          Reads the TID file in a buffer
 void setMonitor(com.stc.connector.management.util.ObjectReference mbean)
          Sets the mbean object for alerts
protected  void writeTIDFileFully(java.io.RandomAccessFile raf, java.lang.String s)
          Writes TID buffer to file
protected  void writeTIDFileFully(java.io.RandomAccessFile raf, java.lang.StringBuffer sb)
          Writes TID buffer to file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LF

protected static final char LF
Line Feed

See Also:
Constant Field Values

RESERVED

protected static final char RESERVED
Const RESERVED, state of the TID

See Also:
Constant Field Values

COMMITTED

protected static final char COMMITTED
Const COMMITTED, state of the TID

See Also:
Constant Field Values

UNPROCESSED

protected static final char UNPROCESSED
Const UNPROCESSED, state of the TID

See Also:
Constant Field Values

ENCODING

protected static final java.lang.String ENCODING
Const ENCODING

See Also:
Constant Field Values

INBOUND_STATE_OFFSET

protected static final int INBOUND_STATE_OFFSET
Const INBOUND_STATE_OFFSET

See Also:
Constant Field Values

INBOUND_RECORD_SEP_OFFSET

protected static final int INBOUND_RECORD_SEP_OFFSET
Const INBOUND_RECORD_SEP_OFFSET

See Also:
Constant Field Values

INBOUND_TID_RECORD_SIZE

protected static final int INBOUND_TID_RECORD_SIZE
Const INBOUND_TID_RECORD_SIZE

See Also:
Constant Field Values

OUTBOUND_EID_OFFSET

public static final int OUTBOUND_EID_OFFSET
Const OUTBOUND_EID_OFFSET

See Also:
Constant Field Values
Constructor Detail

FileTIDManagerImpl

protected FileTIDManagerImpl()
Creates a new FileTIDManagerImpl object for local testing.


FileTIDManagerImpl

public FileTIDManagerImpl(Connector connector,
                          boolean isServer)
Creates a new FileTIDManagerImpl object.

Parameters:
connector - Connector object associated with this File TID Manager.
isServer - boolean value to indicate client or server mode of operation
Method Detail

getLockErr

public boolean getLockErr()

readTIDFileFully

protected java.lang.StringBuffer readTIDFileFully(java.io.RandomAccessFile raf)
                                           throws java.io.IOException
Reads the TID file in a buffer

Parameters:
raf - the handle to the TID file
Returns:
the TID string buffer
Throws:
java.io.IOException - IOException

writeTIDFileFully

protected void writeTIDFileFully(java.io.RandomAccessFile raf,
                                 java.lang.StringBuffer sb)
                          throws java.io.IOException
Writes TID buffer to file

Parameters:
raf - the file handle to write to
sb - the TID buffer to be written to file
Throws:
java.io.IOException - IOException

writeTIDFileFully

protected void writeTIDFileFully(java.io.RandomAccessFile raf,
                                 java.lang.String s)
                          throws java.io.IOException
Writes TID buffer to file

Parameters:
raf - the file handle to write to
s - the TID buffer to be written to file
Throws:
java.io.IOException - IOException

setMonitor

public void setMonitor(com.stc.connector.management.util.ObjectReference mbean)
Sets the mbean object for alerts

Specified by:
setMonitor in interface TIDManager
Parameters:
mbean - The mbean object.

getMonitor

public com.stc.connector.management.util.ObjectReference getMonitor()
Gets the mbean object for alerts

Specified by:
getMonitor in interface TIDManager
Returns:
the mbean object

onCheckTID

public boolean onCheckTID(java.lang.String tid)
                   throws com.sap.mw.jco.JCO.Exception
Checks if the TID has been reserved (R) or committed (C). It not, the TID will be stored persistently and marked as reserved (R).

Specified by:
onCheckTID in interface TIDManager
Parameters:
tid - The incoming tRFC Transaction ID (TID).
Returns:
true if TID has not been Reserved (R) nor committed (C). false otherwise.
Throws:
com.sap.mw.jco.JCO.Exception

onCommit

public void onCommit(java.lang.String tid)
Commits the TID into the persistent database.

Specified by:
onCommit in interface TIDManager
Parameters:
tid - The TID to commit.

onConfirmTID

public void onConfirmTID(java.lang.String tid)
Confirms the TID in the persistent database. From SAP's standpoint, this means the TID can be removed from the database, since it will never be sent again by SAP.

Specified by:
onConfirmTID in interface TIDManager
Parameters:
tid - The TID to confirm.

onRollback

public void onRollback(java.lang.String tid)
Rollbacks the TID from the persistent database (marks it as unprocessed, U).

Specified by:
onRollback in interface TIDManager
Parameters:
tid - The TID to confirm.

readOutboundTIDFile

protected java.lang.StringBuffer readOutboundTIDFile(java.io.RandomAccessFile tidRf)
                                              throws java.io.IOException
Reads the outbound EID/TID database file.

Parameters:
tidRf - RandomAccessFile pointer to EID/TID database file
Returns:
The string buffer representing the max limit of rows read.
Throws:
java.io.IOException - When IO errors occur

createTID

public java.lang.String createTID(java.lang.String eid)
Creates a TID (using SAP's method) and stores it persistently, marking it as reserved (R).

Specified by:
createTID in interface TIDManager
Parameters:
eid - The eid for which a tid will be created.
Returns:
String The TID created for the eid.

indexOf

protected int indexOf(java.lang.StringBuffer sb,
                      char ch,
                      int fromIndex)
Returns you an index of the char ch given.

Parameters:
sb - the buffer of characters
ch - the char whose index is to be located
fromIndex - the fromIndex
Returns:
int The index of the given char

confirmTID

public void confirmTID()
Confirms the TID in SAP's database. SAP will then remove the TID from its tracking since e*Gate is basically guaranteeing that the TID will never be sent again.

Specified by:
confirmTID in interface TIDManager

getFullPath

public static java.io.File getFullPath(java.lang.String fname)
Converts a partial (maybe) pathname to a fully qualified abstract File object, normalized relative to e*Gate.

Parameters:
fname - The partial pathname.
Returns:
The fully qualified file

main

public static void main(java.lang.String[] args)
Standalone tester for the FileTIDManagerImpl

Parameters:
args - command line arguments

Sun Adapter for SAP BAPI API