|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ge.research.utils.db.DBPoller
Abstract class that defines the general functionality for a database polling utility.
| Field Summary | |
static int |
DEFAULT_POLLING_FREQ
The default polling frequency set to 3 minutes |
| Constructor Summary | |
DBPoller(javax.sql.DataSource datasource)
Calls the default constructor with argument DEFAULT_POLLING_FREQ |
|
DBPoller(javax.sql.DataSource datasource,
int frequency)
Default constructor. |
|
DBPoller(java.lang.String resourceFile)
Calls the default resource file constructor with argument DEFAULT_POLLING_FREQ |
|
DBPoller(java.lang.String resourceFile,
int frequency)
Default resource file constructor. |
|
| Method Summary | |
void |
addDeleteEventListener(DeleteEventListener listener)
Add a listener to watch for database delete events |
void |
addInsertEventListener(InsertEventListener listener)
Add a listener to watch for database insert events |
void |
addUpdateEventListener(UpdateEventListener listener)
Add a listener to watch for database update events |
protected void |
freeConnection(java.sql.Connection connection)
Returns the connection to the connection pool, if that is where it was originally obtained from. |
protected java.sql.Connection |
getConnection()
Obtains a database connection from the active datasource |
long |
getPollFrequency()
Returns the polling frequency in milliseconds |
protected abstract java.util.Vector |
queryForDeletes(java.sql.Connection connection)
Performs the specific logic to check for delete events and creates a DeleteEvent
for each one found, with the desired event information. |
protected abstract java.util.Vector |
queryForInserts(java.sql.Connection connection)
Performs the specific logic to check for insert events and creates an InsertEvent
for each one found, with the desired event information. |
protected abstract java.util.Vector |
queryForUpdates(java.sql.Connection connection)
Performs the specific logic to check for delete events and creates an UpdateEvent
for each one found, with the desired event information. |
void |
removeDeleteEventListener(DeleteEventListener listener)
Remove a listener from watching for database delete events |
void |
removeInsertEventListener(InsertEventListener listener)
Remove a listener from watching for database insert events |
void |
removeUpdateEventListener(UpdateEventListener listener)
Remove a listener from watching for database update events |
void |
run()
Executes the polling, notifying registered listeners when events occur. |
void |
setPollFrequency(long frequency)
Sets the polling frequency to the number of milliseconds specified by frequency.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int DEFAULT_POLLING_FREQ
| Constructor Detail |
public DBPoller(javax.sql.DataSource datasource)
DEFAULT_POLLING_FREQ
datasource - the datasource to acquire database connection information fromDBPoller(javax.sql.DataSource, int)
public DBPoller(java.lang.String resourceFile)
throws java.lang.Exception
DEFAULT_POLLING_FREQ
resourceFile - the resource bundle to use to setup a database connection broker
java.lang.Exception - If an error occurs while setting up the connection brokerDBPoller(java.lang.String, int)
public DBPoller(javax.sql.DataSource datasource,
int frequency)
datasource - the datasource to acquire database connection information fromfrequency - the millisecond value for the poll frequencysetPollFrequency(long)
public DBPoller(java.lang.String resourceFile,
int frequency)
throws java.lang.Exception
SingleConnectionManager
resourceFile - the resource bundle to use to setup a database connection brokerfrequency - the millisecond value for the poll frequency
java.lang.Exception - If an error occurs while setting up the connection brokerDBPoller(javax.sql.DataSource, int)| Method Detail |
public final void addDeleteEventListener(DeleteEventListener listener)
listener - the listener object to notify when delete events happenpublic final void addInsertEventListener(InsertEventListener listener)
listener - the listener object to notify when insert events happenpublic final void addUpdateEventListener(UpdateEventListener listener)
listener - the listener object to notify when update events happenpublic final long getPollFrequency()
public final void removeDeleteEventListener(DeleteEventListener listener)
listener - the listener object to remove from notificationpublic final void removeInsertEventListener(InsertEventListener listener)
listener - the listener object to remove from notificationpublic final void removeUpdateEventListener(UpdateEventListener listener)
listener - the listener object to remove from notificationpublic final void setPollFrequency(long frequency)
frequency.
If the frequency is less than zero, the polling frequency is set to zero.
frequency - the new millisecond value for the poll frequencypublic final void run()
run in interface java.lang.RunnableRunnable.run(),
Thread.sleep(long),
getConnection(),
freeConnection(java.sql.Connection),
queryForDeletes(java.sql.Connection),
queryForInserts(java.sql.Connection),
queryForUpdates(java.sql.Connection)protected void freeConnection(java.sql.Connection connection)
connection - the database connection to return to the pool
protected java.sql.Connection getConnection()
throws java.sql.SQLException
java.sql.SQLException - If an error occurs while attempting to retrieve a connectionprotected abstract java.util.Vector queryForDeletes(java.sql.Connection connection)
DeleteEvent
for each one found, with the desired event information. Called by the run() method
Returns a list of the events found, null if no events were found.
This method should not close the Connection resource when finished. The
Connection resource may be reused outside of this method, and as such it is
the calling method's responsibility to close the Connection resource.
connection - the database connection to use to execute the polling query
DeleteEvents found and created, to be passed to the registered delete event listeners.protected abstract java.util.Vector queryForInserts(java.sql.Connection connection)
InsertEvent
for each one found, with the desired event information. Called by the run() method.
Returns a list of the events found, null if no events were found.
This method should not close the Connection resource when finished. The
Connection resource may be reused outside of this method, and as such it is
the calling method's responsibility to close the Connection resource.
connection - the database connection to use to execute the polling query
InsertEvents found and created, to be passed to the registered insert event listeners.protected abstract java.util.Vector queryForUpdates(java.sql.Connection connection)
UpdateEvent
for each one found, with the desired event information. Called by the run() method
Returns a list of the events found, null if no events were found.
This method should not close the Connection resource when finished. The
Connection resource may be reused outside of this method, and as such it is
the calling method's responsibility to close the Connection resource.
connection - the database connection to use to execute the polling query
DeleteEvents found and created, to be passed to the registered update event listeners.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||