KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > transacted > SimpleCommon


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: SimpleCommon.java,v 1.8 2004/08/04 15:00:00 durieuxp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 // SimpleCommon.java
27

28 package org.objectweb.jonas.jtests.beans.transacted;
29
30 import java.rmi.RemoteException JavaDoc;
31
32 import javax.transaction.Status JavaDoc;
33 import javax.transaction.UserTransaction JavaDoc;
34
35 import org.objectweb.jonas.common.Log;
36 import org.objectweb.jonas.jtm.TransactionService;
37 import org.objectweb.jonas.service.ServiceManager;
38 import org.objectweb.util.monolog.api.BasicLevel;
39 import org.objectweb.util.monolog.api.Logger;
40 import org.objectweb.jonas.jtests.util.JBean;
41
42 /**
43  * Common part to different implementations of Simple
44  */

45 public class SimpleCommon extends JBean {
46
47     static protected Logger logger = null;
48
49     /**
50      * Utility method that init the logger
51      */

52     protected void initLogger() {
53         if (logger == null)
54             logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
55     }
56
57     /**
58      * This method return true if there is an association of a transaction with
59      * this thread
60      */

61     public boolean opwith_notsupported() {
62         logger.log(BasicLevel.DEBUG, "");
63         return isAssociated();
64     }
65
66     /**
67      * This method return true if there is an association of a transaction with
68      * this thread
69      */

70     public boolean opwith_supports() {
71         logger.log(BasicLevel.DEBUG, "");
72         return isAssociated();
73     }
74
75     /**
76      * This method return true if there is an association of a transaction with
77      * this thread
78      */

79     public boolean opwith_required() {
80         logger.log(BasicLevel.DEBUG, "");
81         return isAssociated();
82     }
83
84     /**
85      * This method return true if there is an association of a transaction with
86      * this thread
87      */

88     public boolean opwith_requires_new() {
89         logger.log(BasicLevel.DEBUG, "");
90         return isAssociated();
91     }
92
93     /**
94      * This method return true if there is an association of a transaction with
95      * this thread
96      */

97     public boolean opwith_mandatory() {
98         logger.log(BasicLevel.DEBUG, "");
99         return isAssociated();
100     }
101   
102     /**
103      * This method return true if there is an association of a transaction with
104      * this thread
105      */

106     public boolean opwith_never() {
107         logger.log(BasicLevel.DEBUG, "");
108         return isAssociated();
109     }
110  
111     /**
112      * REQUIRED -> should return true.
113      */

114     public boolean required_call_requires_new() {
115         logger.log(BasicLevel.DEBUG, "");
116         boolean tx = opwith_requires_new();
117         if (!tx) {
118             logger.log(BasicLevel.ERROR, "opwith_requires_new was outside tx");
119             return false; // error
120
}
121         return isAssociated();
122     }
123
124     /**
125      * REQUIRED -> should return true.
126      */

127     public boolean call_requires_new_on(Simple other) throws RemoteException JavaDoc {
128         logger.log(BasicLevel.DEBUG, "");
129         boolean tx = other.opwith_requires_new();
130         if (!tx) {
131             logger.log(BasicLevel.ERROR, "opwith_requires_new was outside tx");
132             return false; // error
133
}
134         return isAssociated();
135     }
136
137 }
138
Popular Tags