KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > pss > runtime > common > lib > ConnectorBase


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.common.lib;
28
29
30 /**
31  * ConnectorBase is a base class for Connector.
32  * It implements the org.objectweb.openccm.pss.runtime.api.Connector 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 ConnectorBase
40               extends org.omg.CORBA.LocalObject JavaDoc
41            implements org.objectweb.openccm.pss.runtime.common.api.Connector
42 {
43     // ==================================================================
44
//
45
// Internal state.
46
//
47
// ==================================================================
48

49     /**
50      * The implementation id.
51      */

52     protected String JavaDoc _implementation_id;
53
54     /**
55      * Registered object factories.
56      */

57     protected java.util.Map JavaDoc _storage_object_factories;
58
59     /**
60      * Registered home factories.
61      */

62     protected java.util.Map JavaDoc _storage_home_factories;
63
64      /**
65      * Next free id for Catalogs.
66      */

67     protected int _free_id;
68
69     // ==================================================================
70
//
71
// Constructor.
72
//
73
// ==================================================================
74

75     /**
76      * The default constructor.
77      *
78      * @param id - The connector id.
79      */

80     public ConnectorBase(String JavaDoc id)
81     {
82         _implementation_id = id;
83         _storage_object_factories = new java.util.HashMap JavaDoc();
84         _storage_home_factories = new java.util.HashMap JavaDoc();
85         _free_id = 0;
86     }
87
88     // ==================================================================
89
//
90
// Internal methods.
91
//
92
// ==================================================================
93

94     // ==================================================================
95
//
96
// Public methods.
97
//
98
// ==================================================================
99

100     // ==================================================================
101
//
102
// Methods for org.omg.CosPersistentState.Connector
103
//
104
// ==================================================================
105

106     /**
107      * Read accessor for implementation_id attribute
108      *
109      * @return the attribute value
110      */

111     public String JavaDoc implementation_id()
112     {
113         return _implementation_id;
114     }
115
116     /**
117      * Get the PID of a Storage Object.
118      */

119     public byte[]
120     get_pid(java.lang.Object JavaDoc obj)
121     {
122         return ((org.omg.CosPersistentState.StorageObject) obj).get_pid();
123     }
124
125     /**
126      * Get the short PID of a Storage Object.
127      */

128     public byte[]
129     get_short_pid(java.lang.Object JavaDoc obj)
130     {
131         return ((org.omg.CosPersistentState.StorageObject) obj).get_short_pid();
132     }
133
134     /**
135      * Create a basic session.
136      */

137     public abstract org.omg.CosPersistentState.Session
138     create_basic_session(short access_mode,
139                          org.omg.CosPersistentState.Parameter[] additional_parameters);
140
141     /**
142      * Create a transactional session.
143      */

144     public abstract org.omg.CosPersistentState.TransactionalSession
145     create_transactional_session(short access_mode,
146                                  short default_isolation_level,
147                                  org.omg.CosPersistentState.EndOfAssociationCallback callback,
148                                  org.omg.CosPersistentState.Parameter[] additional_parameters);
149
150     /**
151      * Create a session pool.
152      */

153     public abstract org.omg.CosPersistentState.SessionPool
154     create_session_pool(short access_mode,
155                         short tx_policy,
156                         org.omg.CosPersistentState.Parameter[] additional_parameters);
157
158     /**
159      * Get the current session.
160      */

161     public abstract org.omg.CosPersistentState.TransactionalSession
162     current_session();
163
164     /**
165      * Get sessions.
166      */

167     public abstract org.omg.CosPersistentState.TransactionalSession[]
168     sessions(org.omg.CosTransactions.Coordinator transaction);
169
170     /**
171      * Register a storage object factory.
172      */

173     public java.lang.Class JavaDoc
174     register_storage_object_factory(String JavaDoc storage_type_name,
175                                     java.lang.Class JavaDoc storage_object_factory)
176     {
177         java.lang.Class JavaDoc previous = null;
178
179         previous = (Class JavaDoc) _storage_object_factories.get(storage_type_name);
180         if ( previous != null )
181             _storage_object_factories.remove(storage_type_name);
182
183         _storage_object_factories.put(storage_type_name, storage_object_factory);
184         return previous;
185     }
186
187     /**
188      * Register a storage home factory
189      */

190     public java.lang.Class JavaDoc
191     register_storage_home_factory(String JavaDoc storage_home_type_name,
192                                   java.lang.Class JavaDoc storage_home_factory)
193     {
194         java.lang.Class JavaDoc previous = null;
195
196         previous = (Class JavaDoc) _storage_home_factories.get(storage_home_type_name);
197         if ( previous != null )
198             _storage_home_factories.remove(storage_home_type_name);
199
200         _storage_home_factories.put(storage_home_type_name, storage_home_factory);
201         return previous;
202     }
203
204     /**
205      * Register a session factory.
206      */

207     public java.lang.Class JavaDoc
208     register_session_factory(java.lang.Class JavaDoc session_factory)
209     {
210         // Don't know how to implement this method
211
return null;
212     }
213
214     /**
215      * Register a session pool factory.
216      */

217     public java.lang.Class JavaDoc
218     register_session_pool_factory(java.lang.Class JavaDoc session_pool_factory)
219     {
220         // Don't know how to implement this method
221
return null;
222     }
223
224     // ==================================================================
225
//
226
// Methods for org.objectweb.openccm.pss.runtime.common.api.Connector
227
//
228
// ==================================================================
229

230     /**
231      * Get a storage object factory.
232      */

233     public java.lang.Class JavaDoc
234     get_storage_object_factory(String JavaDoc storage_type_name)
235     {
236         return (Class JavaDoc) _storage_object_factories.get(storage_type_name);
237     }
238
239     /**
240      * Get a storage home factory
241      */

242     public java.lang.Class JavaDoc
243     get_storage_home_factory(String JavaDoc storage_home_type_name)
244     {
245         return (Class JavaDoc) _storage_home_factories.get(storage_home_type_name);
246     }
247
248     /**
249      * Get the next free id for catalogs
250      */

251     public int
252     get_free_id()
253     {
254         return _free_id++;
255     }
256 }
257
Popular Tags