com.atomikos.icatch.config
Class UserTransactionServiceImp

java.lang.Object
  extended by com.atomikos.icatch.config.UserTransactionServiceImp
All Implemented Interfaces:
UserTransactionService, Serializable

public class UserTransactionServiceImp
extends Object
implements Serializable, UserTransactionService

This is the main class for creating a UserTransactionService instance. This class is the client's main entry point into the transaction engine. The creation of a user transaction happens via a UserTransactionServiceFactory which is looked up by this object behind the scenes. Instances can be serialized to disk and re-read at a later time. Note: deserialization will only work in the SAME configuration as the one that did the streaming out. In particular, if no identical Atomikos transaction service is present in the target VM then the process of deserialization will be erroneous.

See Also:
Serialized Form

Field Summary
static String DEFAULT_PROPERTIES_FILE_NAME
          The default file name for the transaction service's init parameters.
static String FILE_PATH_PROPERTY_NAME
          The name of the system property whose value corresponds to the path towards the properties file for initialization of the transaction service.
static String HIDE_INIT_FILE_PATH_PROPERTY_NAME
          The name of the system property to disable printing 'Using init file...' messages to System.err - if this system property to an arbitrary value then no such message will be shown on System.err during startup.
static String NO_FILE_PROPERTY_NAME
          Constant denoting the system property name that suggest NOT to use any configuration file for the transaction service's properties.
 
Constructor Summary
UserTransactionServiceImp()
          Default constructor.
UserTransactionServiceImp(Properties properties)
          Constructs a new instance and initializes it with the given properties.
 
Method Summary
 TSInitInfo createTSInitInfo()
          Create a TSInitInfo for this transaction service.
 CompositeTransactionManager getCompositeTransactionManager()
          Get the composite transaction manager for the config.
 ExportingTransactionManager getExportingTransactionManager()
          Get the ExportingTransactionManager instance
 ImportingTransactionManager getImportingTransactionManager()
          Get the ImportingTransactionManager instance.
 Enumeration getLogAdministrators()
          Get the log administrators.
 Enumeration getResources()
          Get the resources registered.
 TransactionManager getTransactionManager()
          Get the JTA transaction manager handle for the config.
 TSMetaData getTSMetaData()
          Get the meta data for the transaction service.
 UserTransaction getUserTransaction()
          Get the JTA user transaction, for client-demarcated transactions.
 void init()
          Convenience init method for DI containers like Spring.
 void init(Properties properties)
           
 void init(TSInitInfo info)
          Initializes the intra-VM transaction manager.
 void registerLogAdministrator(LogAdministrator admin)
          Register a LogAdministrator instance for administration.
 void registerResource(RecoverableResource res)
          Register a new resource for recovery.
 void registerTSListener(TSListener listener)
          Registers a listener with the transaction service.
 void removeLogAdministrator(LogAdministrator admin)
          Removes the given log administrator.
 void removeResource(RecoverableResource res)
          Removes the given resource.
 void removeTSListener(TSListener listener)
          Removes a listener from the transaction service.
 void setInitialLogAdministrators(List administrators)
          Dependency injection of all administrators to be added during init.
 void setInitialRecoverableResources(List resources)
          Dependency injection of all resources to be added during init.
 void setInitialTSListeners(List listeners)
          Dependency injection of all listeners to be added during init.
 void shutdown(boolean force)
          Shuts down the TM.
 void shutdownForce()
          Convenience shutdown method for DI containers like Spring.
 void shutdownWait()
          Convenience shutdown method for DI containers like Spring.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_FILE_PROPERTY_NAME

public static final String NO_FILE_PROPERTY_NAME
Constant denoting the system property name that suggest NOT to use any configuration file for the transaction service's properties. If this a system property with this name is set to an arbitrary value then the transaction service will attempt initialization based on system properties only. In that case, all the parameters that would normally be set through the properties file have to be supplied as system properties with the same name and corresponding value.

See Also:
Constant Field Values

FILE_PATH_PROPERTY_NAME

public static final String FILE_PATH_PROPERTY_NAME
The name of the system property whose value corresponds to the path towards the properties file for initialization of the transaction service. If this system property is set then the corresponding file path will be used to load the initialization parameters for the transaction service. Otherwise, the transaction service will attempt to load the default file from the classpath.

See Also:
Constant Field Values

HIDE_INIT_FILE_PATH_PROPERTY_NAME

public static final String HIDE_INIT_FILE_PATH_PROPERTY_NAME
The name of the system property to disable printing 'Using init file...' messages to System.err - if this system property to an arbitrary value then no such message will be shown on System.err during startup.

See Also:
Constant Field Values

DEFAULT_PROPERTIES_FILE_NAME

public static final String DEFAULT_PROPERTIES_FILE_NAME
The default file name for the transaction service's init parameters.

See Also:
Constant Field Values
Constructor Detail

UserTransactionServiceImp

public UserTransactionServiceImp()
Default constructor.


UserTransactionServiceImp

public UserTransactionServiceImp(Properties properties)
Constructs a new instance and initializes it with the given properties. If this constructor is called, then file-based initialization is overridden. In particular, the given properties will take precedence over the file-based properties (if found).

Parameters:
properties - The properties.
Method Detail

createTSInitInfo

public TSInitInfo createTSInitInfo()
Description copied from interface: UserTransactionService
Create a TSInitInfo for this transaction service.

Specified by:
createTSInitInfo in interface UserTransactionService
Returns:
TSInitInfo The init info instance.
See Also:
UserTransactionService

shutdown

public void shutdown(boolean force)
              throws IllegalStateException
Description copied from interface: UserTransactionService
Shuts down the TM. It is highly recommended that this method be called before the VM exits, in order to ensure proper log closing. After this method completes, all resources will have been removed from the configuration, as well as all logadministrators. To re-initialize, everything should be registered again.

Specified by:
shutdown in interface UserTransactionService
Parameters:
force - If true, then shutdown will succeed even if some transactions are still active. If false, then the calling thread will block until any active transactions are terminated. A heuristic transaction is also considered to be active.
Throws:
IllegalStateException
See Also:
UserTransactionService

init

public void init(TSInitInfo info)
          throws SysException
Description copied from interface: UserTransactionService
Initializes the intra-VM transaction manager.

Specified by:
init in interface UserTransactionService
Parameters:
info - The TSInitInfo with details for initialization.
Throws:
SysException
See Also:
UserTransactionService

getCompositeTransactionManager

public CompositeTransactionManager getCompositeTransactionManager()
Description copied from interface: UserTransactionService
Get the composite transaction manager for the config.

Specified by:
getCompositeTransactionManager in interface UserTransactionService
Returns:
CompositeTransactionManager The composite transaction manager.
See Also:
UserTransactionService

getTransactionManager

public TransactionManager getTransactionManager()
Description copied from interface: UserTransactionService
Get the JTA transaction manager handle for the config.

Specified by:
getTransactionManager in interface UserTransactionService
Returns:
TransactionManager The JTA transaction manager.
See Also:
UserTransactionService

getUserTransaction

public UserTransaction getUserTransaction()
Description copied from interface: UserTransactionService
Get the JTA user transaction, for client-demarcated transactions.

Specified by:
getUserTransaction in interface UserTransactionService
Returns:
UserTransaction The JTA user transaction. IMPORTANT: the returned instance can be bound in JNDI. In addition, remote clients can use this instance only if the configuration parameters allow remote client transaction demarcation!
See Also:
UserTransactionService

getImportingTransactionManager

public ImportingTransactionManager getImportingTransactionManager()
Description copied from interface: UserTransactionService
Get the ImportingTransactionManager instance.

Specified by:
getImportingTransactionManager in interface UserTransactionService
Returns:
ImportingTransactionManager The instance.
See Also:
UserTransactionService

getExportingTransactionManager

public ExportingTransactionManager getExportingTransactionManager()
Description copied from interface: UserTransactionService
Get the ExportingTransactionManager instance

Specified by:
getExportingTransactionManager in interface UserTransactionService
Returns:
ExportingTransactionManager The instance.
See Also:
UserTransactionService

getTSMetaData

public TSMetaData getTSMetaData()
Description copied from interface: UserTransactionService
Get the meta data for the transaction service.

Specified by:
getTSMetaData in interface UserTransactionService
Returns:
TSMetaData The meta data.
See Also:
UserTransactionService

registerResource

public void registerResource(RecoverableResource res)
Description copied from interface: UserTransactionService
Register a new resource for recovery.

Specified by:
registerResource in interface UserTransactionService
Parameters:
res - The resource to be added.
See Also:
com.atomikos.icatch.UserTransactionService#registerResource(com.atomikos.datasource.RecoverableResource)

registerLogAdministrator

public void registerLogAdministrator(LogAdministrator admin)
Description copied from interface: UserTransactionService
Register a LogAdministrator instance for administration. This allows inspection of active transactions and manual intervention. Care should be taken if multiple instances are registered: the responsibility of taking conflicting manual decisions is entirely with the user!

Specified by:
registerLogAdministrator in interface UserTransactionService
Parameters:
admin - The instance.
See Also:
com.atomikos.icatch.UserTransactionService#registerLogAdministrator(com.atomikos.icatch.admin.LogAdministrator)

getResources

public Enumeration getResources()
Description copied from interface: UserTransactionService
Get the resources registered.

Specified by:
getResources in interface UserTransactionService
Returns:
Enumeration The resources, or empty if none.
See Also:
com.atomikos.icatch.UserTransactionService#getResources()

getLogAdministrators

public Enumeration getLogAdministrators()
Description copied from interface: UserTransactionService
Get the log administrators.

Specified by:
getLogAdministrators in interface UserTransactionService
Returns:
Enumeration The registered administrators.
See Also:
com.atomikos.icatch.UserTransactionService#getLogAdministrators()

removeResource

public void removeResource(RecoverableResource res)
Description copied from interface: UserTransactionService
Removes the given resource. This method should be used with extreme care, because removing resources can endanger recovery!

Specified by:
removeResource in interface UserTransactionService

removeLogAdministrator

public void removeLogAdministrator(LogAdministrator admin)
Description copied from interface: UserTransactionService
Removes the given log administrator. Does nothing if the instance is not found.

Specified by:
removeLogAdministrator in interface UserTransactionService

registerTSListener

public void registerTSListener(TSListener listener)
Description copied from interface: UserTransactionService
Registers a listener with the transaction service.

Specified by:
registerTSListener in interface UserTransactionService

removeTSListener

public void removeTSListener(TSListener listener)
Description copied from interface: UserTransactionService
Removes a listener from the transaction service. After this method is called, the listener in question will no longer receive callback notifications from the transaction service. This method does nothing if the listener is not found.

Specified by:
removeTSListener in interface UserTransactionService

shutdownForce

public void shutdownForce()
Convenience shutdown method for DI containers like Spring.


shutdownWait

public void shutdownWait()
Convenience shutdown method for DI containers like Spring.


setInitialRecoverableResources

public void setInitialRecoverableResources(List resources)
Dependency injection of all resources to be added during init.

Parameters:
resources -

setInitialLogAdministrators

public void setInitialLogAdministrators(List administrators)
Dependency injection of all administrators to be added during init.

Parameters:
administrators -

setInitialTSListeners

public void setInitialTSListeners(List listeners)
Dependency injection of all listeners to be added during init.

Parameters:
listeners -

init

public void init()
Convenience init method for DI containers like Spring.


init

public void init(Properties properties)
          throws SysException
Specified by:
init in interface UserTransactionService
Throws:
SysException


Copyright © 2011. All Rights Reserved.