com.ibm.etill.framework.supervisor
Class Supervisor

java.lang.Object
  |
  +--com.ibm.etill.framework.supervisor.Supervisor

public final class Supervisor
extends Object

Supervisor provides various services to cassettes through a set of class methods. Since this class only contains static methods and no instance variables, it is never actually instantiated.


Constructor Summary
Supervisor()
          Cassettes should never call this constructor.
 
Method Summary
static void addItemToServiceQueue(WorkItem item)
          Adds a work item to the Framework's service thread queue.
static void addItemToTimerQueue(TimeableTransaction item)
          Adds a work item to the Framework's timer thread queue.
static Hashtable batchesForAccount(String merchantNumber, String paymentType, String accountNumber)
          Returns a Hashtable of all the open batches that exist for the specified account.
static Batch createBatch(String merchantNumber, String accountNumber, String paymentType)
          Creates a new batch with a system-generated batch number.
static Batch createBatch(String merchantNumber, String accountNumber, String batchNumber, String paymentType, ParameterTable protocolData)
          Creates a new Batch object using the specified batch number.
static Credit createCredit(Order order, String creditnumber, Amount amount, ParameterTable protocolData)
          Creates a new Credit object.
static Payment createPayment(Order order, String paymentnumber, Amount amount, ParameterTable protocolData)
          Creates a new Payment object.
static Cassette getCassette(String paymentSystem)
          Returns the cassette object for the specified payment system.
static String getExponentForCurrency(String currency)
           
static CommitPoint getThreadCommitPoint()
          Returns the current thread's CommitPoint object.
static Timestamp getTimestamp(long date)
          Returns the actual time and date in a timestamp SQL object.
static String getUniqueKey()
          Generates a unique key value for use as a database record primary key.
static void loadLibrary(String libName)
          Loads the specified native library into storage according to the needs of the underlying operating system.
static void pruneOrder(Order order)
          Prunes an order from the in-storage cache and the database.
static void pruneOrder(Order order, CommitPoint commitPoint)
          Prunes an order from the in-storage cache and the database.
static void pruneOrders(String merchantNumber, Enumeration orders)
          Prunes a set of orders from the in-storage cache and the database.
static void releaseOrder(Order order)
          Deprecated. Included for compatibility with 1.2. No-op in 2.1.
static void removeBatch(Batch batch)
          Removes the Batch object from the in-storage cache.
static void removeItemFromTimerQueue(TimeableTransaction item)
          Removes a work item from the Framework's timer thread queue.
static void removeOrder(Order order)
          Removes the Order object from the in-storage cache.
static Batch retrieveBatch(String merchantNumber, String batchNumber)
          Retrieves the specified batch object from the database and places it in the in-memory Batch cache.
static Order retrieveOrder(String merchantNumber, String orderNumber)
          Retrieves the specified order from the cache or database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Supervisor

public Supervisor()
Cassettes should never call this constructor. Since this class only contains static methods and no instance variables, it is never actually instantiated.
Method Detail

getUniqueKey

public static String getUniqueKey()
Generates a unique key value for use as a database record primary key. Keys generated through this method are typically used to identify binary fields written to the database through the ETillArchive.createBinaryField method.
Returns:
String - a value that is guaranteed to be unique for this Commerce Payments instance.
See Also:
ETillArchive.createBinaryField(byte[], java.lang.String, java.sql.Connection)

createPayment

public static Payment createPayment(Order order,
                                    String paymentnumber,
                                    Amount amount,
                                    ParameterTable protocolData)
                             throws ETillAbortOperation
Creates a new Payment object.
Parameters:
order - the Order object to which the payment will belong.
paymentNumber - a String containing the Payment number (must be unique within this order).
amount - an Amount object containing the authorization amount, exponent, and currency code.
protocolData - a ParameterTable containing protocol-specific key/value pairs
Returns:
Payment - the new Payment object
Throws:
ETillAbortOperation - thrown if payment creation failed. Use the primary and secondary return codes in the exception object to determine the cause.
See Also:
Payment

createCredit

public static Credit createCredit(Order order,
                                  String creditnumber,
                                  Amount amount,
                                  ParameterTable protocolData)
                           throws ETillAbortOperation
Creates a new Credit object.
Parameters:
order - the Order object to which the credit will belong.
creditNumber - a String containing the Credit number (must be unique within this order).
amount - an Amount object containing the credit amount, exponent, and currency code.
protocolData - a ParameterTable containing protocol-specific key/value pairs
Returns:
Payment - the new Credit object
Throws:
ETillAbortOperation - thrown if credit creation failed. Use the primary and secondary return codes in the exception object to determine the cause.
See Also:
Credit

createBatch

public static Batch createBatch(String merchantNumber,
                                String accountNumber,
                                String paymentType)
                         throws ETillAbortOperation
Creates a new batch with a system-generated batch number.
Parameters:
merchantNumber - a String containing the merchant number of the merchant for which this batch is being created.
accountNumber - a String containing the account number of the account under which the batch is being created.
paymentType - a String that identifies the payment protocol associated with this batch. This is actually the name of the cassette that will handle the batch.
Returns:
Batch - the new Batch object
Throws:
ETillAbortOperation - thrown if Batch creation failed. Use the primary and secondary return codes in the exception object to determine the cause.
See Also:
Batch

createBatch

public static Batch createBatch(String merchantNumber,
                                String accountNumber,
                                String batchNumber,
                                String paymentType,
                                ParameterTable protocolData)
                         throws ETillAbortOperation
Creates a new Batch object using the specified batch number.
Parameters:
merchantNumber - a String containing the merchant number of the merchant for which this batch is being created.
accountNumber - a String containing the account number of the account under which the batch is being created.
batchNumber - a String containing the batch number to assign to the batch (must be unique within the Payment Server instance).
paymentType - a String that identifies the payment protocol associated with this batch. This is actually the name of the cassette.
protocolData - a ParameterTable containing the protocol-specific parmeters passed on the API command that caused that batch to be created.
Returns:
Batch - the new Batch object
Throws:
ETillAbortOperation - thrown if Batch creation failed. Use the primary and secondary return codes in the exception object to determine the cause.
See Also:
Batch

removeBatch

public static void removeBatch(Batch batch)
Removes the Batch object from the in-storage cache.
Parameters:
batch - the Batch object to remove.

retrieveBatch

public static Batch retrieveBatch(String merchantNumber,
                                  String batchNumber)
                           throws ETillAbortOperation
Retrieves the specified batch object from the database and places it in the in-memory Batch cache.
Parameters:
merchantNumber - a String containing the merchant number of the merchant for which this batch is being retrieved.
batchNumber - a String containing the batch number of the batch to retrieve.
Returns:
Batch - the specified Batch object
Throws:
ETillAbortOperation - thrown if retrieval failed. Use the primary and secondary return codes in the exception object to determine the cause.

retrieveOrder

public static Order retrieveOrder(String merchantNumber,
                                  String orderNumber)
                           throws ETillAbortOperation
Retrieves the specified order from the cache or database.
Parameters:
merchantNumber - a String containing the merchant number of the merchant for which this order belongs.
orderNumber - a String containing the order number of the order to retrieve.
Returns:
Order - the specified Order object
Throws:
ETillAbortOperation - thrown if retrieval failed. Use the primary and secondary return codes in the exception object to determine the cause.

loadLibrary

public static void loadLibrary(String libName)
Loads the specified native library into storage according to the needs of the underlying operating system. Use this method instead of System.loadLibrary() to ensure that all platform considerations are addressed.
Parameters:
libName - a String containing the "name" of the library to load. Examples: assuming the string "xyz" is passed into this method,
  • On Windows NT, xyz.dll would be loaded
  • On AIX, xyz would be loaded (you must specify the complete library name)
  • On Solaris libxyz.so would be loaded

releaseOrder

public static void releaseOrder(Order order)
Deprecated. Included for compatibility with 1.2. No-op in 2.1.

This function is a no-op in V2R1. The maintenance of cache consistency is performed completely within the framework.
Parameters:
order - the Order object to release from the cache

removeOrder

public static void removeOrder(Order order)
Removes the Order object from the in-storage cache.
Parameters:
order - the order object to remove.

pruneOrder

public static void pruneOrder(Order order,
                              CommitPoint commitPoint)
                       throws ETillAbortOperation
Prunes an order from the in-storage cache and the database.
Parameters:
order - the order to be pruned.
commitPoint - a CommitPoint for archiving.
Throws:
ETillAbortOperation - if the Order can not be pruned

pruneOrder

public static void pruneOrder(Order order)
                       throws ETillAbortOperation
Prunes an order from the in-storage cache and the database.
Parameters:
order - the order to be pruned.
Throws:
ETillAbortOperation - if the Order can not be pruned

pruneOrders

public static void pruneOrders(String merchantNumber,
                               Enumeration orders)
                        throws ETillAbortOperation
Prunes a set of orders from the in-storage cache and the database.
Parameters:
merchantNumber - the merchant identifier
orders - enumeration of OrderNumbers to delete
Throws:
ETillAbortOperation - if the Orders can not be pruned

batchesForAccount

public static Hashtable batchesForAccount(String merchantNumber,
                                          String paymentType,
                                          String accountNumber)
Returns a Hashtable of all the open batches that exist for the specified account.
Parameters:
merchantNumber - a String containing the merchant number of the merchant that owns the batches.
paymentType - a String that identifies the payment protocol associated with the batches. This is actually the name of the cassette.
accountNumber - a String containing the account number of the account through which the batches are processed.
Returns:
Hashtable - contains each open batch for the specified account. BatchKey is used as the key, with the referenced element being the Batch object.
See Also:
BatchKey

getTimestamp

public static Timestamp getTimestamp(long date)
Returns the actual time and date in a timestamp SQL object. IMPORTANT: Precision = one second. Everything shorter than a second is ignored.
Parameters:
date - a long containing a date and time expresssed as the number of milliseconds since January 1, 1970, 00:00:00 UTC.
Returns:
Timestamp - an SQL Timestamp object representing the input date and time.

getCassette

public static Cassette getCassette(String paymentSystem)
                            throws ETillAbortOperation
Returns the cassette object for the specified payment system.
Parameters:
paymentType - a String that identifies the payment protocol associated with the cassette. This is actually the name of the cassette.
Returns:
Cassette - the cassette object for the payment system.
Throws:
ETillAbortOperation - thrown if the cassette object cannot be located.

getThreadCommitPoint

public static CommitPoint getThreadCommitPoint()
Returns the current thread's CommitPoint object.
Returns:
CommitPoint this thread's CommitPoint object.
See Also:
Archivable, CommitPoint, ETillArchive

addItemToServiceQueue

public static void addItemToServiceQueue(WorkItem item)
Adds a work item to the Framework's service thread queue. Items are added to the queue in FIFO order. Cassettes should specify a CassetteWorkItem derivative on this call.
Parameters:
item - the WorkItem object to enqueue.
See Also:
CassetteWorkItem

addItemToTimerQueue

public static void addItemToTimerQueue(TimeableTransaction item)
Adds a work item to the Framework's timer thread queue. Items are added in sorted order according to their timer expiration (as returned by item.timesUpTime()).
Parameters:
item - the TimeableTransaction object to enqueue.
See Also:
CassetteWorkItem, TimeableTransaction

removeItemFromTimerQueue

public static void removeItemFromTimerQueue(TimeableTransaction item)
Removes a work item from the Framework's timer thread queue.
Parameters:
item - the TimeableTransaction object to dequeue.
See Also:
CassetteWorkItem, TimeableTransaction

getExponentForCurrency

public static String getExponentForCurrency(String currency)