KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xa > OzoneUserTransaction


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: OzoneUserTransaction.java,v 1.2 2002/09/18 06:54:18 per_nyfelt Exp $
8

9 package org.ozoneDB.xa;
10
11 import javax.transaction.*;
12
13
14 /**
15  * The UserTransaction interface defines the methods that allow an application
16  * to explicitly manage transaction boundaries.
17  *
18  *
19  * @author <a HREF="http://www.softwarebuero.de/">SMB</a>
20  * @version $Revision: 1.2 $Date: 2002/09/18 06:54:18 $
21  */

22 public final class OzoneUserTransaction implements UserTransaction {
23     
24     /**
25      * Holds a reference to the underlying transaction manager.
26      */

27     private static TransactionManager txManager;
28     
29     
30     public void setTransactionManager( TransactionManager _txManager ) {
31         txManager = _txManager;
32     }
33     
34     
35     public OzoneUserTransaction() {
36     }
37     
38     
39     public void begin() throws NotSupportedException, SystemException {
40         // The logic for user transaction is to never support nested
41
// transactions, regardless of what the transaction server
42
// can do.
43
if (txManager.getTransaction() != null) {
44             throw new NotSupportedException( "Nested transactions not supported in beans" );
45         }
46         txManager.begin();
47     }
48     
49     
50     public void commit()
51             throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException JavaDoc,
52             IllegalStateException JavaDoc, SystemException {
53         txManager.commit();
54     }
55     
56     
57     public void rollback() throws IllegalStateException JavaDoc, SecurityException JavaDoc, SystemException {
58         txManager.rollback();
59     }
60     
61     
62     public int getStatus() throws SystemException {
63         return txManager.getStatus();
64     }
65     
66     
67     public void setRollbackOnly() throws SystemException {
68         txManager.setRollbackOnly();
69     }
70     
71     
72     public void setTransactionTimeout( int seconds ) throws SystemException {
73         txManager.setTransactionTimeout( seconds );
74     }
75     
76 }
77
Popular Tags