i3.dragos.core.services.transactions
Class TransactionManagerFactory

java.lang.Object
  extended by i3.dragos.core.AbstractService
      extended by i3.dragos.core.services.transactions.TransactionManagerFactory
All Implemented Interfaces:
Service

public class TransactionManagerFactory
extends AbstractService

The TransactionManagerFactory instantiates TransactionManagers. See TransactionManager for a detailed discussion of this topic.

Author:
Boris Boehlen <boehlen@cs.rwth-aachen.de>, Thorsten Hermes <thermes@i3.informatik.rwth-aachen.de>

Nested Class Summary
 
Nested classes/interfaces inherited from interface i3.dragos.core.Service
Service.Result, Service.State
 
Constructor Summary
TransactionManagerFactory()
          Constructor.
 
Method Summary
 TransactionManager create(DataSourceURL ds)
          Returns a TransactionManager for the data source.
 TransactionManager create(DataSourceURL[] ds, java.lang.String id)
          Returns a TransactionManager for the data source.
 TransactionManager create(DataSourceURL ds, java.lang.String id)
          Returns a TransactionManager for the data source.
 java.lang.String getDefaultImplementation()
          Returns the identifier of the default implementation (may be null if not set).
 TransactionManager getExistingTransactionManager(DataSourceURL url)
          Returns the existing transaction manager for a specific DataSourceURL.
static TransactionManagerFactory getInstance()
          Returns the TransactionManagerFactory instance registered by the service manager.
 java.lang.String getName()
          Returns the name of the service.
 java.util.Set<java.lang.String> getSupportedTransactionManagers()
          Returns the transaction manager identifiers supported by the factory.
 Service.Result initialize()
          Initializes the services.
 void registerTransactionManagerImplementation(java.lang.String id, java.lang.String impl)
          Registers a TransactionManager implementation, so that instances can be created.
 void setDefaultImplementation(java.lang.String defaultImplementation)
          Sets the default implementation by its identifier (may be null to return to hard-coded behaviour).
 Service.Result uninitialize()
          Uninitializes the services and releases all resources used by the service.
 
Methods inherited from class i3.dragos.core.AbstractService
getState, resume, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionManagerFactory

public TransactionManagerFactory()
Constructor.

Method Detail

getInstance

public static TransactionManagerFactory getInstance()
Returns the TransactionManagerFactory instance registered by the service manager.

Returns:
the TransactionManagerFactory instance registered by the service manager.

getName

public final java.lang.String getName()
Returns the name of the service.

Returns:
the name of the service.

initialize

public Service.Result initialize()
Initializes the services.

Specified by:
initialize in interface Service
Overrides:
initialize in class AbstractService
Returns:
OK if the initialization was successful, FAILED if it was not and INVALID if the configuration was incorrect.

uninitialize

public Service.Result uninitialize()
Uninitializes the services and releases all resources used by the service.

Specified by:
uninitialize in interface Service
Overrides:
uninitialize in class AbstractService
Returns:
OK if the uninitialization was successful, FAILED if it was not and INVALID if the configuration was incorrect.

getSupportedTransactionManagers

public java.util.Set<java.lang.String> getSupportedTransactionManagers()
Returns the transaction manager identifiers supported by the factory.

Returns:
A set of identifiers of type String.

registerTransactionManagerImplementation

public void registerTransactionManagerImplementation(java.lang.String id,
                                                     java.lang.String impl)
                                              throws TransactionManagerFactoryException
Registers a TransactionManager implementation, so that instances can be created. It performs some checks on the specified class to make sure it is a valid implementation, but some problems may only be detected later during actual instantiation of the TransactionManager for a specific DataSourceURL[] argument.

Parameters:
id - The identifier string.
impl - The actual class name.
Throws:
TransactionManagerFactoryException - if the specified class does not exist, is abstract, does not implement the TransactionManager interface or does not implement the necessary public constructor for instantiation.
See Also:
TransactionManager

create

public TransactionManager create(DataSourceURL ds)
                          throws TransactionManagerFactoryException
Returns a TransactionManager for the data source. If no cached TransactionManager exists for that data source, the default implementation is used to create one. If no default is set, the first implementation in the key set of the implementation map is used.

Parameters:
ds - The DataSourceURL of the data source.
Returns:
a TransactionManager for the data source.
Throws:
TransactionManagerFactoryException - if the transaction manager could not be created.

create

public TransactionManager create(DataSourceURL ds,
                                 java.lang.String id)
                          throws TransactionManagerFactoryException
Returns a TransactionManager for the data source. If no cached TransactionManager exists for that data source, the default implementation is used to create one. If no default is set, the first implementation in the key set of the implementation map is used.

Parameters:
ds - The DataSourceURL of the data source.
id - The ID of the implementation to use (may be null).
Returns:
a TransactionManager for the data source.
Throws:
TransactionManagerFactoryException - if the transaction manager could not be created.

create

public TransactionManager create(DataSourceURL[] ds,
                                 java.lang.String id)
                          throws TransactionManagerFactoryException
Returns a TransactionManager for the data source. If no cached TransactionManager exists for that data source, the default implementation is used to create one. If no default is set, the first implementation in the key set of the implementation map is used.

Parameters:
ds - The DataSourceURL of the data source.
id - The ID of the implementation to use (may be null).
Returns:
a TransactionManager for the data source.
Throws:
TransactionManagerFactoryException - if the transaction manager could not be created.

getExistingTransactionManager

public TransactionManager getExistingTransactionManager(DataSourceURL url)
Returns the existing transaction manager for a specific DataSourceURL.

Parameters:
url - logical DataSourceURL to get the TransactionManager for.
Returns:
transaction manager for a specific DataSourceURL, or null if note created yet.

getDefaultImplementation

public java.lang.String getDefaultImplementation()
Returns the identifier of the default implementation (may be null if not set).

Returns:
the identifier of the default implementation (may be null if not set).

setDefaultImplementation

public void setDefaultImplementation(java.lang.String defaultImplementation)
Sets the default implementation by its identifier (may be null to return to hard-coded behaviour).

Parameters:
defaultImplementation - the identifier of the default implementation (may be null to return to hard-coded behaviour).


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.