KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > plugins > transaction > controller > WithCurrentController


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2001-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Romain Rouvoy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.plugins.transaction.controller;
28
29 import org.objectweb.openccm.corba.TheORB;
30
31 /**
32  * This class implements an transactionnal profile for the
33  * OpenCCM::Containers::CallController interface.
34  *
35  * @author <a HREF="mailto:Romain.Rouvoy@lifl.fr">Romain Rouvoy</a>
36  *
37  * @version 0.3
38  */

39 public abstract class WithCurrentController
40         extends org.omg.CORBA.LocalObject JavaDoc
41         implements org.objectweb.openccm.Containers.CallController
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /**
50      * Reference to the transaction service current interface
51      *
52      */

53     protected org.omg.CosTransactions.Current current_;
54
55         /**
56          * Determine if a transaction has been started by the controller
57          *
58          */

59         protected boolean private_transaction_;
60     
61     // ==================================================================
62
//
63
// Constructor.
64
//
65
// ==================================================================
66

67     /**
68      ** The constructor.
69      **
70      **/

71     public
72     WithCurrentController()
73     {
74                 current_ = null;
75                 private_transaction_ = false;
76                 try
77                         {
78                                 org.omg.CORBA.Object JavaDoc _obj = TheORB.getORB().resolve_initial_references("TransactionCurrent");
79                                 current_ = org.omg.CosTransactions.CurrentHelper.narrow( _obj );
80                         }
81                 catch (org.omg.CORBA.ORBPackage.InvalidName JavaDoc ex)
82                         {
83                         }
84     }
85
86     // ==================================================================
87
//
88
// Internal methods.
89
//
90
// ==================================================================
91

92         /**
93          ** tell if there is no transaction started
94          **
95          ** @return true -> there is no active transaction
96          **/

97         protected boolean
98         no_transaction(org.objectweb.openccm.Containers.CallContext ctx)
99         {
100                 return current_.get_status() == org.omg.CosTransactions.Status.StatusNoTransaction;
101         }
102         
103         /**
104          ** begin a new transaction
105          **
106          **/

107         protected void
108         begin(org.objectweb.openccm.Containers.CallContext ctx)
109         {
110                 try
111                         {
112                                 current_.begin();
113                                 private_transaction_ = true;
114                         }
115                 catch (org.omg.CosTransactions.SubtransactionsUnavailable ex)
116                         {
117                         }
118                 // TODO :
119
//
120
// Wrapp the exception
121
}
122
123         /**
124          ** Commit a transaction
125          ** <i> Only if it has been started by the current controller </i>
126          **
127          **/

128         protected void
129         commit(org.objectweb.openccm.Containers.CallContext ctx)
130         {
131                 if (private_transaction_)
132                         {
133                                 try
134                                         {
135                                                 current_.commit(false);
136                                                 private_transaction_ = false;
137                                         } catch(org.omg.CosTransactions.NoTransaction ex) {
138                                         } catch(org.omg.CosTransactions.HeuristicMixed ex) {
139                                         } catch(org.omg.CosTransactions.HeuristicHazard ex) {
140                                         }
141                         }
142                 // TODO :
143
//
144
// Wrapp the exceptions
145
}
146
147     // ==================================================================
148
//
149
// Public methods for the CallController interface.
150
//
151
// ==================================================================
152

153     // ==================================================================
154
//
155
// Public methods for the CallProtocol interface.
156
//
157
// ==================================================================
158

159     //
160
// IDL:goal.lifl.fr/OpenCCM/Containers/CallProtocol/preinvoke:1.0
161
//
162
/**
163      **
164      **/

165     public abstract void
166         preinvoke(org.objectweb.openccm.Containers.CallContext ctx);
167
168     //
169
// IDL:goal.lifl.fr/OpenCCM/Containers/CallProtocol/postinvoke:1.0
170
//
171
/**
172      **
173      **/

174     public abstract void
175         postinvoke(org.objectweb.openccm.Containers.CallContext ctx);
176
177     // ==================================================================
178
//
179
// Public methods for the SystemComponent interface.
180
//
181
// ==================================================================
182

183     // ==================================================================
184
//
185
// Public methods for the Configuration interface.
186
//
187
// ==================================================================
188

189     //
190
// IDL:goal.lifl.fr/OpenCCM/Containers/Configuration/configure:1.0
191
//
192
/**
193      **
194      **/

195     public abstract void
196       configure(org.objectweb.openccm.Containers.PropertySet config)
197                 throws org.objectweb.openccm.Containers.ConfigurationFailed;
198 }
199
Popular Tags