Java Doc for XAResource.java in  » EJB-Server-JBoss-4.2.1 » j2ee » javax » transaction » xa » 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 » EJB Server JBoss 4.2.1 » j2ee » javax.transaction.xa 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.transaction.xa.XAResource

XAResource
public interface XAResource (Code)
The XAResource interface is a Java mapping of the industry standard XA interface based on the X/Open CAE Specification (Distributed Transaction Processing: The XA Specification).

The XA interface defines the contract between a Resource Manager and a Transaction Manager in a distributed transaction processing (DTP) environment. An XA resource such as a JDBC driver or a JMS provider implements this interface to support association between a global transaction and a database or message service connection.

The XAResource interface can be supported by any transactional resource that is intended to be used by application programs in an environment where transactions are controlled by an external transaction manager. An example of such a resource is a database management system. An application may access data through multiple database connections. Each database connection is enlisted with the transaction manager as a transactional resource. The transaction manager obtains an XAResource for each connection participating in a global transaction. The transaction manager uses the XAResource.start(Xid,int) start method to associate the global transaction with the resource, and it uses the XAResource.end(Xid,int) end method to disassociate the transaction from the resource. The resource manager is responsible for associating the global transaction to all work performed on its data between the start and end method invocation.

At transaction commit time, the resource managers are informed by the transaction manager to prepare, commit, or rollback a transaction according to the two-phase commit protocol.

Behind the resources that implement this interface the resource manager exists. The resource manager does not have a public interface or direct references, and can manage several resources. To see if two resources are managed by the same resource manager, the XAResource.isSameRM(XAResource) method can be used.
version:
   $Revision: 57196 $



Field Summary
final public static  intTMENDRSCAN
     Flag value for the XAResource.recover(int) recover method indicating that the resource manager should end the current recovery scan.
final public static  intTMFAIL
    
final public static  intTMJOIN
     Flag value for the XAResource.start(Xid,int) start method indicating that the resource should associate with a transaction previously seen by this resource manager.
final public static  intTMNOFLAGS
     Flag value indicating that no flags are set.
final public static  intTMONEPHASE
     JTA specifies this constant and states that it indicates that the caller is using one-phase optimization, but this constant seems not to be used by JTA.
final public static  intTMRESUME
     Flag value for the XAResource.start(Xid,int) start method indicating that the resource should associate with a transaction where the association was suspended.
final public static  intTMSTARTRSCAN
     Flag value for the XAResource.recover(int) recover method indicating that the resource manager should start a new recovery scan.
final public static  intTMSUCCESS
     Flag value for the XAResource.end(Xid,int) end method indicating that the transaction should be disassociated, and that the work has completed sucessfully.
final public static  intTMSUSPEND
     Flag value for the XAResource.end(Xid,int) end method indicating that the resource should temporarily suspend the association with the transaction.
final public static  intXA_OK
     Value returned from the XAResource.prepare(Xid) prepare method to indicate that the resource has successfully prepared to commit the transaction.
final public static  intXA_RDONLY
     Value returned from the XAResource.prepare(Xid) prepare method to indicate that the resource was not changed in this transaction.


Method Summary
public  voidcommit(Xid xid, boolean onePhase)
     Commit the work done on this resource in the given transaction.
public  voidend(Xid xid, int flags)
     Called to disassociate the resource from a transaction. If the flags argument is XAResource.TMSUCCESS , the portion of work was done sucessfully. If the flags argument is XAResource.TMFAIL , the portion of work failed.
public  voidforget(Xid xid)
     Tells the resource manager to forget about a heuristic decision.
public  intgetTransactionTimeout()
     Get the current transaction timeout value for this resource.
public  booleanisSameRM(XAResource xaRes)
     Tells the caller if this resource has the same resource manager as the argument resource.
public  intprepare(Xid xid)
     Prepare to commit the work done on this resource in the given transaction. This method cannot return a status indicating that the transaction should be rolled back.
public  Xid[]recover(int flag)
     Return a list of transactions that are in a prepared or heuristically state. This method looks not only at the resource it is invoked on, but also on all other resources managed by the same resource manager. It is intended to be used by the application server when recovering after a server crash.

A recovery scan is done with one or more calls to this method. At the first call, XAResource.TMSTARTRSCAN must be in the flag argument to indicate that the scan should be started. During the recovery scan, the resource manager maintains an internal cursor that keeps track of the progress of the recovery scan. To end the recovery scan, the XAResource.TMENDRSCAN must be passed in the flag argument.
Parameters:
  flag - Must be either XAResource.TMNOFLAGS, XAResource.TMSTARTRSCAN,XAResource.TMENDRSCAN or TMSTARTRSCAN|TMENDRSCAN.

public  voidrollback(Xid xid)
     Roll back the work done on this resource in the given transaction.
public  booleansetTransactionTimeout(int seconds)
     Set the transaction timeout value for this resource. If the seconds argument is 0, the timeout value is set to the default timeout value of the resource manager. Not all resource managers support setting the timeout value. If the resource manager does not support setting the timeout value, it should return false.
Parameters:
  seconds - The timeout value, in seconds.
public  voidstart(Xid xid, int flags)
     Called to associate the resource with a transaction.

Field Detail
TMENDRSCAN
final public static int TMENDRSCAN(Code)
Flag value for the XAResource.recover(int) recover method indicating that the resource manager should end the current recovery scan.



TMFAIL
final public static int TMFAIL(Code)
Flag value for the XAResource.end(Xid,int) end method indicating that the transaction should be disassociated, and that the work has failed



TMJOIN
final public static int TMJOIN(Code)
Flag value for the XAResource.start(Xid,int) start method indicating that the resource should associate with a transaction previously seen by this resource manager.



TMNOFLAGS
final public static int TMNOFLAGS(Code)
Flag value indicating that no flags are set.



TMONEPHASE
final public static int TMONEPHASE(Code)
JTA specifies this constant and states that it indicates that the caller is using one-phase optimization, but this constant seems not to be used by JTA.



TMRESUME
final public static int TMRESUME(Code)
Flag value for the XAResource.start(Xid,int) start method indicating that the resource should associate with a transaction where the association was suspended.



TMSTARTRSCAN
final public static int TMSTARTRSCAN(Code)
Flag value for the XAResource.recover(int) recover method indicating that the resource manager should start a new recovery scan.



TMSUCCESS
final public static int TMSUCCESS(Code)
Flag value for the XAResource.end(Xid,int) end method indicating that the transaction should be disassociated, and that the work has completed sucessfully.



TMSUSPEND
final public static int TMSUSPEND(Code)
Flag value for the XAResource.end(Xid,int) end method indicating that the resource should temporarily suspend the association with the transaction.



XA_OK
final public static int XA_OK(Code)
Value returned from the XAResource.prepare(Xid) prepare method to indicate that the resource has successfully prepared to commit the transaction.



XA_RDONLY
final public static int XA_RDONLY(Code)
Value returned from the XAResource.prepare(Xid) prepare method to indicate that the resource was not changed in this transaction.





Method Detail
commit
public void commit(Xid xid, boolean onePhase) throws XAException(Code)
Commit the work done on this resource in the given transaction. If the onePhase argument is true, one-phase optimization is being used, and the XAResource.prepare(Xid) prepare method must not have been called for this transaction. Otherwise, this is the second phase of the two-phase commit protocol.
Parameters:
  xid - The id of the transaction to commit work for.
Parameters:
  onePhase - If true, the transaction manager is using one-phaseoptimization.
throws:
  XAException - If an error occurred.



end
public void end(Xid xid, int flags) throws XAException(Code)
Called to disassociate the resource from a transaction. If the flags argument is XAResource.TMSUCCESS , the portion of work was done sucessfully. If the flags argument is XAResource.TMFAIL , the portion of work failed. The resource manager may mark the transaction for rollback only to avoid the transaction being committed. If the flags argument is XAResource.TMSUSPEND the resource will temporarily suspend the transaction association. The transaction must later be re-associated by giving the XAResource.TMRESUME flag to the XAResource.start(Xid,int) start method.
Parameters:
  xid - The id of the transaction to disassociate from.
Parameters:
  flags - Must be either XAResource.TMSUCCESS, XAResource.TMFAILor XAResource.TMSUSPEND.
throws:
  XAException - If an error occurred.



forget
public void forget(Xid xid) throws XAException(Code)
Tells the resource manager to forget about a heuristic decision.
Parameters:
  xid - The id of the transaction that was ended with a heuristicdecision.
throws:
  XAException - If an error occurred.



getTransactionTimeout
public int getTransactionTimeout() throws XAException(Code)
Get the current transaction timeout value for this resource. The current timeout value, in seconds.
throws:
  XAException - If an error occurred.



isSameRM
public boolean isSameRM(XAResource xaRes) throws XAException(Code)
Tells the caller if this resource has the same resource manager as the argument resource. The transaction manager needs this method to be able to decide if the XAResource.start(Xid,int) start method should be given the XAResource.TMJOIN flag.
throws:
  XAException - If an error occurred.



prepare
public int prepare(Xid xid) throws XAException(Code)
Prepare to commit the work done on this resource in the given transaction. This method cannot return a status indicating that the transaction should be rolled back. If the resource wants the transaction to be rolled back, it should throw an XAException at the caller.
Parameters:
  xid - The id of the transaction to prepare to commit work for. Either XAResource.XA_OK or XAResource.XA_RDONLY.
throws:
  XAException - If an error occurred.



recover
public Xid[] recover(int flag) throws XAException(Code)
Return a list of transactions that are in a prepared or heuristically state. This method looks not only at the resource it is invoked on, but also on all other resources managed by the same resource manager. It is intended to be used by the application server when recovering after a server crash.

A recovery scan is done with one or more calls to this method. At the first call, XAResource.TMSTARTRSCAN must be in the flag argument to indicate that the scan should be started. During the recovery scan, the resource manager maintains an internal cursor that keeps track of the progress of the recovery scan. To end the recovery scan, the XAResource.TMENDRSCAN must be passed in the flag argument.
Parameters:
  flag - Must be either XAResource.TMNOFLAGS, XAResource.TMSTARTRSCAN,XAResource.TMENDRSCAN or TMSTARTRSCAN|TMENDRSCAN. An array of zero or more transaction ids.
throws:
  XAException - If an error occurred.




rollback
public void rollback(Xid xid) throws XAException(Code)
Roll back the work done on this resource in the given transaction.
Parameters:
  xid - The id of the transaction to commit work for.
throws:
  XAException - If an error occurred.



setTransactionTimeout
public boolean setTransactionTimeout(int seconds) throws XAException(Code)
Set the transaction timeout value for this resource. If the seconds argument is 0, the timeout value is set to the default timeout value of the resource manager. Not all resource managers support setting the timeout value. If the resource manager does not support setting the timeout value, it should return false.
Parameters:
  seconds - The timeout value, in seconds. True if the timeout value could be set, otherwise false.
throws:
  XAException - If an error occurred.



start
public void start(Xid xid, int flags) throws XAException(Code)
Called to associate the resource with a transaction. If the flags argument is XAResource.TMNOFLAGS , the transaction must not previously have been seen by this resource manager, or an XAException with error code XAER_DUPID will be thrown. If the flags argument is XAResource.TMJOIN , the resource will join a transaction previously seen by tis resource manager. If the flags argument is XAResource.TMRESUME the resource will resume the transaction association that was suspended with end(TMSUSPEND).
Parameters:
  xid - The id of the transaction to associate with.
Parameters:
  flags - Must be either XAResource.TMNOFLAGS, XAResource.TMJOINor XAResource.TMRESUME.
throws:
  XAException - If an error occurred.



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