|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.services.sqldataloader.mru.SqlBeanMapMRUDataLoader
Class provides a generic lookup class to users with a mechanism to cache data retreived from a table. The map implementation and object containing the data and the query retreiving the data are all configurable propertied read from the component configuration file.
It reads the data from database using the configured query and loads it into Javabean objects which are loaded into a map then stored in cache.
Copyright 2003 Sapient
Field Summary | |
protected SqlBeanMapMRUDataLoaderConfiguration |
config
Reference to configuration document |
private org.apache.commons.logging.Log |
log
The handle to Apache-commons logger |
Constructor Summary | |
SqlBeanMapMRUDataLoader()
|
Method Summary | |
void |
configure(ComponentConfiguration configuration)
Configure the component. |
protected Map |
getMapInstance()
Returns an instance of configured map implementation. |
Object |
loadDatum(Object key)
Loads the Object corresponding to the particular key supplied. |
protected ResultSet |
retrieveResult(Connection connection,
Object key)
Creates and executes the PreparedStatement to retrieve data from database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.apache.commons.logging.Log log
protected SqlBeanMapMRUDataLoaderConfiguration config
Constructor Detail |
public SqlBeanMapMRUDataLoader()
Method Detail |
public void configure(ComponentConfiguration configuration)
configure
in interface Configurable
configuration
- A GenericTotalCacheDataLoaderConfigurationprotected ResultSet retrieveResult(Connection connection, Object key) throws SQLException
Creates and executes the PreparedStatement to retrieve data from database. This method abstracts out the creation and execution of SQL statement.
You can extend this class and provide implementation for this method in case you want to retrieve data using callable statement.
connection
- Connection to the databasekey
- represents key acting as a filter to retrieve data from db
SQLException
- in case there is some error in loading
the datapublic Object loadDatum(Object key) throws CacheLoadException
Loads the Object corresponding to the particular key supplied. Executes the configured SQL query, loads the data into configured map implementation and returns the loaded map
Reads data from database into configured java bean and stores the bean in the map implementation configured. This map is returned by the method as a value to the cache.
loadDatum
in interface MRUCacheDataLoader
key
- that identifies the returned object in the cache
CacheLoadException
- in case there is some error in loading
the dataprotected Map getMapInstance()
Returns an instance of configured map implementation. This method just returns a new and blank instance. In case comparator is defined for the map, the appropriate constructor of the map implementation is used to create the new instance.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |