public class DataSourceResourceLoader extends ResourceLoader
Modifier and Type | Field and Description |
---|---|
private javax.naming.InitialContext |
ctx |
private javax.sql.DataSource |
dataSource |
private java.lang.String |
dataSourceName |
private java.lang.String |
keyColumn |
private java.lang.String |
tableName |
private java.lang.String |
templateColumn |
private java.lang.String |
timestampColumn |
className, isCachingOn, modificationCheckInterval, rsvc
Constructor and Description |
---|
DataSourceResourceLoader() |
Modifier and Type | Method and Description |
---|---|
private void |
closeDbConnection(java.sql.Connection conn)
Closes connection to the datasource
|
long |
getLastModified(Resource resource)
Get the last modified time of the InputStream source
that was used to create the template.
|
java.io.InputStream |
getResourceStream(java.lang.String name)
Get an InputStream so that the Runtime can build a
template with it.
|
void |
init(org.apache.commons.collections.ExtendedProperties configuration)
Initialize the template loader with a
a resources class.
|
boolean |
isSourceModified(Resource resource)
Given a template, check to see if the source of InputStream
has been modified.
|
private java.sql.Connection |
openDbConnection()
gets connection to the datasource specified through the configuration
parameters.
|
private java.sql.ResultSet |
readData(java.sql.Connection conn,
java.lang.String columnNames,
java.lang.String templateName)
Reads the data from the datasource.
|
private long |
readLastModified(Resource resource,
java.lang.String i_operation)
Fetches the last modification time of the resource
|
commonInit, getClassName, getModificationCheckInterval, isCachingOn, setCachingOn, setModificationCheckInterval
private java.lang.String dataSourceName
private java.lang.String tableName
private java.lang.String keyColumn
private java.lang.String templateColumn
private java.lang.String timestampColumn
private javax.naming.InitialContext ctx
private javax.sql.DataSource dataSource
public void init(org.apache.commons.collections.ExtendedProperties configuration)
ResourceLoader
init
in class ResourceLoader
public boolean isSourceModified(Resource resource)
ResourceLoader
isSourceModified
in class ResourceLoader
public long getLastModified(Resource resource)
ResourceLoader
getLastModified
in class ResourceLoader
public java.io.InputStream getResourceStream(java.lang.String name) throws ResourceNotFoundException
getResourceStream
in class ResourceLoader
name
- name of templateResourceNotFoundException
private long readLastModified(Resource resource, java.lang.String i_operation)
resource
- Resource object we are finding timestamp ofi_operation
- string for logging, indicating caller's intentionprivate java.sql.Connection openDbConnection() throws java.lang.Exception
java.lang.Exception
private void closeDbConnection(java.sql.Connection conn)
private java.sql.ResultSet readData(java.sql.Connection conn, java.lang.String columnNames, java.lang.String templateName) throws java.sql.SQLException
conn
- connection to datasourcecolumnNames
- columns to fetch from datasourcetemplateName
- name of template to fetchjava.sql.SQLException
Copyright ? 2002 Apache Software Foundation. All Rights Reserved.