ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.platform
Class AblePersistenceSupport

java.lang.Object
  |
  +--com.ibm.able.platform.AblePersistenceSupport
All Implemented Interfaces:
AbleEventQueueProcessor

public final class AblePersistenceSupport
extends java.lang.Object
implements AbleEventQueueProcessor

AblePersistenceSupport is a support Object that others can use to persist information.

Services and Agents and any other part of the platform may wish to persist information, and to do so, they can instantiate one of these Objects. In AblePersistenceSupport's ctor, the database and table to write to, the format of this table, and some addtional processing information will be passed in.

The use of this support object is dependant on the AblePlatformPersistenceService being up and running in the platform. If this object attempts to persist some information while the AblePlatformPersistenceService is not ready to be used, this support object will queue up these missed persist actions and attempt them when the service becomes available.

The class that creates one of these support objects should also implement the AblePersistenceSupportProcessor interface. This is necessary so this support object can call back to the AblePersistenceSupportProcessor that created it and pass back all previously persisted information.


Field Summary
static int PERSIST_ACTION_ADD
          Different types of persist actions that can occur
static int PERSIST_ACTION_REMOVE_MAP
           
static int PERSIST_ACTION_REMOVE_STRING
           
static int PERSIST_ACTION_UPDATE_MAP
           
static int PERSIST_ACTION_UPDATE_STRING
           
 
Constructor Summary
AblePersistenceSupport(java.lang.String persistenceDatabaseName, java.lang.String persistenceTableName, java.lang.String[] persistenceTableColumnNames, java.lang.String[] persistenceTableColumnTypes, long PPSIntervalCheckTime, AblePersistenceSupportProcessor processor, AbleSecuritySupport securitySupport)
          Creates a new AblePersistenceSupport with the supplied properties.
 
Method Summary
 boolean delete(java.util.Map whereMap)
          Handles deleting a record from the table this support Object is dealing with.
 boolean delete(java.lang.String whereString)
          Handles deleting a record from the table this support Object is dealing with.
 java.lang.String getDatabaseName()
          Gets the name of the database used by this persistence support object.
 AbleLogger getLogger()
          Returns a message logger object from the event queue's container.
 int getState()
          Returns the state of the event queue's container.
 java.lang.String[] getTableColumnNames()
          Gets a collection of the names of the columns in the table used by this persistence support object.
 java.lang.String[] getTableColumnTypes()
          Gets a collection of the data types of the columns in the table used by this persistence support object.
 java.lang.String getTableName()
          Gets the name of the database table used by this persistence support object.
 boolean insert(java.lang.Object[] row)
          Handles inserting a record into the table this support Object is dealing with.
 void processAbleEvent(AbleEvent theAbleEvent)
          Processes an Able event synchronously; that is, on the same thread as the caller.
 void processNoEventProcessingEnabledSituation()
          Processes the situation where neither timer nor Able event processing is enabled in the event queue, but the event queue's asynchronous thread of control has been started.
 void processTimerEvent()
          This will be called if we are waiting for the PlatformPersistenceService to get back up.
 void quitAll()
          This method will nicely shut down this AblePersistenceSupport Object.
 void setState(int theState)
          Sets the state of the event queue's container.
 boolean update(java.util.Map updateMap, java.util.Map whereMap)
          Handles updating a record in the table this support Object is dealing with.
 boolean update(java.lang.Object[] row, java.lang.String whereString)
          Handles updating a record in the table this support Object is dealing with.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSIST_ACTION_ADD

public static final int PERSIST_ACTION_ADD
Different types of persist actions that can occur

PERSIST_ACTION_UPDATE_STRING

public static final int PERSIST_ACTION_UPDATE_STRING

PERSIST_ACTION_UPDATE_MAP

public static final int PERSIST_ACTION_UPDATE_MAP

PERSIST_ACTION_REMOVE_STRING

public static final int PERSIST_ACTION_REMOVE_STRING

PERSIST_ACTION_REMOVE_MAP

public static final int PERSIST_ACTION_REMOVE_MAP
Constructor Detail

AblePersistenceSupport

public AblePersistenceSupport(java.lang.String persistenceDatabaseName,
                              java.lang.String persistenceTableName,
                              java.lang.String[] persistenceTableColumnNames,
                              java.lang.String[] persistenceTableColumnTypes,
                              long PPSIntervalCheckTime,
                              AblePersistenceSupportProcessor processor,
                              AbleSecuritySupport securitySupport)
Creates a new AblePersistenceSupport with the supplied properties.

An AblePersistenceSupport is a support Object that others will use to persist information.

Parameters:
persistenceDatabaseName - The database that this persistence support will be using.

persistenceTableName - The table that this persistence support will be using.

persistenceTableColumnNames - The column names of the table that is being persisted to.

persistenceTableColumnTypes - The column types of the table that is being persisted to.

PPSIntervalCheckTime - The interval between checks to the PlatformPersistenceService to see if the PlatformPersistenceService is up and ready.

processor - The AblePersistenceSupportProcessor that will be called back to with the persisted information this AblePersistenceSupport grabs from persistence.

securitySupport - The AbleSecuritySupport Object that will assist in security issues.
Method Detail

processAbleEvent

public void processAbleEvent(AbleEvent theAbleEvent)
                      throws AbleException
Description copied from interface: AbleEventQueueProcessor
Processes an Able event synchronously; that is, on the same thread as the caller.

This method is called by the AbleEventQueue when an event is removed from the queue for asynchronous processing. Note that this method also can be called directly from the handleAbleEvent() method described in the AbleEventListener interface when that method is given a synchronous event to handle.

Specified by:
processAbleEvent in interface AbleEventQueueProcessor
Following copied from interface: com.ibm.able.AbleEventQueueProcessor
Parameters:
theAbleEvent - The event to process.
Throws:
AbleException - If an error occurs.

processTimerEvent

public void processTimerEvent()
                       throws AbleException
This will be called if we are waiting for the PlatformPersistenceService to get back up. This method will check if the PlatformPersistenceService is up and ready. If so, all missed persist actions will be pushed to the PlatformPersistenceService. If not, nothing will be done, processing missed persist actions will be attempted again at the next interval.

Specified by:
processTimerEvent in interface AbleEventQueueProcessor
Throws:
AbleException -  

processNoEventProcessingEnabledSituation

public void processNoEventProcessingEnabledSituation()
                                              throws AbleException
Description copied from interface: AbleEventQueueProcessor
Processes the situation where neither timer nor Able event processing is enabled in the event queue, but the event queue's asynchronous thread of control has been started.

This method is called by an AbleEventQueue when the queue is neither enabled for timer processing nor Able event processing. When neither type of processing is enabled, the queue is in a tight processing loop, consuming CPU cycles. This method is called so that the event queue's container can do something about the situation or perform some other type of asynchronous processing.

Specified by:
processNoEventProcessingEnabledSituation in interface AbleEventQueueProcessor
Following copied from interface: com.ibm.able.AbleEventQueueProcessor
Throws:
AbleException - If an error occurs.

setState

public void setState(int theState)
              throws AbleException
Description copied from interface: AbleEventQueueProcessor
Sets the state of the event queue's container.

This method is called by an AbleEventQueue when the queue's run time loop changes state; for example, from Waiting to Active.

Specified by:
setState in interface AbleEventQueueProcessor
Following copied from interface: com.ibm.able.AbleEventQueueProcessor
Parameters:
theState - An AbleState value.

Throws:
AbleException - If an error occurs.

getState

public int getState()
             throws AbleException
Description copied from interface: AbleEventQueueProcessor
Returns the state of the event queue's container.

This method is called by an AbleEventQueue when the queue needs to interrogate the state of its container.

Specified by:
getState in interface AbleEventQueueProcessor
Following copied from interface: com.ibm.able.AbleEventQueueProcessor
Returns:
An AbleState value.
Throws:
AbleException - If an error occurs.

getLogger

public AbleLogger getLogger()
                     throws AbleException
Description copied from interface: AbleEventQueueProcessor
Returns a message logger object from the event queue's container.
Specified by:
getLogger in interface AbleEventQueueProcessor
Following copied from interface: com.ibm.able.AbleEventQueueProcessor
Returns:
a Logger object.
Throws:
AbleException - If an error occurs.

getDatabaseName

public final java.lang.String getDatabaseName()
Gets the name of the database used by this persistence support object.
Returns:
the name of the database.

getTableName

public final java.lang.String getTableName()
Gets the name of the database table used by this persistence support object.
Returns:
the name of the database table.

getTableColumnNames

public final java.lang.String[] getTableColumnNames()
Gets a collection of the names of the columns in the table used by this persistence support object.
Returns:
a collection of column names.

getTableColumnTypes

public final java.lang.String[] getTableColumnTypes()
Gets a collection of the data types of the columns in the table used by this persistence support object.
Returns:
a collection of data types; for example, if the DB table has a single column of type Object, ["java.lang.Object"] is returned.

insert

public boolean insert(java.lang.Object[] row)
Handles inserting a record into the table this support Object is dealing with.

Parameters:
row - An Object[] representing the row that is to be inserted.

Returns:
boolean indicating success when the persist was sent to the PlatformPersistenceService, or failure if the persist action had to be cached.

update

public boolean update(java.lang.Object[] row,
                      java.lang.String whereString)
Handles updating a record in the table this support Object is dealing with.

Parameters:
row - An Object[] representing the row that is the new updated info.

whereString - The where string for the update statement that will specify which records are to be updated.

Returns:
boolean indicating success when the persist was sent to the PlatformPersistenceService, or failure if the persist action had to be cached.

update

public boolean update(java.util.Map updateMap,
                      java.util.Map whereMap)
Handles updating a record in the table this support Object is dealing with.

Parameters:
updateMap - This is the new data for the record that is to be updated. This is a Map where the keys are the column names and the values are the column values. When using a Map the columns that are not changing do not have to be presents.

whereMap - This is a Map that will be used to build the where clause. The keys will be the column names, and the values will be the Object to match to for their respective column. If left null, or empty, everything will be deleted.

Returns:
boolean indicating success when the persist was sent to the PlatformPersistenceService, or failure if the persist action had to be cached.

delete

public boolean delete(java.lang.String whereString)
Handles deleting a record from the table this support Object is dealing with.

Parameters:
whereString - The where string for the update statement that will specify which records are to be updated.

Returns:
boolean indicating success when the persist was sent to the PlatformPersistenceService, or failure if the persist action had to be cached.

delete

public boolean delete(java.util.Map whereMap)
Handles deleting a record from the table this support Object is dealing with.

Parameters:
whereMap - This is a Map that will be used to build the where clause. The keys will be the column names, and the values will be the Object to match to for their respective column. If left null, or empty, everything will be deleted.

Returns:
boolean indicating success when the persist was sent to the PlatformPersistenceService, or failure if the persist action had to be cached.

quitAll

public void quitAll()
This method will nicely shut down this AblePersistenceSupport Object. It will attempt to end the event event queue, flush out all missed persist actions one last time, and tell the PlatformPersistenceService to clean up the connection that this AblePersistenceSupport Object was using.

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003