IBM Branch Transformation Toolkit Javadoc

com.ibm.btt.services.jdbcjournalservice
Class JournalImpl

java.lang.Object
  extended bycom.ibm.btt.base.Service
      extended bycom.ibm.btt.services.BTTServiceImpl
          extended bycom.ibm.btt.services.PoolableServiceImpl
              extended bycom.ibm.btt.services.jdbcservicesinfra.JDBCServiceImpl
                  extended bycom.ibm.btt.services.jdbcjournalservice.JournalImpl
All Implemented Interfaces:
BTTService, DatabaseConnect, Externalizable, java.io.Externalizable, Poolable, java.io.Serializable
Direct Known Subclasses:
JDBCJournalImpl

public abstract class JournalImpl
extends JDBCServiceImpl

The Journal class is an abstract class that provides all of the data and methods required to build a Financial Electronic Journal. The Journal class is a subclass of real JDBC journal service. Because of this, it has an externalizer that allows you to define any journal object attributes in an external XML file which will been used when the journal object is instantiated. Obviously it inherits all Service Requester attributes. And it will allow you to request an journl action such as add record, query and etc. All the contact with the CHA and formatter service will be handler in this subclass instead of the journal service. . A journal object is then usually instantiated by providing the name of the service to be created to the Service Factory class. The service factory creates an instance of the class that is identified by the name (in this case, a journal) and sets its attributes to the values read from the services XML file.

See Also:
Serialized Form

Field Summary
static java.lang.String COMPID
          Keeps the component identification that will be used by the traces tool.
protected static boolean currentSingleTableReset
           
 java.lang.String date
          Keeps the date that will be used by the Journal service to decide which table generation the current journal instance will have to work with.
 java.lang.String entity
          Keeps the entity information for the current journal instance.
protected  boolean fromPool
           
protected  int lastRecordNumber
          Keeps the number of the last record inserted in the current journal table.
protected  boolean recIdFromTable
           
protected static java.lang.Object recIdSem
           
protected  boolean singleTable
           
protected static int singleTableLastRecordNumber
           
 
Fields inherited from class com.ibm.btt.services.jdbcservicesinfra.JDBCServiceImpl
addPstmt, addString, autoCommit, connectionProperties, databaseConnection, databaseURL, dataSourceName, metaData, operationtime, password, poolName, sharedConnection, STMT_POOL_SIZE_DEFAULT, stmtPool, stmtPoolSize, updateString, user, waitRetry
 
Fields inherited from class com.ibm.btt.services.BTTServiceImpl
DEFAULT_RESPONSE
 
Fields inherited from class com.ibm.btt.base.Service
externalizer, name
 
Constructor Summary
JournalImpl()
           
 
Method Summary
abstract  int addRecord(Hashtable aDataHashtable)
          Inserts the data in aDataHashtable as a new row in the current journal table.
 void close()
          Closes the journal (sets its status to inactive).
abstract  void commit()
          Commits all changes to the database.
protected abstract  java.lang.String controlTableName()
          Returns the control table name that is used internally by the journal service.
abstract  java.lang.String currentGenerationDate()
          Returns the last date that the journal service was used by a specific entity.
 java.lang.String getDate()
          Returns the date attribute value.
 java.lang.String getEntity()
          Returns the entity attribute value.
 boolean getInUse()
          Returns the value of the inUse attribute.
protected  int getLastRecordNumber()
          Returns the lastRecordNumber attribute value.
abstract  int getLastRecordNumberFromTable()
          Returns the lastRecordNumber from control table.
abstract  java.lang.String getSchemaName()
          Returns the schemaName attribute value.
static int getSingleTableLastRecordNumber()
          Returns the singleTableLastRecordNumber.
protected  java.lang.String getState()
          Returns the state attribute value.
abstract  java.lang.String getTableName()
          Returns the current journal table name.
 void initialize()
          Performs any required actions after service instanciation and before starting to use it.
 boolean isActive()
          Answers true if the journal is in an active state.
abstract  boolean isCreateSchema()
          Answers whether a schema has been created for the journal schema in the database.
static boolean isCurrentSingleTableReset()
          Returns the currentSingleTableReset.
 boolean isFromPool()
          Returns the fromPool.
 boolean isRecIdFromTable()
          Returns the recIdFromTable.
 boolean isSingleTable()
          Returns the singleTable.
protected abstract  boolean isValidEntity()
          Checks whether the entity set for the journal instance is a valid entity or not based on the previously created journal tables.
 void open()
          Decides which table should use the journal instance.
abstract  void openOnCurrentTable()
          Sets the journal instance attributes that work with the database table that is currently in use.
abstract  void openOnNextTable()
          Sets the journal instance attributes that work with the next table generation that is available for the specific journal definition.
abstract  int queryLastRecordNumber()
          Retrieves the last record number from the current journal table.
 void reset()
          Resets the Journal.
abstract  void resetSingleTableLastRecordNumber()
          Resets the Journal last record number when different instances are accessing the same tables
abstract  Hashtable retrieveLastRecord()
          Returns the last record in the current journal table in a Hashtable instance.
abstract  Vector retrieveLastRecords(int aNumber)
           
abstract  Hashtable retrieveRecord(int aRecordNumber)
          Returns the record that is identified by aRecordNumber from the current journal table.
abstract  Vector retrieveRecords(java.lang.String aSearchCondition)
          Returns a Vector with a set of Hashtables built from the records in the current journal table that match the selection criteria.
abstract  void rollback()
          Rolls back all changes made to the database using the current connection.
abstract  void setCreateSchema(boolean newCreateSchema)
          Sets the createSchema attribute that keeps information about the existence of a schema in the journal table database.
static void setCurrentSingleTableReset(boolean CurrentSingleTableReset)
          Sets the currentSingleTableReset.
abstract  void setEntity(java.lang.String anEntityName)
          Sets the entity attribute value to anEntityName.
 void setFromPool(boolean fromPool)
          Sets the fromPool.
 void setInUse(boolean b)
          Sets the value of the attribute inUse.
protected  void setLastRecordNumber(int aRecordNumber)
          Sets the lastRecordNumber attribute value to aRecordNumber.
abstract  void setLastRecordNumberFromTable(int aLastRecordNumberFromTable)
          Sets the lastRecordNumberFromTable into control table.
 void setRecIdFromTable(boolean recIdFromTable)
          Sets the recIdFromTable.
abstract  void setSchemaName(java.lang.String aSchemaName)
          Sets the schemaName attribute to aSchemaName.
 void setSingleTable(boolean singleTable)
          Sets the singleTable.
static void setSingleTableLastRecordNumber(int singleTableNumber)
          Sets the singleTableLastRecordNumber.
protected  void setState(java.lang.String aState)
          Sets the state attribute value of the journal instance to aState.
protected abstract  void setTableName(java.lang.String aTableName)
          Sets the name of the table that will use the journal instance.
 void terminate()
          Performs any actions required before stopping using the service instance.
protected  java.lang.String today()
          Returns today's date.
abstract  int updateLastRecord(Hashtable aDataHashtable)
          Updates the contents of the last journal table record with the data in aDataHashtable.
abstract  int updateRecord(int aRecordNumber, Hashtable aDataHashtable)
          Updates the contents of the aRecordNumber journal record with the data in aDataHashtable.
abstract  int updateRecords(java.lang.String aSearchCondition, Hashtable aDataHashtable)
          Updates the contents of all the journal records that match the specified search condition with the data in aDataHashtable.
 
Methods inherited from class com.ibm.btt.services.jdbcservicesinfra.JDBCServiceImpl
buildAddString, buildConnectionProperties, buildStatementArray, buildUpdateString, connect, connect, disconnect, getAddPstmt, getAddString, getAutoCommit, getConnectionManager, getConnectionProperties, getConnMgrID, getDatabaseConnection, getDataSourceName, getPassword, getUpdateString, getUser, handleCommand, isConnected, isWaitRetry, requestConnectionToConnectionManager, requestConnectionToConnectionManager, resetOperationTime, setAddPstmt, setAddString, setAutoCommit, setConnectionManager, setConnectionProperties, setConnMgrID, setDatabaseConnection, setDatabaseURL, setDataSourceName, setPassword, setPoolName, setSharedConnection, setStatementPoolSize, setUpdateString, setUser, setWaitRetry, verifyConnection
 
Methods inherited from class com.ibm.btt.services.PoolableServiceImpl
getGrantTime, getUID, setGrantTime, setUID
 
Methods inherited from class com.ibm.btt.services.BTTServiceImpl
getInactiveTimeout, getLastAccess, initializeFrom, processRequest, setInactiveTimeout, setLastAccess
 
Methods inherited from class com.ibm.btt.base.Service
externalizer, getExternalizer, getName, getTagName, readExternal, readExternal, readObject, removeExternal, setExternalizer, setName, toString, toStrings, toTags, writeExternal, writeExternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPID

public static final java.lang.String COMPID
Keeps the component identification that will be used by the traces tool.

See Also:
Constant Field Values

date

public java.lang.String date
Keeps the date that will be used by the Journal service to decide which table generation the current journal instance will have to work with.


entity

public java.lang.String entity
Keeps the entity information for the current journal instance.


lastRecordNumber

protected int lastRecordNumber
Keeps the number of the last record inserted in the current journal table.


recIdFromTable

protected boolean recIdFromTable

fromPool

protected boolean fromPool

recIdSem

protected static java.lang.Object recIdSem

singleTable

protected boolean singleTable

singleTableLastRecordNumber

protected static int singleTableLastRecordNumber

currentSingleTableReset

protected static boolean currentSingleTableReset
Constructor Detail

JournalImpl

public JournalImpl()
Method Detail

isCurrentSingleTableReset

public static boolean isCurrentSingleTableReset()
Returns the currentSingleTableReset.

Returns:
boolean

setCurrentSingleTableReset

public static void setCurrentSingleTableReset(boolean CurrentSingleTableReset)
Sets the currentSingleTableReset.

Parameters:
CurrentSingleTableReset - The currentSingleTableReset to set

getSingleTableLastRecordNumber

public static int getSingleTableLastRecordNumber()
Returns the singleTableLastRecordNumber.

Returns:
int

setSingleTableLastRecordNumber

public static void setSingleTableLastRecordNumber(int singleTableNumber)
Sets the singleTableLastRecordNumber.

Parameters:
singleTableNumber - The singleTableLastRecordNumber to set

addRecord

public abstract int addRecord(Hashtable aDataHashtable)
                       throws DSEInvalidRequestException,
                              DSEInvalidArgumentException,
                              DSEInternalErrorException,
                              DSESQLException
Inserts the data in aDataHashtable as a new row in the current journal table. This method must be implemented by the subclass.

Parameters:
aDataHashtable - com.ibm.dse.base.Hashtable
Returns:
int - the row number where the journal record is inserted
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

close

public void close()
           throws DSESQLException
Closes the journal (sets its status to inactive). No more journaling operations can be performed on it.

Throws:
DSESQLException - if the close fails

commit

public abstract void commit()
                     throws DSESQLException
Commits all changes to the database. This method must be implemented by the subclass.

Throws:
DSESQLException - if an SQL Exception is caught

controlTableName

protected abstract java.lang.String controlTableName()
Returns the control table name that is used internally by the journal service. This method must be implemented by the subclass.

Returns:
java.lang.String the name

currentGenerationDate

public abstract java.lang.String currentGenerationDate()
                                                throws DSEInternalErrorException,
                                                       DSESQLException
Returns the last date that the journal service was used by a specific entity. This method must be implemented by the subclass.

Returns:
java.sql.Date - the current table generation date
Throws:
DSESQLException - if an SQL Exception is caught
DSEInternalErrorException - if an internal program error occurs

getDate

public java.lang.String getDate()
Returns the date attribute value.

Returns:
java.sql.Date

getEntity

public java.lang.String getEntity()
Returns the entity attribute value.

Returns:
java.lang.String

getInUse

public boolean getInUse()
Returns the value of the inUse attribute.

Specified by:
getInUse in interface Poolable
Overrides:
getInUse in class PoolableServiceImpl
Returns:
boolean - The value of the inUse attribute
See Also:
Poolable.getInUse()

getLastRecordNumber

protected int getLastRecordNumber()
Returns the lastRecordNumber attribute value.

Returns:
int

getSchemaName

public abstract java.lang.String getSchemaName()
Returns the schemaName attribute value.

Returns:
java.lang.String

getState

protected java.lang.String getState()
Returns the state attribute value.

Returns:
java.lang.String

getTableName

public abstract java.lang.String getTableName()
Returns the current journal table name. This method must be implemented by the subclass.

Returns:
java.lang.String

initialize

public void initialize()
                throws DSEException
Performs any required actions after service instanciation and before starting to use it.

Specified by:
initialize in interface Poolable
Overrides:
initialize in class PoolableServiceImpl
Throws:
DSEException
DSEException
See Also:
Poolable.initialize()

isActive

public boolean isActive()
Answers true if the journal is in an active state.

Returns:
boolean

isCreateSchema

public abstract boolean isCreateSchema()
Answers whether a schema has been created for the journal schema in the database.

Returns:
boolean

isValidEntity

protected abstract boolean isValidEntity()
                                  throws DSEInternalErrorException,
                                         DSESQLException
Checks whether the entity set for the journal instance is a valid entity or not based on the previously created journal tables. This method must be implemented by the subclass.

Returns:
boolean
Throws:
DSEInternalErrorException - if an internal program error is detected
DSESQLException - if a SQL Exception is caught

open

public void open()
          throws DSEInternalErrorException,
                 DSEInvalidRequestException,
                 DSEInvalidArgumentException,
                 DSESQLException
Decides which table should use the journal instance. First, it checks if the journal is active. If it is already active, this method checks if the date returned by the method currentGenerationDate() equals the date returned by the method today(). If this is true, the method calls the openOnCurrentTable() method. If not, it calls the openOnNextTable() method.

Throws:
DSEInvalidRequestException - if the entity name is not valid
DSEInternalErrorException - if an internal program error occurs
DSEInvalidArgumentException - if an argument is not valid
DSESQLException - if a SQL Exception occurs

openOnCurrentTable

public abstract void openOnCurrentTable()
                                 throws DSEInvalidRequestException,
                                        DSEInternalErrorException,
                                        DSEInvalidArgumentException,
                                        DSESQLException
Sets the journal instance attributes that work with the database table that is currently in use. To be implemented by the subclass.

Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

openOnNextTable

public abstract void openOnNextTable()
                              throws DSEInternalErrorException,
                                     DSEInvalidRequestException,
                                     DSEInvalidArgumentException,
                                     DSESQLException
Sets the journal instance attributes that work with the next table generation that is available for the specific journal definition. This method must be implemented by the subclass.

Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

queryLastRecordNumber

public abstract int queryLastRecordNumber()
                                   throws DSESQLException,
                                          DSEInternalErrorException
Retrieves the last record number from the current journal table. This method must be implemented by the subclass.

Returns:
int - the record number
Throws:
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

reset

public void reset()
           throws DSEException
Resets the Journal. This method is invoked when releasing the Poolable object

Specified by:
reset in interface Poolable
Overrides:
reset in class PoolableServiceImpl
Throws:
DSEException
See Also:
Poolable.reset()

resetSingleTableLastRecordNumber

public abstract void resetSingleTableLastRecordNumber()
                                               throws DSESQLException,
                                                      DSEInternalErrorException
Resets the Journal last record number when different instances are accessing the same tables

Throws:
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

retrieveLastRecord

public abstract Hashtable retrieveLastRecord()
                                      throws DSEInternalErrorException,
                                             DSEInvalidArgumentException,
                                             DSESQLException
Returns the last record in the current journal table in a Hashtable instance. This method must be implemented by the subclass.

Returns:
com.ibm.dse.base.Hashtable - the retrieved record in hash table format
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

retrieveLastRecords

public abstract Vector retrieveLastRecords(int aNumber)
                                    throws DSEInternalErrorException,
                                           DSEInvalidRequestException,
                                           DSEInvalidArgumentException,
                                           DSESQLException
Throws:
DSEInternalErrorException
DSEInvalidRequestException
DSEInvalidArgumentException
DSESQLException

retrieveRecord

public abstract Hashtable retrieveRecord(int aRecordNumber)
                                  throws DSEInternalErrorException,
                                         DSEInvalidArgumentException,
                                         DSEInternalErrorException,
                                         DSEInvalidArgumentException,
                                         DSESQLException
Returns the record that is identified by aRecordNumber from the current journal table. This method must be implemented by the subclass.

Parameters:
aRecordNumber - int
Returns:
Hashtable
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

retrieveRecords

public abstract Vector retrieveRecords(java.lang.String aSearchCondition)
                                throws DSEInternalErrorException,
                                       DSEInvalidRequestException,
                                       DSEInvalidArgumentException,
                                       DSESQLException
Returns a Vector with a set of Hashtables built from the records in the current journal table that match the selection criteria. This method must be implemented by the subclass.

Parameters:
aSearchCondition - java.lang.String - the selection criteria
Returns:
Vector - the vector of matching records
Throws:
DSEInvalidRequestException - if the request is not valid
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

rollback

public abstract void rollback()
                       throws DSESQLException
Rolls back all changes made to the database using the current connection. This method must be implemented by the subclass.

Throws:
DSESQLException - if an SQL Exception is caught

setCreateSchema

public abstract void setCreateSchema(boolean newCreateSchema)
Sets the createSchema attribute that keeps information about the existence of a schema in the journal table database.

Parameters:
newCreateSchema - boolean

setEntity

public abstract void setEntity(java.lang.String anEntityName)
Sets the entity attribute value to anEntityName.

Parameters:
anEntityName - java.lang.String

setInUse

public void setInUse(boolean b)
Sets the value of the attribute inUse.

Specified by:
setInUse in interface Poolable
Overrides:
setInUse in class PoolableServiceImpl
Parameters:
b - - The new value of the attribute inUse
See Also:
Poolable.setInUse(boolean)

setLastRecordNumber

protected void setLastRecordNumber(int aRecordNumber)
Sets the lastRecordNumber attribute value to aRecordNumber.

Parameters:
aRecordNumber - int

setSchemaName

public abstract void setSchemaName(java.lang.String aSchemaName)
Sets the schemaName attribute to aSchemaName.

Parameters:
aSchemaName - java.lang.String

setState

protected void setState(java.lang.String aState)
Sets the state attribute value of the journal instance to aState.

Parameters:
aState - java.lang.String

setTableName

protected abstract void setTableName(java.lang.String aTableName)
Sets the name of the table that will use the journal instance.

Parameters:
aTableName - java.lang.String

terminate

public void terminate()
               throws DSEException
Performs any actions required before stopping using the service instance.

Specified by:
terminate in interface Poolable
Overrides:
terminate in class PoolableServiceImpl
Throws:
DSEException
DSEException

today

protected java.lang.String today()
Returns today's date. It determines the time frame in which a journal table generation remains valid and can be modified for different journalling systems needs.

Returns:
java.lang.String - String representing today's date with format yyyymmdd

updateLastRecord

public abstract int updateLastRecord(Hashtable aDataHashtable)
                              throws DSEInvalidRequestException,
                                     DSEInvalidArgumentException,
                                     DSEInternalErrorException,
                                     DSESQLException
Updates the contents of the last journal table record with the data in aDataHashtable. This method must be implemented by the subclass.

Parameters:
aDataHashtable - com.ibm.dse.base.Hashtable
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

updateRecord

public abstract int updateRecord(int aRecordNumber,
                                 Hashtable aDataHashtable)
                          throws DSEInvalidRequestException,
                                 DSEInvalidArgumentException,
                                 DSEInternalErrorException,
                                 DSESQLException
Updates the contents of the aRecordNumber journal record with the data in aDataHashtable. This method must be implemented by the subclass.

Parameters:
aRecordNumber - int the number of the record to be updated
aDataHashtable - Hashtable
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

updateRecords

public abstract int updateRecords(java.lang.String aSearchCondition,
                                  Hashtable aDataHashtable)
                           throws DSEInvalidRequestException,
                                  DSEInternalErrorException,
                                  DSEInvalidArgumentException,
                                  DSESQLException
Updates the contents of all the journal records that match the specified search condition with the data in aDataHashtable. This method must be implemented by the subclass.

Parameters:
aSearchCondition - java.lang.String
aDataHashtable - Hashtable
Returns:
int - the row count ( number of updated records)
Throws:
DSEInvalidArgumentException - if the argument(s) is(are) not valid
DSEInvalidRequestException - if the request is not valid
DSEInternalErrorException - if an internal program error occurs
DSESQLException - if an SQL Exception is caught

isRecIdFromTable

public boolean isRecIdFromTable()
Returns the recIdFromTable.

Returns:
boolean

setRecIdFromTable

public void setRecIdFromTable(boolean recIdFromTable)
Sets the recIdFromTable.

Parameters:
recIdFromTable - The recIdFromTable to set

isFromPool

public boolean isFromPool()
Returns the fromPool.

Returns:
boolean

setFromPool

public void setFromPool(boolean fromPool)
Sets the fromPool.

Parameters:
fromPool - The fromPool to set

isSingleTable

public boolean isSingleTable()
Returns the singleTable.

Returns:
boolean

setSingleTable

public void setSingleTable(boolean singleTable)
Sets the singleTable.

Parameters:
singleTable - The singleTable to set

getLastRecordNumberFromTable

public abstract int getLastRecordNumberFromTable()
                                          throws DSEInvalidRequestException
Returns the lastRecordNumber from control table. In this method, all accesses are exclusive.

Returns:
int
Throws:
DSEInvalidRequestException

setLastRecordNumberFromTable

public abstract void setLastRecordNumberFromTable(int aLastRecordNumberFromTable)
Sets the lastRecordNumberFromTable into control table.

Parameters:
aLastRecordNumberFromTable - The lastRecordNumberFromTable to set

IBM Branch Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2005