|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.compass.gps.device.AbstractGpsDevice
org.compass.gps.device.jdbc.AbstractJdbcGpsDevice
public abstract class AbstractJdbcGpsDevice
A helper base class for Jdbc Gps Device. Provides supprot for
DataSource
and
JdbcDialect
. Also
provides template like support for processing database indexing using the
IndexExecution
object hint, and a set of callback methods:
processResultSet(Object, ResultSet, CompassSession)
,
processRow(Object, ResultSet, CompassSession)
, and
processRowValue(Object, ResultSet, CompassSession)
. One of the
callback mehtods should be overriden by the derived class otherwize the class
won't index anyhting.
Nested Class Summary | |
---|---|
static class |
AbstractJdbcGpsDevice.IndexExecution
A hint object which provides the statement query to execute or the actual PreparedStatement . |
Field Summary | |
---|---|
protected DataSource |
dataSource
|
protected JdbcDialect |
dialect
|
protected org.apache.commons.logging.Log |
log
|
Fields inherited from class org.compass.gps.device.AbstractGpsDevice |
---|
compassGps |
Constructor Summary | |
---|---|
AbstractJdbcGpsDevice()
|
Method Summary | |
---|---|
protected abstract AbstractJdbcGpsDevice.IndexExecution[] |
doGetIndexExecutions(Connection connection)
Returns an array of the AbstractJdbcGpsDevice.IndexExecution that should be executed
it's respective ResultSet should be indexed. |
protected void |
doIndex(CompassSession session)
Performs the indexing operation. |
protected void |
doStart()
Derived devices can implement it in case of start event notification. |
DataSource |
getDataSource()
Returns the Jdbc data source that will be used to connect to the database. |
JdbcDialect |
getDialect()
Returns the JdbcDialect that will be used when executing
operations that might have different implementations based on the target
database. |
int |
getFetchSize()
Returns the fetch size that will be used when executing select queries against the database. |
protected void |
processResultSet(Object description,
ResultSet rs,
CompassSession session)
Called for each AbstractJdbcGpsDevice.IndexExecution returned from the
doGetIndexExecutions(Connection) with the ResultSet . |
protected void |
processRow(Object description,
ResultSet rs,
CompassSession session)
Called for each row in the ResultSet which maps to an
AbstractJdbcGpsDevice.IndexExecution . |
protected Object |
processRowValue(Object description,
ResultSet rs,
CompassSession session)
Called for each row in the ResultSet which maps to an
AbstractJdbcGpsDevice.IndexExecution . |
void |
setDataSource(DataSource dataSource)
Sets the Jdbc data source that will be used to connect to the database. |
void |
setDialect(JdbcDialect dialect)
Sets the JdbcDialect that will be used when executing operations
that might have different implementations based on the target database. |
void |
setFetchSize(int fetchSize)
Sets the fetch size that will be used when executing select queries against the database. |
Methods inherited from class org.compass.gps.device.AbstractGpsDevice |
---|
buildMessage, doIndex, doStop, getGps, getName, index, injectGps, isFilteredForIndex, isPerformingIndexOperation, isRunning, refresh, setFilteredEntitiesForIndex, setName, shouldMirrorDataChanges, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.compass.gps.CompassGpsDevice |
---|
getGps, getName, index, injectGps, isPerformingIndexOperation, isRunning, refresh, setName, shouldMirrorDataChanges, start, stop |
Field Detail |
---|
protected org.apache.commons.logging.Log log
protected DataSource dataSource
protected JdbcDialect dialect
Constructor Detail |
---|
public AbstractJdbcGpsDevice()
Method Detail |
---|
protected void doStart() throws CompassGpsException
AbstractGpsDevice
doStart
in class AbstractGpsDevice
CompassGpsException
protected void doIndex(CompassSession session) throws CompassGpsException
doGetIndexExecutions(Connection)
method with
an open connection to get the list of AbstractJdbcGpsDevice.IndexExecution
to perform.
For each AbstractJdbcGpsDevice.IndexExecution
, executes the select query, and calls
the processResultSet(Object, ResultSet, CompassSession)
for the
returned ResultSet
.
CompassGpsException
protected void processResultSet(Object description, ResultSet rs, CompassSession session) throws SQLException, CompassException
AbstractJdbcGpsDevice.IndexExecution
returned from the
doGetIndexExecutions(Connection)
with the ResultSet
.
Can be override by derived classes, if not override, than iterates threw
the ResultSet
and calls
processRow(Object, ResultSet, CompassSession)
for each row.
SQLException
CompassException
protected void processRow(Object description, ResultSet rs, CompassSession session) throws SQLException, CompassException
ResultSet
which maps to an
AbstractJdbcGpsDevice.IndexExecution
. Can be override by derived classes, if not
override, than calls
processRowValue(Object, ResultSet, CompassSession)
and uses it's
return value to save it in the CompassSession
. The return
value can be an OSEM enables object, a Resource
, or an
array of one of them.
SQLException
CompassException
protected Object processRowValue(Object description, ResultSet rs, CompassSession session) throws SQLException, CompassException
ResultSet
which maps to an
AbstractJdbcGpsDevice.IndexExecution
. Can be override by derived classes, and should
return the actual data to be saved using the CompassSession
.
The return value can be either an OSEM enables object, a
Resource
, or an array of one of them.
SQLException
CompassException
protected abstract AbstractJdbcGpsDevice.IndexExecution[] doGetIndexExecutions(Connection connection) throws SQLException, JdbcGpsDeviceException
AbstractJdbcGpsDevice.IndexExecution
that should be executed
it's respective ResultSet
should be indexed.
SQLException
JdbcGpsDeviceException
public DataSource getDataSource()
JdbcGpsDevice
getDataSource
in interface JdbcGpsDevice
public void setDataSource(DataSource dataSource)
JdbcGpsDevice
start
method.
setDataSource
in interface JdbcGpsDevice
public int getFetchSize()
JdbcGpsDevice
PreparedStatement#setFetchSize
.
getFetchSize
in interface JdbcGpsDevice
public void setFetchSize(int fetchSize)
JdbcGpsDevice
PreparedStatement#setFetchSize
.
setFetchSize
in interface JdbcGpsDevice
public JdbcDialect getDialect()
JdbcGpsDevice
JdbcDialect
that will be used when executing
operations that might have different implementations based on the target
database.
getDialect
in interface JdbcGpsDevice
public void setDialect(JdbcDialect dialect)
JdbcGpsDevice
JdbcDialect
that will be used when executing operations
that might have different implementations based on the target database.
setDialect
in interface JdbcGpsDevice
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |