com.bea.alsb.financial.api
Class DatabasePersistenceAPI

java.lang.Object
  extended by com.bea.alsb.financial.api.DatabasePersistenceAPI

public class DatabasePersistenceAPI
extends Object

This class provides an API for message persistence related operations with message batches - persist a message, query for persisted messages, update a retrieved message and delete a message.

The relevant methods are all public static so that they can be used from ALSB Java Callouts. The class is not designed to be instantiated, and cannot be as it has a private constructor.


Constructor Summary
DatabasePersistenceAPI()
           
 
Method Summary
static void deleteFromDB(MessageWrapper message, String dataSourceName)
          Deletes the wrapped message from database.
static void persistToDB(MessageWrapper message, String dataSourceName)
          Persists the wrapped message to database.
static MessageWrapper queryDB(String messageType, String dataSourceName, String queryName, String parameters)
          Executes a query defined in the cartridge for a particular message type and returns a MessageWrapper object.
static int updateDB(String sql, String dataSourceName)
          Updates the database by executing the sql passed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabasePersistenceAPI

public DatabasePersistenceAPI()
Method Detail

deleteFromDB

public static void deleteFromDB(MessageWrapper message,
                                String dataSourceName)
                         throws DeleteException
Deletes the wrapped message from database. Such a message (with same primary key) must exist in the database, else this function throws a DeleteException.

Parameters:
message - the message to be deleted.
dataSourceName - the logical name of the data source.
Throws:
DeleteException - for any deletion related errors

updateDB

public static int updateDB(String sql,
                           String dataSourceName)
                    throws DatabaseException
Updates the database by executing the sql passed. Such a message (with same primary key) must exist in the database, else this function throws a DeleteException.

Parameters:
dataSourceName - the logical name of the data source.
sql - the sql to be executed
Throws:
DatabaseException - for any database related errors

persistToDB

public static void persistToDB(MessageWrapper message,
                               String dataSourceName)
                        throws PersistenceException
Persists the wrapped message to database.

Parameters:
message - the message to be persisted.
dataSourceName - name of the data source as referenced in the cartridge.
Throws:
PersistenceException - for any persistence related errors

queryDB

public static MessageWrapper queryDB(String messageType,
                                     String dataSourceName,
                                     String queryName,
                                     String parameters)
                              throws QueryException
Executes a query defined in the cartridge for a particular message type and returns a MessageWrapper object.

Parameters:
messageType - the message to be queried.
dataSourceName - the logical data source name.
queryName - name of the query defined in Cartridge
parameters - semi-colon separated list of name-value pairs (e.g. messageType=MT100;Reference=Ref123). This list should contain a value for all parameters in the query definition. The names in the list should match the name of the parameters used in Query definition. The value specified should be convertible to corresponding parameter type.
Returns:
MessageWrapper object
Throws:
QueryException - for any query related errors