KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > pss > runtime > jdo > lib > CatalogBase


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@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): Christophe Demarey.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.pss.runtime.jdo.lib;
28
29
30 /**
31  * CatalogBase is a base class for JDO Catalog.
32  * It implements the org.objectweb.openccm.pss.runtime.api.Catalog interface.
33  *
34  * @author <a HREF="mailto:Christophe.Demarey@lifl.fr">Christophe Demarey</a>
35  *
36  * @version 0.1
37  */

38
39 public abstract class CatalogBase
40               extends org.objectweb.openccm.pss.runtime.common.lib.CatalogBase
41            implements org.objectweb.openccm.pss.runtime.jdo.api.CatalogBase
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /**
50      * Persistent Manager reference.
51      */

52     private javax.jdo.PersistenceManager _persistence_manager;
53
54     // ==================================================================
55
//
56
// Constructor.
57
//
58
// ==================================================================
59

60     /**
61      * The default constructor.
62      *
63      * @param id - The catalog id.
64      * @param pm - The associted JDO Persistence Manager.
65      */

66     public CatalogBase(int id, javax.jdo.PersistenceManager pm)
67     {
68         super(id);
69         _persistence_manager = pm;
70     }
71
72     // ==================================================================
73
//
74
// Internal methods.
75
//
76
// ==================================================================
77

78     // ==================================================================
79
//
80
// Public methods.
81
//
82
// ==================================================================
83

84     // ==================================================================
85
//
86
// Methods for org.omg.CosPersistentState.Catalog
87
//
88
// ==================================================================
89

90     // ==================================================================
91
//
92
// Methods for org.objectweb.openccm.pss.runtime.common.api.CatalogBase
93
//
94
// ==================================================================
95

96     // ==================================================================
97
//
98
// Methods for org.objectweb.openccm.pss.runtime.jdo.api.CatalogBase
99
//
100
// ==================================================================
101

102     /**
103      * Get the JDO Persistence Manager.
104      *
105      * @return The associated persistence manager.
106      */

107     public javax.jdo.PersistenceManager
108     get_persistence_manager()
109     {
110         return _persistence_manager;
111     }
112
113     /**
114      * Begin a transaction in the JDO Persistence Manager.
115      */

116     public void
117     begin_tx()
118     {
119         javax.jdo.Transaction t = get_persistence_manager().currentTransaction();
120         if ( !t.isActive() )
121             t.begin();
122     }
123
124     /**
125      * Commit a transaction in the JDO Persistence Manager.
126      */

127     public void
128     commit_tx()
129     {
130         javax.jdo.Transaction t = get_persistence_manager().currentTransaction();
131         if ( t.isActive() )
132         {
133             t.commit();
134             begin_tx();
135         }
136     }
137
138     /**
139      * Rollback a transaction in the JDO Persistence Manager.
140      */

141     public void
142     rollback_tx()
143     {
144         javax.jdo.Transaction t = get_persistence_manager().currentTransaction();
145         if ( t.isActive() )
146         {
147             t.rollback();
148             begin_tx();
149         }
150     }
151 }
152
Popular Tags