org.norther.tammi.root.ojb
Class DefaultOJBPersisterFactory

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.ojb.DefaultOJBPersisterFactory
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, TraceListener, Manageable, MBeanDelegate, ObjectFactory, Refreshable, Startable, CacheClient, KeyCacheClient, Configurable, ConfigurableFactory, PersisterFactory, PersisterListener, OJBPersisterFactory

public class DefaultOJBPersisterFactory
extends AbstractPersisterFactory
implements OJBPersisterFactory, PersisterListener

A default implementation of OJBPersisterFactory.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static String BASE
          The base key for connections.
static String HOST
          The host key for connections.
 
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.ojb.OJBPersisterFactory
EXT_INITIALIZER_CLASS_NAME, 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
DefaultOJBPersisterFactory()
          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.
 Map classDescriptorMap()
          Returns a map of defined class descriptors.
 void clearClassDescriptors()
          Clears all class decriptors.
 void clearConnectionDescriptors()
          Clears all connection decriptors.
 Map connectionDescriptorMap()
          Returns a map of defined connection descriptors.
 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.
 ClassDescriptor getClassDescriptor(String className)
          Gets the class descriptor of the specified class from the repository.
 JdbcConnectionDescriptor getConnectionDescriptor()
          Gets the default connection descriptor from the repository.
 JdbcConnectionDescriptor getConnectionDescriptor(String key)
          Gets the connection descriptor of the specified connection from the repository.
 JdbcConnectionDescriptor getConnectionDescriptor(String key, String user, String pswd)
          Gets the connection descriptor of the specified connection for the given user from the repository.
 String getConnectionPlatform(String key)
          Gets the DB platform 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.
 FieldDescriptor getFieldDescriptor(String className, String attribute)
          Gets the field descriptor of the specified class and attribute from the repository.
 Object getInstance(String className, ObjectName loader, Object[] params, String[] signature)
          Gets an instance of a named class using a specified class loader.
 String getLoggingFilePath()
          Gets the logging file path.
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.
 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 username, String password)
          Sets the key, username and password of the default connection.
 void setLoggingFilePath(String path)
          Sets the logging file path.
 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, resolveJdbcAlias, 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
 

Field Detail

HOST

public static final String HOST
The host key for connections.

See Also:
Constant Field Values

BASE

public static final String BASE
The base key for connections.

See Also:
Constant Field Values
Constructor Detail

DefaultOJBPersisterFactory

public DefaultOJBPersisterFactory()
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 username,
                                    String password)
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.
username - the username of the default connection.
password - 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

getConnectionDescriptor

public JdbcConnectionDescriptor getConnectionDescriptor()
Description copied from interface: OJBPersisterFactory
Gets the default connection descriptor from the repository.

Note that the descriptor is cloned from the original one.

Specified by:
getConnectionDescriptor in interface OJBPersisterFactory
Returns:
the class descriptor or null.

getConnectionDescriptor

public JdbcConnectionDescriptor getConnectionDescriptor(String key)
Description copied from interface: OJBPersisterFactory
Gets the connection descriptor of the specified connection from the repository.

Note that the descriptor is cloned from the original one.

Specified by:
getConnectionDescriptor in interface OJBPersisterFactory
Parameters:
key - the key i.e. the alias name of the connection.
Returns:
the class descriptor or null.

getConnectionDescriptor

public JdbcConnectionDescriptor getConnectionDescriptor(String key,
                                                        String user,
                                                        String pswd)
Description copied from interface: OJBPersisterFactory
Gets the connection descriptor of the specified connection for the given user from the repository.

Note that the descriptor is cloned from the original one.

Specified by:
getConnectionDescriptor in interface OJBPersisterFactory
Parameters:
key - the key i.e. the alias name of the connection.
user - the username of the connection.
pswd - the password of the connection.
Returns:
the class descriptor or null.

connectionDescriptorMap

public Map connectionDescriptorMap()
Description copied from interface: OJBPersisterFactory
Returns a map of defined connection descriptors.

Specified by:
connectionDescriptorMap in interface OJBPersisterFactory
Returns:
a map of connection descriptors with aliases as keys.

getConnectionPlatform

public String getConnectionPlatform(String key)
Description copied from interface: OJBPersisterFactory
Gets the DB platform of the specified connection.

Specified by:
getConnectionPlatform in interface OJBPersisterFactory
Parameters:
key - the key i.e. the alias name of the connection.
Returns:
the DB platform or null if not mapped.

getClassDescriptor

public ClassDescriptor getClassDescriptor(String className)
Description copied from interface: OJBPersisterFactory
Gets the class descriptor of the specified class from the repository.

Specified by:
getClassDescriptor in interface OJBPersisterFactory
Parameters:
className - the name of the class.
Returns:
the class descriptor or null.

classDescriptorMap

public Map classDescriptorMap()
Description copied from interface: OJBPersisterFactory
Returns a map of defined class descriptors.

Specified by:
classDescriptorMap in interface OJBPersisterFactory
Returns:
a map of class descriptors with persistent classes as keys.

getFieldDescriptor

public FieldDescriptor getFieldDescriptor(String className,
                                          String attribute)
Description copied from interface: OJBPersisterFactory
Gets the field descriptor of the specified class and attribute from the repository.

Specified by:
getFieldDescriptor in interface OJBPersisterFactory
Parameters:
className - the name of the class.
attribute - the name of the attribute.
Returns:
the field descriptor or null.

getLoggingFilePath

public String getLoggingFilePath()
Description copied from interface: OJBPersisterFactory
Gets the logging file path.

Specified by:
getLoggingFilePath in interface OJBPersisterFactory
Returns:
the logging file path.

setLoggingFilePath

public void setLoggingFilePath(String path)
Description copied from interface: OJBPersisterFactory
Sets the logging file path. The path may be an absolute file path, a file path relative to the specified config key folder or a URL.

Specified by:
setLoggingFilePath in interface OJBPersisterFactory
Parameters:
path - a logging file path.

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.

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.

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.

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.

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.