| org.apache.commons.transaction.file.ResourceManager
All known Subclasses: org.apache.commons.transaction.file.FileResourceManager,
ResourceManager | public interface ResourceManager extends Status(Code) | | Interface for resource managers.
A resource manager is an entity
that manages the processing and administration of resources.
What is specified here are methods
- for tasks related to starting and stopping of the resource manager
- for transaction management, like
starting, rolling back and committing of transactions
- to set and get transaction timeouts
- to set the isolation level of a transaction
- for the general administration of resources
- for reading and writing of resources
version: $Id: ResourceManager.java 513490 2007-03-01 20:46:28Z ozeigermann $ |
Method Summary | |
public void | commitTransaction(Object txId) Commis the transaction specified by the given transaction identifier. | public void | createResource(Object txId, Object resourceId) Creates a resource. | public void | createResource(Object txId, Object resourceId, boolean assureOnly) Creates a resource. | public void | deleteResource(Object txId, Object resourceId) Deletes a resource. | public void | deleteResource(Object txId, Object resourceId, boolean assureOnly) Deletes a resource. | public int | getDefaultIsolationLevel() Gets the default isolation level as an integer. | public long | getDefaultTransactionTimeout() Gets the default transaction timeout in milliseconds. | public int | getIsolationLevel(Object txId) Gets the isolation level for the specified transaction. | public int[] | getSupportedIsolationLevels() Gets an array of all isolation levels supported by this resource manager. | public int | getTransactionState(Object txId) Gets the state of the transaction specified by the given transaction identifier.
The state will be expressed by an int code as defined
in the
javax.transaction.Status interface. | public long | getTransactionTimeout(Object txId) Gets the transaction timeout of the specified transaction in milliseconds. | public boolean | isIsolationLevelSupported(int level) Tests if the specified isolation level is supported by this resource manager. | public boolean | lockResource(Object resourceId, Object txId, boolean shared, boolean wait, long timeoutMSecs, boolean reentrant) Explicitly locks a resource. | public boolean | lockResource(Object resourceId, Object txId, boolean shared) Explicitly locks a resource in reentrant style. | public boolean | lockResource(Object resourceId, Object txId) Explicitly locks a resource exclusively, i.e. | public void | markTransactionForRollback(Object txId) Marks the transaction specified by the given transaction identifier for rollback. | public int | prepareTransaction(Object txId) Prepares the transaction specified by the given transaction identifier for commit.
The preparation may either succeed (
ResourceManager.PREPARE_SUCCESS ),
succeed as there is nothing to commit (
ResourceManager.PREPARE_SUCCESS_READONLY )
or fail (
ResourceManager.PREPARE_FAILURE ). | public InputStream | readResource(Object txId, Object resourceId) Opens a streamable resource for reading. | public InputStream | readResource(Object resourceId) Opens a streamable resource for a single reading request not inside the scope of a transaction. | public boolean | recover() Tries to bring this resource manager back to a consistent state. | public boolean | resourceExists(Object txId, Object resourceId) Checks if a resource exists. | public boolean | resourceExists(Object resourceId) Checks if a resource exists wihtout being in a transaction. | public void | rollbackTransaction(Object txId) Rolls back the transaction specified by the given transaction identifier. | public void | setIsolationLevel(Object txId, int level) Sets the isolation level for the specified transaction.
Caution: Implementations are likely to forbid changing the isolation level after any operations
have been executed inside the specified transaction. | public void | setTransactionTimeout(Object txId, long mSecs) Sets the transaction timeout of the specified transaction in milliseconds. | public void | start() Starts this resource manager. | public void | startTransaction(Object txId) Creates and starts a transaction using the specified transaction identifier. | public boolean | stop(int mode, long timeoutMSecs) Tries to stop this resource manager within the given timeout. | public boolean | stop(int mode) Tries to stop this resource manager within a default timeout. | public OutputStream | writeResource(Object txId, Object resourceId) Opens a resource for writing. |
ISOLATION_LEVEL_READ_COMMITTED | final public static int ISOLATION_LEVEL_READ_COMMITTED(Code) | | Isolation level read committed: data written by other transactions can be read after they commit
|
ISOLATION_LEVEL_READ_UNCOMMITTED | final public static int ISOLATION_LEVEL_READ_UNCOMMITTED(Code) | | Isolation level read uncommitted: data written by other transactions can be read even before they commit
|
ISOLATION_LEVEL_REPEATABLE_READ | final public static int ISOLATION_LEVEL_REPEATABLE_READ(Code) | | Isolation level repeatable read: data written by other transactions can be read after they commit if this transaction has not read this data before
|
ISOLATION_LEVEL_SERIALIZABLE | final public static int ISOLATION_LEVEL_SERIALIZABLE(Code) | | Isolation level serializable: result of other transactions will not influence the result of this transaction in any way
|
PREPARE_FAILURE | final public static int PREPARE_FAILURE(Code) | | Prepare result: transaction can not commit
|
PREPARE_SUCCESS | final public static int PREPARE_SUCCESS(Code) | | Prepare result: resource manager guarantees a successful commit
|
PREPARE_SUCCESS_READONLY | final public static int PREPARE_SUCCESS_READONLY(Code) | | Prepare result: resource manager guarantees a successful commit as there is nothing to commit
|
SHUTDOWN_MODE_KILL | final public static int SHUTDOWN_MODE_KILL(Code) | | Shutdown mode: Try to stop active transaction NOW, do no rollbacks
|
SHUTDOWN_MODE_NORMAL | final public static int SHUTDOWN_MODE_NORMAL(Code) | | Shutdown mode: Wait for all transactions to complete
|
SHUTDOWN_MODE_ROLLBACK | final public static int SHUTDOWN_MODE_ROLLBACK(Code) | | Shutdown mode: Try to roll back all active transactions
|
commitTransaction | public void commitTransaction(Object txId) throws ResourceManagerException(Code) | | Commis the transaction specified by the given transaction identifier.
After commit the resource manager is allowed to forget about
the associated transaction.
Parameters: txId - identifier for the transaction to be committed throws: ResourceManagerException - if an error occured |
createResource | public void createResource(Object txId, Object resourceId) throws ResourceManagerException(Code) | | Creates a resource.
Parameters: txId - identifier for the transaction in which the resource is to be created Parameters: resourceId - identifier for the resource to be created throws: ResourceManagerException - if the resource already exist or any other error occured |
createResource | public void createResource(Object txId, Object resourceId, boolean assureOnly) throws ResourceManagerException(Code) | | Creates a resource.
Parameters: txId - identifier for the transaction in which the resource is to be created Parameters: resourceId - identifier for the resource to be created Parameters: assureOnly - if set to true this method will not throw an exception when the resource already exists throws: ResourceManagerException - if the resource already exists and assureOnly was not set to true or any other error occured |
deleteResource | public void deleteResource(Object txId, Object resourceId) throws ResourceManagerException(Code) | | Deletes a resource.
Parameters: txId - identifier for the transaction in which the resource is to be deleted Parameters: resourceId - identifier for the resource to be deleted throws: ResourceManagerException - if the resource does not exist or any other error occured |
deleteResource | public void deleteResource(Object txId, Object resourceId, boolean assureOnly) throws ResourceManagerException(Code) | | Deletes a resource.
Parameters: txId - identifier for the transaction in which the resource is to be deleted Parameters: resourceId - identifier for the resource to be deleted Parameters: assureOnly - if set to true this method will not throw an exception when the resource does not exist throws: ResourceManagerException - if the resource does not exist and assureOnly was not set to true or any other error occured |
getDefaultTransactionTimeout | public long getDefaultTransactionTimeout() throws ResourceManagerException(Code) | | Gets the default transaction timeout in milliseconds.
After this time expires and the concerned transaction has not finished
- either rolled back or committed - the resource manager is allowed and
also encouraged - but not required - to abort the transaction and to roll it back.
default transaction timeout in milliseconds throws: ResourceManagerException - if an error occured |
getTransactionState | public int getTransactionState(Object txId) throws ResourceManagerException(Code) | | Gets the state of the transaction specified by the given transaction identifier.
The state will be expressed by an int code as defined
in the
javax.transaction.Status interface.
Parameters: txId - identifier for the transaction for which the state is returned state of the transaction as defined in javax.transaction.Status throws: ResourceManagerException - if an error occured |
lockResource | public boolean lockResource(Object resourceId, Object txId, boolean shared, boolean wait, long timeoutMSecs, boolean reentrant) throws ResourceManagerException(Code) | | Explicitly locks a resource. Although locking must be done implicitly by methods
creating, reading or modifying resources, there may be cases when you want to do this
explicitly.
Note: By intention the order of parameters (txId does not come first) is different than in other methods of this interface.
This is done to make clear locking affects all transactions, not only the locking one.
This should be clear anyhow, but seems to be worth noting.
Parameters: resourceId - identifier for the resource to be locked Parameters: txId - identifier for the transaction that tries to acquire a lock Parameters: shared - true if this lock may be shared by other shared locks Parameters: wait - true if the method shall block when lock can not be acquired now Parameters: timeoutMSecs - timeout in milliseconds Parameters: reentrant - true if the lock should be acquired even when the requesting transaction and no other holds an incompatible lock true when the lock has been acquired throws: ResourceManagerException - if an error occured |
lockResource | public boolean lockResource(Object resourceId, Object txId) throws ResourceManagerException(Code) | | Explicitly locks a resource exclusively, i.e. for writing, in reentrant style. This method blocks until the lock
actually can be acquired or the transaction times out.
Parameters: resourceId - identifier for the resource to be locked Parameters: txId - identifier for the transaction that tries to acquire a lock throws: ResourceManagerException - if an error occured See Also: ResourceManager.lockResource(Object,Object,boolean) See Also: ResourceManager.lockResource(Object,Object,boolean,boolean,long,boolean) |
markTransactionForRollback | public void markTransactionForRollback(Object txId) throws ResourceManagerException(Code) | | Marks the transaction specified by the given transaction identifier for rollback.
This means, even though the transaction is not actually finished, no other operation
than rollback is permitted.
Parameters: txId - identifier for the transaction to be marked for rollback throws: ResourceManagerException - if an error occured |
readResource | public InputStream readResource(Object txId, Object resourceId) throws ResourceManagerException(Code) | | Opens a streamable resource for reading.
Important: By contract, the application is responsible for closing the stream after its work is finished.
Parameters: txId - identifier for the transaction in which the streamable resource is to be openend Parameters: resourceId - identifier for the streamable resource to be opened stream to read from throws: ResourceManagerException - if the resource does not exist or any other error occured |
readResource | public InputStream readResource(Object resourceId) throws ResourceManagerException(Code) | | Opens a streamable resource for a single reading request not inside the scope of a transaction.
Important: By contract, the application is responsible for closing the stream after its work is finished.
Parameters: resourceId - identifier for the streamable resource to be opened stream to read from throws: ResourceManagerException - if the resource does not exist or any other error occured |
recover | public boolean recover() throws ResourceManagerSystemException(Code) | | Tries to bring this resource manager back to a consistent state.
Might be called after system failure. An administrator might be forced
to fix system errors outside this resource manager to actually make
recovery possible. E.g. there may be a need for more disk space or
a network connection must be reestablished.
true upon successful recovery of the resource manager throws: ResourceManagerSystemException - if anything fatal hapened during recovery |
resourceExists | public boolean resourceExists(Object txId, Object resourceId) throws ResourceManagerException(Code) | | Checks if a resource exists.
Parameters: txId - identifier for the transaction in which the resource is to be checked for Parameters: resourceId - identifier for the resource to check for true if the resource exists throws: ResourceManagerException - if an error occured |
resourceExists | public boolean resourceExists(Object resourceId) throws ResourceManagerException(Code) | | Checks if a resource exists wihtout being in a transaction. This means only take
into account resources already globally commited.
Parameters: resourceId - identifier for the resource to check for true if the resource exists throws: ResourceManagerException - if an error occured |
rollbackTransaction | public void rollbackTransaction(Object txId) throws ResourceManagerException(Code) | | Rolls back the transaction specified by the given transaction identifier.
After roll back the resource manager is allowed to forget about
the associated transaction.
Parameters: txId - identifier for the transaction to be rolled back throws: ResourceManagerException - if an error occured |
startTransaction | public void startTransaction(Object txId) throws ResourceManagerException(Code) | | Creates and starts a transaction using the specified transaction identifier.
The identifier needs to be unique to this resource manager.
As there is no transaction object returned all access to the transaction
needs to be addressed to this resource manager.
Parameters: txId - identifier for the transaction to be started throws: ResourceManagerException - if an error occured |
writeResource | public OutputStream writeResource(Object txId, Object resourceId) throws ResourceManagerException(Code) | | Opens a resource for writing.
Important: By contract, the application is responsible for closing the stream after its work is finished.
Parameters: txId - identifier for the transaction in which the streamable resource is to be openend Parameters: resourceId - identifier for the streamable resource to be opened stream to write to throws: ResourceManagerException - if the resource does not exist or any other error occured |
|
|