com.jenkov.mrpersister.impl
Class PersistenceConfiguration

java.lang.Object
  extended by com.jenkov.mrpersister.impl.PersistenceConfiguration
All Implemented Interfaces:
IPersistenceConfiguration

public class PersistenceConfiguration
extends java.lang.Object
implements IPersistenceConfiguration

Created by IntelliJ IDEA. User: Administrator Date: 16-02-2004 Time: 15:41:02 To change this template use File | Settings | File Templates.


Field Summary
protected  java.lang.Object configurationKey
           
protected  ICustomObjectMapper customObjectMapper
           
protected  Database database
           
protected  javax.sql.DataSource dataSource
           
protected  ISqlCache deleteSqlCache
           
protected  ISqlCache insertSqlCache
           
protected  IObjectMapper mapper
           
protected  IObjectMappingCache mappingCache
           
protected  PersistenceManager persistenceManager
           
protected  ISqlCache readByPrimaryKeySqlCache
           
protected  IObjectReader reader
           
protected  IScopeFactory scopeFactory
           
protected  ISqlGenerator sqlGenerator
           
protected  ISqlCache updateOptimisticSqlCache
           
protected  ISqlCache updateSqlCache
           
protected  IObjectWriter writer
           
 
Constructor Summary
PersistenceConfiguration(Database database, PersistenceManager persistenceManager)
           
PersistenceConfiguration(PersistenceManager persistenceManager)
           
 
Method Summary
 java.lang.Object getConfigurationKey()
          Returns the key by which this persistence configuration is stored internally in the MrPersister class.
 ICustomObjectMapper getCustomObjectMapper()
          Returns the custom object mapper of this persistence configuration.
 Database getDatabase()
          Returns the Database instance representing the database this instance is specialized for.
 javax.sql.DataSource getDataSource()
          Gets the data source associated with this persistence configuration.
 ISqlCache getDeleteSqlCache()
          Returns the SQL cache used to store delete statements in this persistence configuration.
 ISqlCache getInsertSqlCache()
          Returns the SQL cache used to store insert SQL statements in this persistence configuration.
 IObjectCache getObjectCache()
           
 IObjectMapper getObjectMapper()
          Returns the object mapper used in this persistence configuration.
 IObjectMappingCache getObjectMappingCache()
          Returns the object mapping cache used in this persistence configuration.
 IObjectReader getObjectReader()
          Returns the object reader used in this persistence configuration.
 IObjectWriter getObjectWriter()
          Returns the object writer used in this persistence configuration.
 PersistenceManager getPersistenceManager()
           
 ISqlCache getReadByPrimaryKeySqlCache()
          Returns the SQL cache used to store read-by-primary-key SQL statements in this persistence configuration.
 IScopeFactory getScopeFactory()
          Returns the scope factory matching the data source set on this persistence configuration.
 ISqlGenerator getSqlGenerator()
          Returns the SQL generator used with this persistence configuration.
 ISqlCache getUpdateOptimisticSqlCache()
          Returns the SQL cache used to store updateOptimistic SQL statements in this persistence configuration.
 ISqlCache getUpdateSqlCache()
          Returns the SQL cache used to store updateBatch SQL statements in this persistence configuration.
 void setConfigurationKey(java.lang.Object configurationKey)
          Sets the key by which this persistence configuration is stored internally in the MrPersister class.
 void setCustomObjectMapper(ICustomObjectMapper customObjectMapper)
          Sets the custom object mapper of this persistence configuration.
 void setDatabase(Database database)
          Sets the database this configuration is specialized for.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the data source associated with this persistence configuration.
 void setDeleteSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store delete SQL statements in this persistence configuration.
 void setInsertSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store insert SQL statements in this persistence configuration.
 void setObjectCache(IObjectCache cache)
           
 void setObjectMapper(IObjectMapper mapper)
          Sets the object mapper to be used with this persistence configuration.
 void setObjectMappingCache(IObjectMappingCache cache)
          Sets the object mapping cache to be used in this persistence configuration.
 void setObjectReader(IObjectReader reader)
          Sets the object reader to be used with this persistence configuration.
 void setObjectWriter(IObjectWriter writer)
          Sets the object writer to use with this persistence configuration.
 void setReadByPrimaryKeySqlCache(ISqlCache readByPrimaryKeySqlCache)
          Sets the SQL cache to be used to store read-by-primary-key SQL statements in this persistence configuration.
 void setScopeFactory(IScopeFactory scopeFactory)
           
 void setSqlGenerator(ISqlGenerator generator)
          Sets the SQL generator to be used with this persistence configuration.
 void setUpdateOptimisticSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store updateOptimistic SQL statements in this persistence configuration.
 void setUpdateSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store updateBatch SQL statements in this persistence configuration.
 void update()
          Updates the MrPersister class with any changes made to this IPersistenceConfiguration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistenceManager

protected PersistenceManager persistenceManager

configurationKey

protected java.lang.Object configurationKey

reader

protected IObjectReader reader

writer

protected IObjectWriter writer

mapper

protected IObjectMapper mapper

mappingCache

protected IObjectMappingCache mappingCache

customObjectMapper

protected ICustomObjectMapper customObjectMapper

sqlGenerator

protected ISqlGenerator sqlGenerator

readByPrimaryKeySqlCache

protected ISqlCache readByPrimaryKeySqlCache

insertSqlCache

protected ISqlCache insertSqlCache

updateSqlCache

protected ISqlCache updateSqlCache

updateOptimisticSqlCache

protected ISqlCache updateOptimisticSqlCache

deleteSqlCache

protected ISqlCache deleteSqlCache

database

protected Database database

dataSource

protected javax.sql.DataSource dataSource

scopeFactory

protected IScopeFactory scopeFactory
Constructor Detail

PersistenceConfiguration

public PersistenceConfiguration(PersistenceManager persistenceManager)

PersistenceConfiguration

public PersistenceConfiguration(Database database,
                                PersistenceManager persistenceManager)
Method Detail

getDatabase

public Database getDatabase()
Description copied from interface: IPersistenceConfiguration
Returns the Database instance representing the database this instance is specialized for.

Specified by:
getDatabase in interface IPersistenceConfiguration
Returns:
The Database instance represeting the database this instance is specialized for.

setDatabase

public void setDatabase(Database database)
Description copied from interface: IPersistenceConfiguration
Sets the database this configuration is specialized for. Note that simply setting the database instance isn't enough to target the entire configuration to another database. If you change the database instance you will have to change the other components manually, or you will have a semantically incoherent persistence configuration. In other words: Do not change the database configuration unless you know what you are doing.

Specified by:
setDatabase in interface IPersistenceConfiguration

getDataSource

public javax.sql.DataSource getDataSource()
Description copied from interface: IPersistenceConfiguration
Gets the data source associated with this persistence configuration.

Specified by:
getDataSource in interface IPersistenceConfiguration
Returns:
The data source associated with this persistence configuration.

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Description copied from interface: IPersistenceConfiguration
Sets the data source associated with this persistence configuration.

Specified by:
setDataSource in interface IPersistenceConfiguration

getScopeFactory

public IScopeFactory getScopeFactory()
Description copied from interface: IPersistenceConfiguration
Returns the scope factory matching the data source set on this persistence configuration. A scope factory is automatically created when a DataSource is set on an IPersistenceConfiguration.

Specified by:
getScopeFactory in interface IPersistenceConfiguration
Returns:
The scope factory matching the data source set on this persistence configuration.

setScopeFactory

public void setScopeFactory(IScopeFactory scopeFactory)

getConfigurationKey

public java.lang.Object getConfigurationKey()
Description copied from interface: IPersistenceConfiguration
Returns the key by which this persistence configuration is stored internally in the MrPersister class.

Specified by:
getConfigurationKey in interface IPersistenceConfiguration
Returns:
The key by which this persistence configuration is stored internally in the MrPersister class.

setConfigurationKey

public void setConfigurationKey(java.lang.Object configurationKey)
Description copied from interface: IPersistenceConfiguration
Sets the key by which this persistence configuration is stored internally in the MrPersister class. Note: Changing the key in the IPersistenceConfiguration instance will not remap the instance stored in the MrPersister class. You will have to remove the previously stored IPersistenceConfiguration yourself.

Calling the updateBatch method of a IPersistenceConfiguration instance will however store that instance by the new key. But the instance will remain mapped to the old key as well in the MrPersister class.

Specified by:
setConfigurationKey in interface IPersistenceConfiguration
Parameters:
configurationKey - key by which this persistence configuration is stored internally in the MrPersister class, until you specifically remove that instance from the MrPersister class.

getPersistenceManager

public PersistenceManager getPersistenceManager()

update

public void update()
Description copied from interface: IPersistenceConfiguration
Updates the MrPersister class with any changes made to this IPersistenceConfiguration. This method must be called whenever changes have been made to any of the objects stored in this persistence configuration. This must be done to assure that changes to a persistence configuration by one thread, are also visible to other threads using it. This does not include objects inserted or removed from the various caches, as these are already prepared to handle concurrency. Only changes to the other components, or if components in this persistence configuraion are replaced by others.

Specified by:
update in interface IPersistenceConfiguration

getObjectMapper

public IObjectMapper getObjectMapper()
Description copied from interface: IPersistenceConfiguration
Returns the object mapper used in this persistence configuration.

Specified by:
getObjectMapper in interface IPersistenceConfiguration
Returns:
The IObjectMapper instance set in this persistence configuration.

setObjectMapper

public void setObjectMapper(IObjectMapper mapper)
Description copied from interface: IPersistenceConfiguration
Sets the object mapper to be used with this persistence configuration.

Specified by:
setObjectMapper in interface IPersistenceConfiguration
Parameters:
mapper - The IObjectMapper instance to use with this persistence configuration.

getCustomObjectMapper

public ICustomObjectMapper getCustomObjectMapper()
Description copied from interface: IPersistenceConfiguration
Returns the custom object mapper of this persistence configuration. Currently unused. May be deprecated in a future release. Set the custom mappers directly on the ObjectMappingKey instances instead.

Specified by:
getCustomObjectMapper in interface IPersistenceConfiguration
Returns:
the custom object mapper of this persistence configuration.

setCustomObjectMapper

public void setCustomObjectMapper(ICustomObjectMapper customObjectMapper)
Description copied from interface: IPersistenceConfiguration
Sets the custom object mapper of this persistence configuration. Currently unused. May be deprecated in a future release. Set the custom mappers directly on the ObjectMappingKey instances instead.

Specified by:
setCustomObjectMapper in interface IPersistenceConfiguration
Parameters:
customObjectMapper - The custom object mapper to set on this persistence configuration.

getObjectMappingCache

public IObjectMappingCache getObjectMappingCache()
Description copied from interface: IPersistenceConfiguration
Returns the object mapping cache used in this persistence configuration.

Specified by:
getObjectMappingCache in interface IPersistenceConfiguration
Returns:
The IObjectMappingCache instance set in this persistence configuration.

setObjectMappingCache

public void setObjectMappingCache(IObjectMappingCache cache)
Description copied from interface: IPersistenceConfiguration
Sets the object mapping cache to be used in this persistence configuration.

Specified by:
setObjectMappingCache in interface IPersistenceConfiguration
Parameters:
cache - The IObjectMappingCache instance to use in this persistence configuration.

getObjectCache

public IObjectCache getObjectCache()

setObjectCache

public void setObjectCache(IObjectCache cache)

getObjectReader

public IObjectReader getObjectReader()
Description copied from interface: IPersistenceConfiguration
Returns the object reader used in this persistence configuration.

Specified by:
getObjectReader in interface IPersistenceConfiguration
Returns:
The IObjectReader instance set in this persistence configuration.

setObjectReader

public void setObjectReader(IObjectReader reader)
Description copied from interface: IPersistenceConfiguration
Sets the object reader to be used with this persistence configuration.

Specified by:
setObjectReader in interface IPersistenceConfiguration
Parameters:
reader - The IObjectReader instance to use with this persistence configuration

getObjectWriter

public IObjectWriter getObjectWriter()
Description copied from interface: IPersistenceConfiguration
Returns the object writer used in this persistence configuration.

Specified by:
getObjectWriter in interface IPersistenceConfiguration
Returns:
The IObjectWriter instance set in this persistence configuration.

setObjectWriter

public void setObjectWriter(IObjectWriter writer)
Description copied from interface: IPersistenceConfiguration
Sets the object writer to use with this persistence configuration.

Specified by:
setObjectWriter in interface IPersistenceConfiguration
Parameters:
writer - The IObjectWriter instance to use with this persistence configuration.

getSqlGenerator

public ISqlGenerator getSqlGenerator()
Description copied from interface: IPersistenceConfiguration
Returns the SQL generator used with this persistence configuration.

Specified by:
getSqlGenerator in interface IPersistenceConfiguration
Returns:
The ISqlGenerator instance set in this persistence configuration.

setSqlGenerator

public void setSqlGenerator(ISqlGenerator generator)
Description copied from interface: IPersistenceConfiguration
Sets the SQL generator to be used with this persistence configuration.

Specified by:
setSqlGenerator in interface IPersistenceConfiguration
Parameters:
generator - The ISqlGenerator instance to be used with this persistence configuration.

getInsertSqlCache

public ISqlCache getInsertSqlCache()
Description copied from interface: IPersistenceConfiguration
Returns the SQL cache used to store insert SQL statements in this persistence configuration.

Specified by:
getInsertSqlCache in interface IPersistenceConfiguration
Returns:
The ISqlCache instance used to store insert SQL statements in this persistence configuration.

setInsertSqlCache

public void setInsertSqlCache(ISqlCache cache)
Description copied from interface: IPersistenceConfiguration
Sets the SQL cache to be used to store insert SQL statements in this persistence configuration.

Specified by:
setInsertSqlCache in interface IPersistenceConfiguration
Parameters:
cache - The ISqlCache instance to be used to store insert SQL statements in this persistence configuration.

getUpdateSqlCache

public ISqlCache getUpdateSqlCache()
Description copied from interface: IPersistenceConfiguration
Returns the SQL cache used to store updateBatch SQL statements in this persistence configuration.

Specified by:
getUpdateSqlCache in interface IPersistenceConfiguration
Returns:
The ISqlCache instance used to store updateBatch SQL statements in this persistence configuration.

getUpdateOptimisticSqlCache

public ISqlCache getUpdateOptimisticSqlCache()
Description copied from interface: IPersistenceConfiguration
Returns the SQL cache used to store updateOptimistic SQL statements in this persistence configuration.

Specified by:
getUpdateOptimisticSqlCache in interface IPersistenceConfiguration
Returns:
The ISqlCache instance used to store updateOptimistic SQL statements in this persistence configuration.

setUpdateSqlCache

public void setUpdateSqlCache(ISqlCache cache)
Description copied from interface: IPersistenceConfiguration
Sets the SQL cache to be used to store updateBatch SQL statements in this persistence configuration.

Specified by:
setUpdateSqlCache in interface IPersistenceConfiguration
Parameters:
cache - The ISqlCache instance to be used to store updateBatch SQL statements in this persistence configuration.

setUpdateOptimisticSqlCache

public void setUpdateOptimisticSqlCache(ISqlCache cache)
Description copied from interface: IPersistenceConfiguration
Sets the SQL cache to be used to store updateOptimistic SQL statements in this persistence configuration.

Specified by:
setUpdateOptimisticSqlCache in interface IPersistenceConfiguration
Parameters:
cache - The ISqlCache instance to be used to store updateOptimistic SQL statements in this persistence configuration.

getDeleteSqlCache

public ISqlCache getDeleteSqlCache()
Description copied from interface: IPersistenceConfiguration
Returns the SQL cache used to store delete statements in this persistence configuration.

Specified by:
getDeleteSqlCache in interface IPersistenceConfiguration
Returns:
The ISqlCache instance used to store delete SQL statements in this persistence configuration.

setDeleteSqlCache

public void setDeleteSqlCache(ISqlCache cache)
Description copied from interface: IPersistenceConfiguration
Sets the SQL cache to be used to store delete SQL statements in this persistence configuration.

Specified by:
setDeleteSqlCache in interface IPersistenceConfiguration
Parameters:
cache - The ISqlCache instance to be used to store delete SQL statements in this persistence configuration.

getReadByPrimaryKeySqlCache

public ISqlCache getReadByPrimaryKeySqlCache()
Description copied from interface: IPersistenceConfiguration
Returns the SQL cache used to store read-by-primary-key SQL statements in this persistence configuration.

Specified by:
getReadByPrimaryKeySqlCache in interface IPersistenceConfiguration
Returns:
The ISqlCache instance used to store read-by-primary-key SQL statements in this persistence configuration.

setReadByPrimaryKeySqlCache

public void setReadByPrimaryKeySqlCache(ISqlCache readByPrimaryKeySqlCache)
Description copied from interface: IPersistenceConfiguration
Sets the SQL cache to be used to store read-by-primary-key SQL statements in this persistence configuration.

Specified by:
setReadByPrimaryKeySqlCache in interface IPersistenceConfiguration
Parameters:
readByPrimaryKeySqlCache - The ISqlCache instance to be used to store read-by-primary-key SQL statements in this persistence configuration.