|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.softslate.commerce.daos.core.BaseDAOFactory
public abstract class BaseDAOFactory
Field Summary | |
---|---|
private java.util.Properties |
appComponents
|
private java.util.Properties |
appSettings
|
private java.lang.String |
databaseDriver
The fully-qualified class name of the database driver used for the DataSource . |
private java.lang.String |
databasePassword
The password used for this factory's DataSource database
connection, if the built-in connection pooling is used. |
private java.lang.String |
databaseType
The type of database this factory connects to. |
private java.lang.String |
databaseURL
The URL used for this factory's DataSource database
connection, if the built-in connection pooling is used. |
private java.lang.String |
databaseUserName
The user name used for this factory's DataSource database
connection, if the built-in connection pooling is used. |
private javax.sql.DataSource |
dataSource
The application's DataSource used for persistent storage. |
private java.lang.String |
dataSourceName
The JNDI name for the application's DataSource , if one is
set up in the servlet container's configuration. |
private java.util.Properties |
hibernateSettings
|
private java.lang.String |
jndiContext
The JNDI context for the application's DataSource , if one
is set up in the servlet container's configuration. |
(package private) static org.apache.commons.logging.Log |
log
|
private java.lang.String |
maxActive
The maximum number of active connections for the pool used by this factory's DataSource , if the built-in connection pooling
is used. |
private java.lang.String |
maxIdle
The maximum number of idle connections for the pool used by this factory's DataSource , if the built-in connection pooling
is used. |
private java.lang.String |
maxWait
The maximum time to wait for a connection to become available in milliseconds, before an exception is thrown. |
private java.util.StringTokenizer |
moduleList
The list of modules in use by the application in StringTokenizer form. |
static java.lang.String |
moduleListString
The list of modules in use by the application in String
form. |
private java.lang.String |
paymentPrivateKeyFile
The full path to the file on the server where the private key is stored for key pair encryption. |
private java.lang.String |
paymentPublicKeyFile
The full path to the file on the server where the public key is stored for key pair (RSA) encryption. |
private java.lang.String |
removeAbandoned
If set to true, abandoned connections will be removed and recycled. |
private java.lang.String |
removeAbandonedTimeout
The number of seconds a connection is idle before it is considered abandoned. |
private org.hibernate.SessionFactory |
sessionFactory
|
private Settings |
settings
Used to look up the Java class names for the various DAO's this factory creates. |
private java.util.Map |
sqlMap
A Map of SQL statements used by the application. |
private java.lang.String |
twoWayKeyFile
The full path to the file on the server where the key is stored for two way (DES) encryption. |
Constructor Summary | |
---|---|
BaseDAOFactory()
|
Method Summary | |
---|---|
void |
beginTransaction()
|
void |
closeSession()
|
void |
commitTransaction()
|
java.lang.Object |
createDAO(java.lang.String type)
Creates and initializes a data access object for use by the application. |
java.lang.Object |
createDAOFromClassName(java.lang.String className)
Creates and initializes a data access object for use by the application. |
java.lang.Object |
createSettingsDAO()
Creates and initializes a settings bean data access object for use by the application. |
void |
evictCache()
|
java.util.Properties |
getAppComponents()
Retrieves this factory's component settings. |
java.util.Properties |
getAppSettings()
Retrieves this factory's application settings; the current application settings for the system. |
java.lang.String |
getDatabaseDriver()
|
java.lang.String |
getDatabasePassword()
|
java.lang.String |
getDatabaseType()
|
java.lang.String |
getDatabaseURL()
|
java.lang.String |
getDatabaseUserName()
|
javax.sql.DataSource |
getDataSource()
|
java.lang.String |
getDataSourceName()
|
java.util.Properties |
getHibernateSettings()
Retrieves this factory's Hibernate settings. |
java.lang.String |
getJndiContext()
|
javax.sql.DataSource |
getJndiDataSource()
Looks up a DataSource object in a JNDI context. |
java.lang.String |
getMaxActive()
|
java.lang.String |
getMaxIdle()
|
java.lang.String |
getMaxWait()
|
java.util.StringTokenizer |
getModuleList()
|
java.lang.String |
getModuleListString()
|
java.lang.String |
getPaymentPrivateKeyFile()
|
java.lang.String |
getPaymentPublicKeyFile()
|
javax.sql.DataSource |
getPooledDataSource()
Creates a connection pool using various properties defined in this factory. |
java.util.Properties |
getProperties(java.lang.String databaseType,
java.lang.String module)
Loads SQL statements into a Properties object for a given
database type. |
java.lang.String |
getRemoveAbandoned()
|
java.lang.String |
getRemoveAbandonedTimeout()
|
org.hibernate.Session |
getSession()
|
org.hibernate.SessionFactory |
getSessionFactory()
Retrieves this factory's Hibernate SessionFactory . |
Settings |
getSettings()
Retrieves this factory's Settings instance. |
java.util.Map |
getSqlMap()
|
java.util.Map |
getTransferMap()
Retrieves a Map of properties that will be transfered to
each of the data access objects this factory creates. |
java.lang.String |
getTwoWayKeyFile()
|
void |
initialize()
Initializes this DAOFactory . |
void |
initialize(java.lang.String settingsLocation)
Initializes this DAOFactory using the settings defined in
the file located at the imcoming settingLocation . |
void |
initializeDataSource()
Initializes this factory's dataSource property. |
void |
initializeSettings(java.lang.String settingsLocation)
Loads database settings from a properties file into the properties of this DAOFactory . |
void |
initializeSQLProperties()
Reads in the application's SQL statements into this factory's sqlMap . |
java.util.Properties |
loadProperties(java.lang.String path)
Load properties from a .properties file represented by the argument. |
java.util.Properties |
loadProperties(java.lang.String path,
java.util.Properties defaultProperties)
Load properties from a .properties file represented by the argument, using a given Properties object as the default properties. |
void |
rollbackTransaction()
|
void |
setAppComponents(java.util.Properties appComponents)
|
void |
setAppSettings(java.util.Properties appSettings)
|
void |
setDatabaseDriver(java.lang.String databaseDriver)
|
void |
setDatabasePassword(java.lang.String databasePassword)
|
void |
setDatabaseType(java.lang.String databaseType)
|
void |
setDatabaseURL(java.lang.String databaseURL)
|
void |
setDatabaseUserName(java.lang.String databaseUserName)
|
void |
setDataSource(javax.sql.DataSource dataSource)
|
void |
setDataSourceName(java.lang.String dataSourceName)
|
void |
setHibernateSettings(java.util.Properties hibernateSettings)
|
void |
setJndiContext(java.lang.String jndiContext)
|
void |
setMaxActive(java.lang.String maxActive)
|
void |
setMaxIdle(java.lang.String maxIdle)
|
void |
setMaxWait(java.lang.String maxWait)
|
void |
setModuleList(java.util.StringTokenizer moduleList)
|
void |
setModuleListString(java.lang.String moduleList)
|
void |
setPaymentPrivateKeyFile(java.lang.String paymentPrivateKeyFile)
|
void |
setPaymentPublicKeyFile(java.lang.String paymentPublicKeyFile)
|
void |
setRemoveAbandoned(java.lang.String removeAbandoned)
|
void |
setRemoveAbandonedTimeout(java.lang.String removeAbandonedTimeout)
|
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
|
void |
setSettings(Settings settings)
|
void |
setSqlMap(java.util.Map sqlMap)
|
void |
setTwoWayKeyFile(java.lang.String twoWayKeyFile)
|
org.hibernate.Session |
startSession()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static org.apache.commons.logging.Log log
private java.util.Map sqlMap
Map
of SQL statements used by the application.
private java.util.StringTokenizer moduleList
StringTokenizer
form. Modules may include core, product,
order, and customer.
public static java.lang.String moduleListString
String
form. Modules may include core, product, order, and customer.
private javax.sql.DataSource dataSource
DataSource
used for persistent storage.
private java.lang.String dataSourceName
DataSource
, if one is
set up in the servlet container's configuration. (For example, in
server.xml for Tomcat.)
private java.lang.String jndiContext
DataSource
, if one
is set up in the servlet container's configuration. (For example, in
server.xml for Tomcat.)
private java.lang.String databaseDriver
DataSource
.
private java.lang.String databaseURL
DataSource
database
connection, if the built-in connection pooling is used. This factory will
use its own connection pooling if it fails to connect using the JNDI
dataSourceName
and jndiContext
settings.
private java.lang.String databaseUserName
DataSource
database
connection, if the built-in connection pooling is used. This factory will
use its own connection pooling if it fails to connect using the JNDI
dataSourceName
and jndiContext
settings.
private java.lang.String databasePassword
DataSource
database
connection, if the built-in connection pooling is used. This factory will
use its own connection pooling if it fails to connect using the JNDI
dataSourceName
and jndiContext
settings.
private java.lang.String databaseType
private java.lang.String maxIdle
DataSource
, if the built-in connection pooling
is used. This factory will use its own connection pooling if it fails to
connect using the JNDI dataSourceName
and
jndiContext
settings.
private java.lang.String maxActive
DataSource
, if the built-in connection pooling
is used. This factory will use its own connection pooling if it fails to
connect using the JNDI dataSourceName
and
jndiContext
settings.
private java.lang.String maxWait
DataSource
, if the built-in connection pooling is used.
This factory will use its own connection pooling if it fails to connect
using the JNDI dataSourceName
and jndiContext
settings.
private java.lang.String removeAbandoned
DataSource
, if the built-in connection
pooling is used. This factory will use its own connection pooling if it
fails to connect using the JNDI dataSourceName
and
jndiContext
settings.
private java.lang.String removeAbandonedTimeout
DataSource
, if the
built-in connection pooling is used. This factory will use its own
connection pooling if it fails to connect using the JNDI
dataSourceName
and jndiContext
settings.
private java.lang.String paymentPrivateKeyFile
private java.lang.String paymentPublicKeyFile
private java.lang.String twoWayKeyFile
private Settings settings
private java.util.Properties appSettings
private java.util.Properties appComponents
private java.util.Properties hibernateSettings
private org.hibernate.SessionFactory sessionFactory
Constructor Detail |
---|
public BaseDAOFactory()
Method Detail |
---|
public java.util.Map getSqlMap()
getSqlMap
in interface DAOFactory
public void setSqlMap(java.util.Map sqlMap)
public java.util.StringTokenizer getModuleList()
getModuleList
in interface DAOFactory
public void setModuleList(java.util.StringTokenizer moduleList)
setModuleList
in interface DAOFactory
public java.lang.String getModuleListString()
getModuleListString
in interface DAOFactory
public void setModuleListString(java.lang.String moduleList)
setModuleListString
in interface DAOFactory
public javax.sql.DataSource getDataSource()
getDataSource
in interface DAOFactory
public void setDataSource(javax.sql.DataSource dataSource)
setDataSource
in interface DAOFactory
public java.lang.String getDataSourceName()
getDataSourceName
in interface DAOFactory
public void setDataSourceName(java.lang.String dataSourceName)
setDataSourceName
in interface DAOFactory
public java.lang.String getJndiContext()
getJndiContext
in interface DAOFactory
public void setJndiContext(java.lang.String jndiContext)
setJndiContext
in interface DAOFactory
public java.lang.String getDatabaseDriver()
getDatabaseDriver
in interface DAOFactory
public void setDatabaseDriver(java.lang.String databaseDriver)
setDatabaseDriver
in interface DAOFactory
public java.lang.String getDatabaseURL()
getDatabaseURL
in interface DAOFactory
public void setDatabaseURL(java.lang.String databaseURL)
setDatabaseURL
in interface DAOFactory
public java.lang.String getDatabaseUserName()
getDatabaseUserName
in interface DAOFactory
public void setDatabaseUserName(java.lang.String databaseUserName)
setDatabaseUserName
in interface DAOFactory
public java.lang.String getDatabasePassword()
getDatabasePassword
in interface DAOFactory
public void setDatabasePassword(java.lang.String databasePassword)
setDatabasePassword
in interface DAOFactory
public java.lang.String getDatabaseType()
getDatabaseType
in interface DAOFactory
public void setDatabaseType(java.lang.String databaseType)
setDatabaseType
in interface DAOFactory
public java.lang.String getMaxIdle()
getMaxIdle
in interface DAOFactory
public void setMaxIdle(java.lang.String maxIdle)
setMaxIdle
in interface DAOFactory
public java.lang.String getMaxActive()
getMaxActive
in interface DAOFactory
public void setMaxActive(java.lang.String maxActive)
setMaxActive
in interface DAOFactory
public java.lang.String getMaxWait()
getMaxWait
in interface DAOFactory
public void setMaxWait(java.lang.String maxWait)
setMaxWait
in interface DAOFactory
public java.lang.String getRemoveAbandoned()
getRemoveAbandoned
in interface DAOFactory
public void setRemoveAbandoned(java.lang.String removeAbandoned)
setRemoveAbandoned
in interface DAOFactory
public java.lang.String getRemoveAbandonedTimeout()
getRemoveAbandonedTimeout
in interface DAOFactory
public void setRemoveAbandonedTimeout(java.lang.String removeAbandonedTimeout)
setRemoveAbandonedTimeout
in interface DAOFactory
public java.lang.String getPaymentPrivateKeyFile()
getPaymentPrivateKeyFile
in interface DAOFactory
public void setPaymentPrivateKeyFile(java.lang.String paymentPrivateKeyFile)
setPaymentPrivateKeyFile
in interface DAOFactory
public java.lang.String getPaymentPublicKeyFile()
getPaymentPublicKeyFile
in interface DAOFactory
public void setPaymentPublicKeyFile(java.lang.String paymentPublicKeyFile)
setPaymentPublicKeyFile
in interface DAOFactory
public java.lang.String getTwoWayKeyFile()
getTwoWayKeyFile
in interface DAOFactory
public void setTwoWayKeyFile(java.lang.String twoWayKeyFile)
setTwoWayKeyFile
in interface DAOFactory
public Settings getSettings()
DAOFactory
Settings
instance. The current
Settings
, containing various settings to be used by DAOs
created by this factory. This factory will pass the Settings
to every object it creates.
getSettings
in interface DAOFactory
public void setSettings(Settings settings)
setSettings
in interface DAOFactory
public void initialize() throws java.lang.Exception
DAOFactory
. Called by
BaseRequestProcessor
.
initialize
in interface DAOFactory
java.lang.Exception
public void initialize(java.lang.String settingsLocation) throws java.lang.Exception
DAOFactory
using the settings defined in
the file located at the imcoming settingLocation
.
initialize
in interface DAOFactory
settingsLocation
- The location of a file containing database settings.
java.lang.Exception
public void initializeSQLProperties() throws java.lang.Exception
sqlMap
. Loops through each of the active modules defined
in the moduleList
property and reads in the SQL
properities from the files in "/WEB-INF/classes/resources.
initializeSQLProperties
in interface DAOFactory
java.lang.Exception
public void initializeSettings(java.lang.String settingsLocation)
DAOFactory
.
settingsLocation
- The location of a file containing database settings.public java.util.Properties getProperties(java.lang.String databaseType, java.lang.String module) throws java.lang.Exception
Properties
object for a given
database type. Reads a default sql.properties file for a given module
under "WEB-INF/classes/resources" and then another file with SQL
statements that override the defaults with SQL specific to the given
database type. Finally, loads the sql-custom.properties file in each
module to provide a way to override any of the statements deployed with
the application.
databaseType
- The type of database the SQL statements apply to.module
- The module the SQL statements correspond to. For example,
core, product, order, or customer.
Properties
object representing the SQL
statements.
java.lang.Exception
public java.util.Properties loadProperties(java.lang.String path)
path
- The path to the .properties file being loaded.
Properties
object representing the contents of
the file.public java.util.Properties loadProperties(java.lang.String path, java.util.Properties defaultProperties)
Properties
object as the default properties.
path
- The path to the .properties file being loaded.defaultProperties
- A Properties
object representing the default
properties to be returned.
Properties
object representing the contents of
the file.public void initializeDataSource() throws java.lang.Exception
dataSource
property. This
method first attempts to establish a DataSource
based on a
JNDI data source name and context defined in the JNDI environment, using
the datasourceName
and jndiContext
properties. If this fails, it will create it's own connection pool using
the various other properties defined in this factory, including the
databaseURL
,databaseUserName
, and
databasePassword
properties.
initializeDataSource
in interface DAOFactory
java.lang.Exception
public javax.sql.DataSource getJndiDataSource() throws java.lang.Exception
DataSource
object in a JNDI context. Attempts
to establish a DataSource
based on a JNDI data source name
and context defined in the JNDI environment, using the
datasourceName
and jndiContext
properties.
getJndiDataSource
in interface DAOFactory
DataSource
object for the application.
java.lang.Exception
public javax.sql.DataSource getPooledDataSource() throws java.lang.Exception
DataSource
object tied to it.
DataSource
object for the application.
java.lang.Exception
public java.util.Map getTransferMap()
Map
of properties that will be transfered to
each of the data access objects this factory creates.
Map
of properties that will be transfered to
each of the data access objects this factory createspublic java.lang.Object createSettingsDAO() throws java.lang.Exception
createSettingsDAO
in interface DAOFactory
null
if initialization failed.
java.lang.Exception
public java.lang.Object createDAO(java.lang.String type) throws java.lang.Exception
createDAO
in interface DAOFactory
type
- A String
associated with the class name of the
data access object to be created.
null
if initialization failed.
java.lang.Exception
public java.lang.Object createDAOFromClassName(java.lang.String className) throws java.lang.Exception
databaseType
property to the class name and attempts to
instantiate that object. If that fails, it next appends "Basic" to the
end of the class name. If a class still cannot be found, the class name
from the class name itself is used.
For example, if this factory receives a request to create an instance of
CustomerDAO
, this factory will try to instantiate the
following objects in this order:
com.softslate.commerce.daos.customer.CustomerDAOMSSQL
com.softslate.commerce.daos.customer.CustomerDAOBasic
com.softslate.commerce.daos.customer.CustomerDAO
Immediately after instantiating the requested DAO, this factory passes its own properties to it so that the newly created object can use them to communicate with the rest of the application.
createDAOFromClassName
in interface DAOFactory
className
- A String
representing the class name of the
data access object to be created.
null
if initialization failed.
java.lang.Exception
public java.util.Properties getAppSettings()
DAOFactory
Settings
instance, which
stores settings drawn from the database.
getAppSettings
in interface DAOFactory
public void setAppSettings(java.util.Properties appSettings)
setAppSettings
in interface DAOFactory
public java.util.Properties getAppComponents()
DAOFactory
getAppComponents
in interface DAOFactory
public void setAppComponents(java.util.Properties appComponents)
setAppComponents
in interface DAOFactory
public java.util.Properties getHibernateSettings()
DAOFactory
getHibernateSettings
in interface DAOFactory
public void setHibernateSettings(java.util.Properties hibernateSettings)
setHibernateSettings
in interface DAOFactory
public org.hibernate.SessionFactory getSessionFactory()
DAOFactory
SessionFactory
.
getSessionFactory
in interface DAOFactory
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
setSessionFactory
in interface DAOFactory
public org.hibernate.Session startSession()
startSession
in interface DAOFactory
public org.hibernate.Session getSession()
getSession
in interface DAOFactory
public void closeSession()
closeSession
in interface DAOFactory
public void beginTransaction()
beginTransaction
in interface DAOFactory
public void commitTransaction()
commitTransaction
in interface DAOFactory
public void rollbackTransaction()
rollbackTransaction
in interface DAOFactory
public void evictCache()
evictCache
in interface DAOFactory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |