org.compass.gps.device.ibatis
Class SqlMapClientGpsDevice

java.lang.Object
  extended by org.compass.gps.device.AbstractGpsDevice
      extended by org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
          extended by org.compass.gps.device.ibatis.SqlMapClientGpsDevice
All Implemented Interfaces:
CompassGpsDevice

public class SqlMapClientGpsDevice
extends AbstractParallelGpsDevice

A SqlMapClient device, provides support for iBatis 2 and the index operation. The device holds a list of iBatis select statements ids, executes them, and index the result.

The device must be initialized with a SqlMapClient instance. When indexing the data, a SqlMapSession will be opened, and a transaction will be started. The device will then execute the select statement id, and use the iBatis PaginatedList to index the data.

The page size for the PaginatedList can be controlled using the pageSize property.

The select statment can have a parameter object associated with it. If one of the select statements requires a parameter object, then the statementsParameterObjects property must be set. It must have the same size as the selectStatementsIds, and the matching index of the selectStatementsIds should be set at the statementsParameterObjects property.

As a replacement, the setIndexStatements(IndexStatement[]) can be used which combines both a select statement id and its optional parameter.

Author:
kimchy

Nested Class Summary
 class SqlMapClientGpsDevice.SqlMapClientGpsDeviceRowHandler
           
 
Field Summary
 
Fields inherited from class org.compass.gps.device.AbstractGpsDevice
compassGps, log
 
Constructor Summary
SqlMapClientGpsDevice()
           
SqlMapClientGpsDevice(String deviceName, com.ibatis.sqlmap.client.SqlMapClient sqlMapClient, IndexStatement... statements)
           
SqlMapClientGpsDevice(String deviceName, com.ibatis.sqlmap.client.SqlMapClient sqlMapClient, String... selectStatementsIds)
           
SqlMapClientGpsDevice(String deviceName, com.ibatis.sqlmap.client.SqlMapClient sqlMapClient, String[] selectStatementsIds, Object[] statementsParameterObjects)
           
 
Method Summary
protected  IndexEntity[] doGetIndexEntities()
          Returns all the indexed entities for this device.
protected  IndexEntitiesIndexer doGetIndexEntitiesIndexer()
          Returns an index entities indexer that knows how to index indexable entities.
protected  void doStart()
          Derived devices can implement it in case of start event notification.
 com.ibatis.sqlmap.client.SqlMapClient getSqlMapClient()
           
 void setIndexStatements(IndexStatement... statements)
          Sets the given index statements that will be used.
 void setPageSize(int pageSize)
          Sets the pagination/fetch size when iterating through the result set.
 void setSelectStatementsIds(String... statementsNames)
          Sets the select statement ids that will be used to fetch data to be indexed.
 void setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
           
 void setStatementsParameterObjects(Object[] statementsParameterObjects)
          Sets the select statement parameters for each select statment.
 
Methods inherited from class org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
doIndex, index, setIndexEntitiesPartitioner, setParallelIndexExecutor, start
 
Methods inherited from class org.compass.gps.device.AbstractGpsDevice
buildMessage, doStop, getGps, getName, injectGps, isFilteredForIndex, isPerformingIndexOperation, isRunning, refresh, setFilteredEntitiesForIndex, setName, shouldMirrorDataChanges, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlMapClientGpsDevice

public SqlMapClientGpsDevice()

SqlMapClientGpsDevice

public SqlMapClientGpsDevice(String deviceName,
                             com.ibatis.sqlmap.client.SqlMapClient sqlMapClient,
                             IndexStatement... statements)

SqlMapClientGpsDevice

public SqlMapClientGpsDevice(String deviceName,
                             com.ibatis.sqlmap.client.SqlMapClient sqlMapClient,
                             String... selectStatementsIds)

SqlMapClientGpsDevice

public SqlMapClientGpsDevice(String deviceName,
                             com.ibatis.sqlmap.client.SqlMapClient sqlMapClient,
                             String[] selectStatementsIds,
                             Object[] statementsParameterObjects)
Method Detail

doStart

protected void doStart()
                throws CompassGpsException
Description copied from class: AbstractGpsDevice
Derived devices can implement it in case of start event notification.

Overrides:
doStart in class AbstractGpsDevice
Throws:
CompassGpsException

doGetIndexEntities

protected IndexEntity[] doGetIndexEntities()
                                    throws CompassGpsException
Description copied from class: AbstractParallelGpsDevice
Returns all the indexed entities for this device.

Specified by:
doGetIndexEntities in class AbstractParallelGpsDevice
Throws:
CompassGpsException

doGetIndexEntitiesIndexer

protected IndexEntitiesIndexer doGetIndexEntitiesIndexer()
Description copied from class: AbstractParallelGpsDevice
Returns an index entities indexer that knows how to index indexable entities.

Specified by:
doGetIndexEntitiesIndexer in class AbstractParallelGpsDevice

getSqlMapClient

public com.ibatis.sqlmap.client.SqlMapClient getSqlMapClient()

setSqlMapClient

public void setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)

setIndexStatements

public void setIndexStatements(IndexStatement... statements)
Sets the given index statements that will be used. An index statement is a combination of the statement id and a possible parameter.

Note, this method is used to replace the combination of setSelectStatementsIds(String[]) and setStatementsParameterObjects(Object[]).


setSelectStatementsIds

public void setSelectStatementsIds(String... statementsNames)
Sets the select statement ids that will be used to fetch data to be indexed. If parameters are required for some of the statements, they can be passed using setStatementsParameterObjects(Object[]) with the order similar to the statement ids.

Note, this method can be replaced with setIndexStatements(IndexStatement[]).


setStatementsParameterObjects

public void setStatementsParameterObjects(Object[] statementsParameterObjects)
Sets the select statement parameters for each select statment. The order is important and must match the setSelectStatementsIds(String[]) order.

Note, the setIndexStatements(IndexStatement[]) can replce the combination of setSelectStatementsIds(String[]) and setStatementsParameterObjects(Object[]).


setPageSize

public void setPageSize(int pageSize)
Sets the pagination/fetch size when iterating through the result set.



Copyright (c) 2004-2008 The Compass Project.