Java Doc for ResourceManager.java in  » Database-JDBC-Connection-Pool » Apache-commons-transaction-1.2 » org » apache » commons » transaction » file » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » Apache commons transaction 1.2 » org.apache.commons.transaction.file 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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 $


Field Summary
final public static  intISOLATION_LEVEL_READ_COMMITTED
    
final public static  intISOLATION_LEVEL_READ_UNCOMMITTED
    
final public static  intISOLATION_LEVEL_REPEATABLE_READ
    
final public static  intISOLATION_LEVEL_SERIALIZABLE
    
final public static  intPREPARE_FAILURE
    
final public static  intPREPARE_SUCCESS
    
final public static  intPREPARE_SUCCESS_READONLY
    
final public static  intSHUTDOWN_MODE_KILL
    
final public static  intSHUTDOWN_MODE_NORMAL
    
final public static  intSHUTDOWN_MODE_ROLLBACK
    


Method Summary
public  voidcommitTransaction(Object txId)
     Commis the transaction specified by the given transaction identifier.
public  voidcreateResource(Object txId, Object resourceId)
     Creates a resource.
public  voidcreateResource(Object txId, Object resourceId, boolean assureOnly)
     Creates a resource.
public  voiddeleteResource(Object txId, Object resourceId)
     Deletes a resource.
public  voiddeleteResource(Object txId, Object resourceId, boolean assureOnly)
     Deletes a resource.
public  intgetDefaultIsolationLevel()
     Gets the default isolation level as an integer.
public  longgetDefaultTransactionTimeout()
     Gets the default transaction timeout in milliseconds.
public  intgetIsolationLevel(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  intgetTransactionState(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  longgetTransactionTimeout(Object txId)
     Gets the transaction timeout of the specified transaction in milliseconds.
public  booleanisIsolationLevelSupported(int level)
     Tests if the specified isolation level is supported by this resource manager.
public  booleanlockResource(Object resourceId, Object txId, boolean shared, boolean wait, long timeoutMSecs, boolean reentrant)
     Explicitly locks a resource.
public  booleanlockResource(Object resourceId, Object txId, boolean shared)
     Explicitly locks a resource in reentrant style.
public  booleanlockResource(Object resourceId, Object txId)
     Explicitly locks a resource exclusively, i.e.
public  voidmarkTransactionForRollback(Object txId)
     Marks the transaction specified by the given transaction identifier for rollback.
public  intprepareTransaction(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  InputStreamreadResource(Object txId, Object resourceId)
     Opens a streamable resource for reading.
public  InputStreamreadResource(Object resourceId)
     Opens a streamable resource for a single reading request not inside the scope of a transaction.
public  booleanrecover()
     Tries to bring this resource manager back to a consistent state.
public  booleanresourceExists(Object txId, Object resourceId)
     Checks if a resource exists.
public  booleanresourceExists(Object resourceId)
     Checks if a resource exists wihtout being in a transaction.
public  voidrollbackTransaction(Object txId)
     Rolls back the transaction specified by the given transaction identifier.
public  voidsetIsolationLevel(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  voidsetTransactionTimeout(Object txId, long mSecs)
     Sets the transaction timeout of the specified transaction in milliseconds.
public  voidstart()
     Starts this resource manager.
public  voidstartTransaction(Object txId)
     Creates and starts a transaction using the specified transaction identifier.
public  booleanstop(int mode, long timeoutMSecs)
     Tries to stop this resource manager within the given timeout.
public  booleanstop(int mode)
     Tries to stop this resource manager within a default timeout.
public  OutputStreamwriteResource(Object txId, Object resourceId)
     Opens a resource for writing.

Field Detail
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





Method Detail
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



getDefaultIsolationLevel
public int getDefaultIsolationLevel() throws ResourceManagerException(Code)
Gets the default isolation level as an integer. The higher the value the higher the isolation. one of the predefined isolation levels ResourceManager.ISOLATION_LEVEL_READ_UNCOMMITTED, ResourceManager.ISOLATION_LEVEL_READ_COMMITTED, ResourceManager.ISOLATION_LEVEL_REPEATABLE_READ or ResourceManager.ISOLATION_LEVEL_SERIALIZABLE or any other int representing an isolation level
throws:
  ResourceManagerException - if an 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



getIsolationLevel
public int getIsolationLevel(Object txId) throws ResourceManagerException(Code)
Gets the isolation level for the specified transaction.
Parameters:
  txId - identifier for the concerned transaction one of the predefined isolation levels ResourceManager.ISOLATION_LEVEL_READ_UNCOMMITTED, ResourceManager.ISOLATION_LEVEL_READ_COMMITTED, ResourceManager.ISOLATION_LEVEL_REPEATABLE_READ or ResourceManager.ISOLATION_LEVEL_SERIALIZABLE or any other int representing an isolation level
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.getDefaultIsolationLevel



getSupportedIsolationLevels
public int[] getSupportedIsolationLevels() throws ResourceManagerException(Code)
Gets an array of all isolation levels supported by this resource manager. This array must not be null or empty as every resource manager has some sort of isolation level. array of the predefined isolation levels ResourceManager.ISOLATION_LEVEL_READ_UNCOMMITTED, ResourceManager.ISOLATION_LEVEL_READ_COMMITTED, ResourceManager.ISOLATION_LEVEL_REPEATABLE_READ or ResourceManager.ISOLATION_LEVEL_SERIALIZABLE or any other int representing an isolation level
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.getDefaultIsolationLevel



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



getTransactionTimeout
public long getTransactionTimeout(Object txId) throws ResourceManagerException(Code)
Gets the transaction timeout of the specified transaction in milliseconds.
Parameters:
  txId - identifier for the concerned transaction transaction timeout of the specified transaction in milliseconds
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.getDefaultTransactionTimeout



isIsolationLevelSupported
public boolean isIsolationLevelSupported(int level) throws ResourceManagerException(Code)
Tests if the specified isolation level is supported by this resource manager.
Parameters:
  level - isolation level whose support is to be tested true if the isolation level is supported
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.getDefaultIsolationLevel



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, boolean shared) throws ResourceManagerException(Code)
Explicitly locks a resource 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
Parameters:
  shared - true if this lock may be shared by other shared locks
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.lockResource(Object,Object,boolean,boolean,long,boolean)



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



prepareTransaction
public int prepareTransaction(Object txId) throws ResourceManagerException(Code)
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 ). If the preparation fails, commit will fail as well and the transaction should be marked for rollback. However, if it succeeds the resource manager must guarantee that a following commit will succeed as well.

An alternative way to singal a failed status is to throw an exception.
Parameters:
  txId - identifier for the transaction to be prepared result of the preparation effort, either ResourceManager.PREPARE_SUCCESS, ResourceManager.PREPARE_SUCCESS_READONLY or ResourceManager.PREPARE_FAILURE
throws:
  ResourceManagerException - alternative way to signal prepare failed



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



setIsolationLevel
public void setIsolationLevel(Object txId, int level) throws ResourceManagerException(Code)
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.
Parameters:
  txId - identifier for the concerned transaction
Parameters:
  level - one of the predefined isolation levels ResourceManager.ISOLATION_LEVEL_READ_UNCOMMITTED, ResourceManager.ISOLATION_LEVEL_READ_COMMITTED, ResourceManager.ISOLATION_LEVEL_REPEATABLE_READ or ResourceManager.ISOLATION_LEVEL_SERIALIZABLE or any other int representing an isolation level
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.getDefaultIsolationLevel



setTransactionTimeout
public void setTransactionTimeout(Object txId, long mSecs) throws ResourceManagerException(Code)
Sets the transaction timeout of the specified transaction in milliseconds.
Parameters:
  txId - identifier for the concerned transaction
Parameters:
  mSecs - transaction timeout of the specified transaction in milliseconds
throws:
  ResourceManagerException - if an error occured
See Also:   ResourceManager.getDefaultTransactionTimeout



start
public void start() throws ResourceManagerSystemException(Code)
Starts this resource manager. A resource manager must be started before transactions can be started or any operations on transactions can be executed.
throws:
  ResourceManagerSystemException - if start failed due to internal problems



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



stop
public boolean stop(int mode, long timeoutMSecs) throws ResourceManagerSystemException(Code)
Tries to stop this resource manager within the given timeout.
Parameters:
  mode - one of ResourceManager.SHUTDOWN_MODE_NORMAL, ResourceManager.SHUTDOWN_MODE_ROLLBACK or ResourceManager.SHUTDOWN_MODE_KILL
Parameters:
  timeoutMSecs - timeout for shutdown in milliseconds true if resource manager stopped within given timeout
throws:
  ResourceManagerSystemException - if something fatal hapened during shutdown



stop
public boolean stop(int mode) throws ResourceManagerSystemException(Code)
Tries to stop this resource manager within a default timeout.
Parameters:
  mode - one of predefined shutdown modes ResourceManager.SHUTDOWN_MODE_NORMAL, ResourceManager.SHUTDOWN_MODE_ROLLBACK or ResourceManager.SHUTDOWN_MODE_KILLor any other int representing a shutdown mode true if resource manager stopped within given timeout
throws:
  ResourceManagerSystemException - if anything fatal hapened during shutdown



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



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.