org.norther.tammi.root.hibernate
Class DefaultHibernatePersisterFactory

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.config.DefaultConfigurable
          extended by org.norther.tammi.core.config.DefaultConfigurableFactory
              extended by org.norther.tammi.root.db.AbstractPersisterFactory
                  extended by org.norther.tammi.root.hibernate.DefaultHibernatePersisterFactory
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, ObjectFactory, Refreshable, Startable, CacheClient, KeyCacheClient, Configurable, ConfigurableFactory, PersisterFactory, PersisterListener, HibernatePersisterFactory

public class DefaultHibernatePersisterFactory
extends AbstractPersisterFactory
implements HibernatePersisterFactory, PersisterListener

A default implementation of HibernatePersisterFactory.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.root.db.AbstractPersisterFactory
DESCRIPTION_SUFFIX, DOCTYPE, PRINCIPAL_CLASS_NAME, XML_HEADER
 
Fields inherited from class org.norther.tammi.core.config.DefaultConfigurable
MODIFIED, SYNCHRONIZED, UNMODIFIED
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.root.hibernate.HibernatePersisterFactory
CONNECTION_ALIAS_PROPERTY, HIBERNATE_PROPERTY_PREFIX, INITIALIZER_CLASS_NAME_PROPERTY, PERSISTER_CLASS_NAME
 
Fields inherited from interface org.norther.tammi.root.db.PersisterFactory
ANY_ALIAS, EXT_BASE_CLASS_NAME, EXT_BEGIN_CLASS, EXT_BEGIN_FIELD, EXT_BLANK_ACCEPTED, EXT_CLONEABLE, EXT_COLLECTION, EXT_COMPARATOR_CLASS_NAME, EXT_CORRELATIVE, EXT_DESCENDING, EXT_DESCRIPTION, EXT_DETAIL, EXT_DISABLED, EXT_EMPTY_ACCEPTED, EXT_END_CLASS, EXT_END_FIELD, EXT_ENUM_NAME, EXT_ENUM_VALUE, EXT_ENUMERATED, EXT_EXPORTER_CLASS_NAME, EXT_GROUP, EXT_IMPORTER_CLASS_NAME, EXT_INDEX, EXT_INTERACTIVE, EXT_LOCAL, EXT_LOCALIZED, EXT_MANDATORY, EXT_MAX_VALUE, EXT_MIN_VALUE, EXT_NAME_PATTERN, EXT_OPTIONS, EXT_ORDER_BY, EXT_ORDERED, EXT_PATTERN, EXT_PRIMARY, EXT_READABLE, EXT_REFERENCE, EXT_SERIALIZED, EXT_SHADOW, EXT_SORTED, EXT_TRACEABLE, EXT_TRANSIENT, EXT_TRIMMED, EXT_TYPE, EXT_VALIDATOR_CLASS_NAME, EXT_VALUE, EXT_VISIBLE, EXT_WRITABLE, JDBC_TYPE_PROPERTY
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultHibernatePersisterFactory()
          Constructs a new factory.
 
Method Summary
 void addClassDescriptor(String expr, String descriptor, Map types)
          Adds a new class descriptor for the specified connections in the repository.
 void clearClassDescriptors()
          Clears all class decriptors.
 void clearConnectionDescriptors()
          Clears all connection decriptors.
 boolean containsClassDescriptor(String expr, String className)
          Checks whether the specified class descriptor is mapped.
 boolean containsConnectionDescriptor(String key)
          Checks whether the specified connection descriptor is mapped.
 org.hibernate.cfg.Configuration getConnectionConfiguration()
          Gets the configuration of the default connection.
 org.hibernate.cfg.Configuration getConnectionConfiguration(String key)
          Gets the configuration of the specified connection.
 String getConnectionURL(String key)
          Gets the URL of the specified connection.
 String getConnectionUsername(String key)
          Gets the username of the specified connection.
protected  String getDefaultConnectionDTD()
          Gets the default connection DTD.
 String getDefaultConnectionKey()
          Gets the key of the default connection.
protected  String getDefaultRepositoryDTD()
          Gets the default repository DTD.
 Object getInstance(String className, ObjectName loader, Object[] params, String[] signature)
          Gets an instance of a named class using a specified class loader.
protected  List getParsedAttributeInfo(String className, Object repository, OrderedMap externals, Map types)
          Gets the parsed attributes of a named class in the repository.
 boolean isLoaderSupported(String className)
          Checks if specified class loaders are supported for a named class.
 boolean isStarted()
          Checks whether the startable has been started.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void removeConnectionDescriptor(String key, String user, String pswd)
          Removes the specified connection descriptor from the repository.
protected  String resolveJdbcAlias(String alias)
          Resolves a JDBC alias containing a parametrized local path that must be replaced with a real one.
 void setConnectionDescriptor(String descriptor, Object[] params)
          Sets a connection descriptor in the repository.
 void setConnectionPassword(String key, String pswd)
          Sets the password of the specified connection.
 void setConnectionURL(String key, String url)
          Sets the URL of the specified connection.
 void setConnectionUsername(String key, String user)
          Gets the username of the specified connection.
 void setDefaultConnectionKey(String key)
          Sets the key of the default connection.
 void setDefaultConnectionKey(String key, String user, String pswd)
          Sets the key, username and password of the default connection.
 void setPropertyFilePath(String path, String encoding)
          Sets the property file path with encoding.
 void start()
          Starts the MBean.
 void stop()
          Stops the MBean.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.root.db.AbstractPersisterFactory
addClassDescriptor, addClassDescriptor, cacheKeySet, clearCached, clearCaches, expireCached, expireFraction, getAttributeInfo, getAttributeInfo, getAttributeType, getCache, getCache, getComparator, getConnectionDTD, getEnumeration, getJdbcTypeName, getLastModified, getRefreshed, getRepositoryDTD, getVariableRegistryMBean, getVariableRegistryName, isCachingDisabled, isCombinedFactoryCache, isRefreshReferencesEnabled, isTraceReferencesDisabled, jdbcTypeSet, modified, query, query, refresh, registerDynamicAttributes, removeAttributeType, removeCache, removeCache, removeConnectionDescriptor, resolveDescriptor, resolveInlineDTD, setAttributeType, setCachingDisabled, setCombinedFactoryCache, setConnectionDescriptor, setConnectionDTD, setRefreshReferencesEnabled, setRepositoryDTD, setTraceReferencesDisabled, setVariableRegistryName
 
Methods inherited from class org.norther.tammi.core.config.DefaultConfigurableFactory
getInstance, getInstance, getInstance
 
Methods inherited from class org.norther.tammi.core.config.DefaultConfigurable
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getConfiguration, getModifiedState, getProperties, getProperty, getPropertyFilePath, indexOfProperty, loadConfiguration, loadConfiguration, loadConfiguration, modified, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setModifiedState, setProperties, setProperty, setPropertyFilePath, storeProperties
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.root.db.PersisterFactory
addClassDescriptor, addClassDescriptor, getAttributeType, getConnectionDTD, getLastModified, getRepositoryDTD, getVariableRegistryName, isCombinedFactoryCache, isRefreshReferencesEnabled, isTraceReferencesDisabled, jdbcTypeSet, query, query, removeAttributeType, removeConnectionDescriptor, setAttributeType, setCombinedFactoryCache, setConnectionDescriptor, setConnectionDTD, setRefreshReferencesEnabled, setRepositoryDTD, setTraceReferencesDisabled, setVariableRegistryName
 
Methods inherited from interface org.norther.tammi.core.base.ObjectFactory
getInstance, getInstance, getInstance
 
Methods inherited from interface org.norther.tammi.core.config.Configurable
addProperty, addProperty, clearProperties, containsProperty, getConfigKey, getProperties, getProperty, getPropertyFilePath, indexOfProperty, propertyMap, propertyMap, removeProperty, removeProperty, setConfigKey, setProperties, setProperty, setPropertyFilePath, storeProperties
 
Methods inherited from interface org.norther.tammi.core.cache.KeyCacheClient
cacheKeySet, clearCaches, getCache, removeCache
 
Methods inherited from interface org.norther.tammi.core.cache.CacheClient
clearCached, expireCached, expireFraction, getCache, isCachingDisabled, removeCache, setCachingDisabled
 
Methods inherited from interface org.norther.tammi.core.base.Refreshable
getRefreshed, refresh
 
Methods inherited from interface org.norther.tammi.root.db.PersisterListener
modified
 

Constructor Detail

DefaultHibernatePersisterFactory

public DefaultHibernatePersisterFactory()
Constructs a new factory.

Method Detail

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class AbstractPersisterFactory

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class AbstractPersisterFactory
Throws:
Exception - if the adaptee refused to be unmanaged.

isStarted

public boolean isStarted()
Description copied from interface: Startable
Checks whether the startable has been started.

Specified by:
isStarted in interface Startable
Returns:
true if started, otherwise false.

start

public void start()
           throws Exception
Description copied from interface: Startable
Starts the MBean.

Specified by:
start in interface Startable
Throws:
Exception - if start fails.

stop

public void stop()
Description copied from interface: Startable
Stops the MBean.

Specified by:
stop in interface Startable

getDefaultConnectionKey

public String getDefaultConnectionKey()
Description copied from interface: PersisterFactory
Gets the key of the default connection.

Specified by:
getDefaultConnectionKey in interface PersisterFactory
Returns:
the key of the default connection.

setDefaultConnectionKey

public void setDefaultConnectionKey(String key)
Description copied from interface: PersisterFactory
Sets the key of the default connection.

Specified by:
setDefaultConnectionKey in interface PersisterFactory
Parameters:
key - the key of the default connection.

setDefaultConnectionKey

public void setDefaultConnectionKey(String key,
                                    String user,
                                    String pswd)
Description copied from interface: PersisterFactory
Sets the key, username and password of the default connection.

Specified by:
setDefaultConnectionKey in interface PersisterFactory
Parameters:
key - the key of the default connection.
user - the username of the default connection.
pswd - the password of the default connection.

getConnectionUsername

public String getConnectionUsername(String key)
Description copied from interface: PersisterFactory
Gets the username of the specified connection.

Specified by:
getConnectionUsername in interface PersisterFactory
Parameters:
key - the key of the connection.
Returns:
the username of the connection.

setConnectionUsername

public void setConnectionUsername(String key,
                                  String user)
Description copied from interface: PersisterFactory
Gets the username of the specified connection.

Specified by:
setConnectionUsername in interface PersisterFactory
Parameters:
key - the key of the connection.
user - the username of the connection.

setConnectionPassword

public void setConnectionPassword(String key,
                                  String pswd)
Description copied from interface: PersisterFactory
Sets the password of the specified connection.

Specified by:
setConnectionPassword in interface PersisterFactory
Parameters:
key - the key of the connection.
pswd - the password of the connection.

getConnectionURL

public String getConnectionURL(String key)
Description copied from interface: PersisterFactory
Gets the URL of the specified connection.

Specified by:
getConnectionURL in interface PersisterFactory
Parameters:
key - the key of the connection.
Returns:
the URL of the connection.

setConnectionURL

public void setConnectionURL(String key,
                             String url)
Description copied from interface: PersisterFactory
Sets the URL of the specified connection.

Specified by:
setConnectionURL in interface PersisterFactory
Parameters:
key - the key of the connection.
url - the URL of the connection.

setConnectionDescriptor

public void setConnectionDescriptor(String descriptor,
                                    Object[] params)
                             throws LogException
Description copied from interface: PersisterFactory
Sets a connection descriptor in the repository. The descriptor may be a file or URL containing one or more connection descriptors, or it may itself contain connection descriptors in XML format. Parameters are message format parameters for the database connection.

Specified by:
setConnectionDescriptor in interface PersisterFactory
Parameters:
descriptor - the connection descriptor.
params - message format parameters.
Throws:
LogException - on errors.

containsConnectionDescriptor

public boolean containsConnectionDescriptor(String key)
Description copied from interface: PersisterFactory
Checks whether the specified connection descriptor is mapped.

Specified by:
containsConnectionDescriptor in interface PersisterFactory
Parameters:
key - the key i.e. the alias name of the connection.
Returns:
true for a mapped connection descriptor, otherwise false.

removeConnectionDescriptor

public void removeConnectionDescriptor(String key,
                                       String user,
                                       String pswd)
Description copied from interface: PersisterFactory
Removes the specified connection descriptor from the repository.

Specified by:
removeConnectionDescriptor in interface PersisterFactory
Parameters:
key - the key i.e. the alias name of the connection.
user - the username of the connection.
pswd - the password of the connection.

clearConnectionDescriptors

public void clearConnectionDescriptors()
Description copied from interface: PersisterFactory
Clears all connection decriptors.

Specified by:
clearConnectionDescriptors in interface PersisterFactory

addClassDescriptor

public void addClassDescriptor(String expr,
                               String descriptor,
                               Map types)
                        throws LogException
Description copied from interface: PersisterFactory
Adds a new class descriptor for the specified connections in the repository. The descriptor may be a file or URL containing one or more class descriptors, or it may itself contain class descriptors in XML format.

Declared but missing classes are defined and loaded as Variables containing the declared fields as their attributes. The types of the attributes corresponding to the declared JDBC types can be given in a separate type map. Default types are applied to undefined types.

Specified by:
addClassDescriptor in interface PersisterFactory
Parameters:
expr - the expression matching connection aliases.
descriptor - the class descriptor.
types - JDBC type mappings.
Throws:
LogException - on errors.

containsClassDescriptor

public boolean containsClassDescriptor(String expr,
                                       String className)
Description copied from interface: PersisterFactory
Checks whether the specified class descriptor is mapped.

Specified by:
containsClassDescriptor in interface PersisterFactory
Parameters:
expr - the expression matching connection aliases.
className - the name of the class.
Returns:
true for a mapped class descriptor, otherwise false.

clearClassDescriptors

public void clearClassDescriptors()
Description copied from interface: PersisterFactory
Clears all class decriptors.

Specified by:
clearClassDescriptors in interface PersisterFactory

setPropertyFilePath

public void setPropertyFilePath(String path,
                                String encoding)
Description copied from interface: Configurable
Sets the property file path with encoding. The path may be an absolute file path, a file path relative to the specified config key folder or a URL. The properties will be loaded before the next get/set property operation.

Specified by:
setPropertyFilePath in interface Configurable
Overrides:
setPropertyFilePath in class DefaultConfigurable
Parameters:
path - a property file path.
encoding - the encoding to use.

getConnectionConfiguration

public org.hibernate.cfg.Configuration getConnectionConfiguration()
Description copied from interface: HibernatePersisterFactory
Gets the configuration of the default connection.

Specified by:
getConnectionConfiguration in interface HibernatePersisterFactory
Returns:
the configuration or null.

getConnectionConfiguration

public org.hibernate.cfg.Configuration getConnectionConfiguration(String key)
Description copied from interface: HibernatePersisterFactory
Gets the configuration of the specified connection.

Specified by:
getConnectionConfiguration in interface HibernatePersisterFactory
Parameters:
key - the key i.e. the alias name of the connection.
Returns:
the configuration or null.

getInstance

public Object getInstance(String className,
                          ObjectName loader,
                          Object[] params,
                          String[] signature)
                   throws ConstructionException
Description copied from interface: ObjectFactory
Gets an instance of a named class using a specified class loader. Parameters for its constructor are given as an array of objects, primitive types must be wrapped with a corresponding class.

Class loaders are supported only if the isLoaderSupported method returns true. Otherwise the loader parameter is ignored.

Specified by:
getInstance in interface ObjectFactory
Overrides:
getInstance in class DefaultConfigurableFactory
Parameters:
className - the name of the class.
loader - the class loader.
params - an array containing the parameters of the constructor.
signature - an array containing the signature of the constructor.
Returns:
the instance.
Throws:
ConstructionException - if construction fails.

isLoaderSupported

public boolean isLoaderSupported(String className)
Description copied from interface: ObjectFactory
Checks if specified class loaders are supported for a named class.

Specified by:
isLoaderSupported in interface ObjectFactory
Overrides:
isLoaderSupported in class DefaultConfigurableFactory
Parameters:
className - the name of the class.
Returns:
true if class loaders are supported, false otherwise.

resolveJdbcAlias

protected String resolveJdbcAlias(String alias)
Description copied from class: AbstractPersisterFactory
Resolves a JDBC alias containing a parametrized local path that must be replaced with a real one.

Overrides:
resolveJdbcAlias in class AbstractPersisterFactory
Parameters:
alias - the original alias.
Returns:
the resolved alias.

getDefaultConnectionDTD

protected String getDefaultConnectionDTD()
Description copied from class: AbstractPersisterFactory
Gets the default connection DTD.

Specified by:
getDefaultConnectionDTD in class AbstractPersisterFactory
Returns:
the default connection DTD.

getDefaultRepositoryDTD

protected String getDefaultRepositoryDTD()
Description copied from class: AbstractPersisterFactory
Gets the default repository DTD.

Specified by:
getDefaultRepositoryDTD in class AbstractPersisterFactory
Returns:
the default repository DTD.

getParsedAttributeInfo

protected List getParsedAttributeInfo(String className,
                                      Object repository,
                                      OrderedMap externals,
                                      Map types)
Description copied from class: AbstractPersisterFactory
Gets the parsed attributes of a named class in the repository.

Specified by:
getParsedAttributeInfo in class AbstractPersisterFactory
Parameters:
className - the name of the class.
repository - the class repository.
externals - external properties.
types - optional type mappings.
Returns:
a list of attribute infos.


Copyright © 2004 The Norther Organization. All rights reserved.