|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.services.sqldataloader.total.SqlBeanDataLoader
Class provides a generic lookup class to users with a mechanism to cache data retreived from a table. The object containing the data, query retreiving the data and the key for the cache 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 then stored in cache.
Copyright 2003 Sapient
Field Summary | |
protected SqlBeanDataLoaderConfiguration |
config
Reference to configuration document |
private org.apache.commons.logging.Log |
log
The handle to Apache-commons logger |
Constructor Summary | |
SqlBeanDataLoader()
|
Method Summary | |
void |
configure(ComponentConfiguration configuration)
Configure the component. |
Map |
getMapInstance()
Returns an instance of configured map implementation. |
Map |
loadAllData()
Loads the cache with data elements. |
protected ResultSet |
retrieveResult(Connection connection)
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 SqlBeanDataLoaderConfiguration config
Constructor Detail |
public SqlBeanDataLoader()
Method Detail |
public void configure(ComponentConfiguration configuration)
configure
in interface Configurable
configuration
- A GenericTotalCacheDataLoaderConfigurationprotected ResultSet retrieveResult(Connection connection) 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 database
CacheLoadException
- in case there is some error in loading
the data
SQLException
public Map loadAllData() throws CacheLoadException
Loads the cache with data elements. Executes the configured SQL query and loads the data into configured bean.
Reads the configuration to retrieve a map of db columns and bean attributes. Reads the value for each column from database and populates it into the mapping bean attributes.
loadAllData
in interface TotalCacheDataLoader
CacheLoadException
- in case there is some error in loading
the datapublic 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.
Please note that the new map instance is not synchronized in
this method. As required the synchronization takes place in the
WritableCache
getMapInstance
in interface ConfigurableMapTypeCacheDataLoader
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |