Java Doc for ExtendedTransactionStatus.java in  » UML » MetaBoss » com » metaboss » enterprise » transaction » 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 » UML » MetaBoss » com.metaboss.enterprise.transaction 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.metaboss.enterprise.transaction.ExtendedTransactionStatus

ExtendedTransactionStatus
public interface ExtendedTransactionStatus (Code)
This interface is somewhat reluctant addition by MetaBoss to the JTA specification. It provides access to the rich transaction status information.

Problem description Java Transaction Architecture (JTA) Specification defines very simple (almost too simple) transaction status mechanism. Under this mechanism :

  • Any transaction participant (eg. server doing some work in transaction) is able to mark transaction for rollback via UserTransaction.setRollbackOnly() or Transaction.setRollbackOnly() methods.
  • Any transaction participant can check the status of the current transaction via UserTransaction.getStatus() and Transaction.getStatus() methods.
The facility to communicate more details about cause of rollback is absent. Such details may contain an identity of the party, which have had a problem and the description of the problem (may be in form of exception). Absence of this facility forces application programmers to invent some "on-the-side" mechanisms to carry rich transaction status information in transaction context. The addition of the cause exception to the java.lang.Throwable in Java 1.4.x offers some opportunity to use cause in the HeuristicRollbackException to communicate the cause of rollback, but it is only helping the code which has issued commit() instruction.

Solution description In order not to pollute JTA interfaces, separate ExtendedTransactionStatus interface is introduced. The instance of this interface is obtainable via JNDI alongside with javax.transaction.Transaction and javax.transaction.UserTransaction. This interface provides facility to store and retrieve rollback cause together with transaction status. Because this interface is an addition to JTA - it's usage (or decision not to use) remains entirely an application discretion. We envisage that if and when JTA specification is enhanced (say UserTransaction and Transaction objects will have similar facility in their interfaces) we will offer clients a smooth transition along the following lines:

  1. At this stage com.metaboss.enterprise.transaction.ExtendedTransactionStatus will be the only component able to deliver this functionality. The implementation will reside in MetaBoss run-time libraries. ExtendedTransactionStatus does not override JTA status management facilities, JTA components will have to be used for setting transactions to rollback status and checking basic transaction status. This means that client application code will be 100% compliant with J2EE and any other Java standard in this area.
  2. After JTA Interfaces are enhanced and able to offer similar facilities, the com.metaboss.enterprise.transaction.ExtendedTransactionStatus interface will continue to offer this facility but it will be deprecated and internal implementation will revert to JTA. If and when this occurs, changes and schedule for deprecation and ultimate retirement of this interface will be communicated to clients.
  3. After a while (say one or two major release cycles or 12 month) com.metaboss.enterprise.transaction.ExtendedTransactionStatus will be retired. There may also be some interim release where com.metaboss.enterprise.transaction.ExtendedTransactionStatus is present, but each and every method throws javax.transaction.NotSupportedException

Usage description To set transaction to rollback only after failure has occurred :

 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.transaction.Transaction;
 import com.metaboss.enterprise.transaction.ExtendedTransactionStatus;
 ...............................  
 ...............................
 try
 {
 ...............................  
 ...............................
 }
 catch(SomeBadException lShowStopperException)
 {  
 Context lContext = new javax.naming.InitialContext();
 Transaction lTransaction = (Transaction)lContext.lookup(com.metaboss.enterprise.transaction.Transaction.COMPONENT_URL);
 ExtendedTransactionStatus lExtendedTransactionStatus = (ExtendedTransactionStatus)lContext.lookup(com.metaboss.enterprise.transaction.ExtendedTransactionStatus.COMPONENT_URL);
 lTransaction.setRollbackOnly();
 lExtendedTransactionStatus.setRollbackCause(lShowStopperException);
 }
 

To check extended status after failure has occurred :

 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.transaction.UserTransaction;
 import javax.transaction.HeuristicRollbackException;
 import com.metaboss.enterprise.transaction.ExtendedTransactionStatus;
 ...............................  
 ...............................
 Context lContext = new javax.naming.InitialContext();
 try
 {
 UserTransaction lUserTransaction = (UserTransaction)lContext.lookup(com.metaboss.enterprise.transaction.UserTransaction.COMPONENT_URL);
 ...............................  
 ...............................
 ...............................
 lUserTransaction.commit();
 }
 catch(HeuristicRollbackException lRollbackException)
 {  
 try
 {
 ExtendedTransactionStatus lExtendedTransactionStatus = (ExtendedTransactionStatus)lContext.lookup(com.metaboss.enterprise.transaction.ExtendedTransactionStatus.COMPONENT_URL);
 Throwable lRollbackCauseException = lExtendedTransactionStatus.getRollbackCause();
 if (lRollbackCauseException != null)
 {
 // Obtained ExtendedTransactionStatus object, and it has information about cause.
 // Cause is known. Analyse it or report it
 ...............................
 ...............................
 }
 else
 {
 // Obtained ExtendedTransactionStatus object, but it does not have information about cause.
 // Cause is unknown. Report this situation somehow
 ...............................
 ...............................
 }
 }
 catch(javax.naming.NamingException lNamingException)
 {  
 // Unable to obtain ExtendedTransactionStatus object.
 // Cause is unknown. Report this situation somehow
 ...............................
 ...............................
 }
 }
 



Field Summary
final public static  StringCOMPONENT_URL
    


Method Summary
public  ThrowablegetRollbackCause()
     Retrieves rollback cause.
public  voidsetRollbackCause(Throwable pCause)
     Saves rollback cause.

Field Detail
COMPONENT_URL
final public static String COMPONENT_URL(Code)
Naming URL of the factory component





Method Detail
getRollbackCause
public Throwable getRollbackCause() throws javax.transaction.SystemException, javax.transaction.NotSupportedException, java.lang.IllegalStateException(Code)
Retrieves rollback cause. Can be called at any time, but may return null meaning that cause has not been stored. The reasons may be that transaction has not been rolled back, no one has actually stored the cause etc..
exception:
  javax.transaction.SystemException - thrown if this operation encountered some sort of system error preventing it from completion
exception:
  javax.transaction.NotSupportedException - thrown if this mechanism is not supported.
exception:
  java.lang.IllegalStateException - thrown if current thread is not associated with transaction or transaction is notin one of the roolback states : javax.transaction.Status.STATUS_MARKED_ROLLBACK or javax.transaction.Status.STATUS_ROLLEDBACKor javax.transaction.Status.STATUS_ROLLING_BACK



setRollbackCause
public void setRollbackCause(Throwable pCause) throws javax.transaction.SystemException, javax.transaction.NotSupportedException, java.lang.IllegalStateException(Code)
Saves rollback cause. Can only be called once after transaction status is already set to rollback only.
exception:
  javax.transaction.SystemException - thrown if this operation encountered some sort of system error preventing it from completion
exception:
  javax.transaction.NotSupportedException - thrown if this mechanism is not supported.
exception:
  java.lang.IllegalStateException - thrown if current thread is not associated with transaction, transaction is not market for rollback or rollback cause for this transaction has been stored already.



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