KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_q816Components > FactoryFinderProviderMonolithicImpl


1 /*====================================================================
2 Tnis file was produced by the OpenCCM ir3_jimpl generator.
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2002 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
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 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 USA
18 Initial developer(s): Philippe Merle, Mathieu Vadet.
19 Contributor(s): Sylvain Leblanc_______________________.
20 ====================================================================*/

21 package ist.coach.itut_q816Components;
22
23 import intt.itu.itut_x780.UIDType;
24 import intt.itu.itut_x780.ApplicationError;
25 import intt.itu.itut_q816.FactoryInfoType;
26 import intt.itu.itut_x780.ManagedObjectFactory;
27 import intt.itu.itut_x780.ManagedObjectFactoryHelper;
28
29 import org.omg.CosNaming.NameComponent JavaDoc;
30 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
31 /**
32  ** Implementation skeleton class for the ::itut_q816Components::FactoryFinderProvider component.
33  ** Business operations MUST be completed !!!
34  **/

35 public class FactoryFinderProviderMonolithicImpl
36        extends org.omg.CORBA.LocalObject JavaDoc
37        implements CCM_FactoryFinderProvider,
38                   intt.itu.itut_q816.CCM_FactoryFinder,
39                   intt.itu.itut_q816.CCM_FactoryFinderComponent,
40                   org.omg.Components.SessionComponent
41 {
42     // ==================================================================
43
//
44
// Internal State.
45
//
46
// ===================================================================
47
/**
48      ** Context reference.
49      **/

50     private CCM_FactoryFinderProvider_Context the_context_;
51
52     /* Business Logic **/
53     java.util.Hashtable JavaDoc factories = null;
54     // ==================================================================
55
//
56
// Constructor.
57
//
58
// ===================================================================
59
/**
60      ** The default constructor.
61      **/

62     public
63     FactoryFinderProviderMonolithicImpl()
64     {
65         the_context_ = null;
66         factories = new java.util.Hashtable JavaDoc();
67     }
68     // ==================================================================
69
//
70
// Internal methods.
71
//
72
// ===================================================================
73
// ==================================================================
74
//
75
// Public methods.
76
//
77
// ===================================================================
78
/**
79      ** To obtain the context.
80      **
81      ** @return The context that has been previously set by
82      ** the set_session_context operation.
83      **/

84     public CCM_FactoryFinderProvider_Context
85     getContext()
86     {
87         return the_context_;
88     }
89     // ==================================================================
90
//
91
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
92
//
93
// ==================================================================
94
//
95
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
96
//
97
/**
98      ** Completes the component configuration.
99      **
100      ** @throws org.omg.Components.InvalidConfiguration
101      ** Thrown if the configuration is invalid.
102      **/

103     public void
104     configuration_complete()
105     throws org.omg.Components.InvalidConfiguration
106     {
107         //
108
// DONE : implement !!!
109
//
110
System.err.println("FactoryFinderProvider configuration completed...");
111
112     }
113     // ==================================================================
114
//
115
// Methods for the OMG IDL Components::SessionComponent local interface.
116
//
117
// ==================================================================
118
//
119
// IDL:omg.org/Components/SessionComponent/set_session_context:1.0
120
//
121
/**
122      * Called by the container when the component session context will be fixed.
123      *
124      * @param context The session context.
125      *
126      * @throws org.omg.Components.CCMException
127      * Thrown if a system level error occured.
128      */

129     public void
130     set_session_context(org.omg.Components.SessionContext context)
131     throws org.omg.Components.CCMException
132     {
133         the_context_ = (CCM_FactoryFinderProvider_Context)context;
134     }
135     //
136
// IDL:omg.org/Components/SessionComponent/ccm_activate:1.0
137
//
138
/**
139      *
140      * Called by the container when the component will be activated.
141      *
142      * @throws org.omg.Components.CCMException
143      * Thrown if a system level error occured.
144      */

145     public void
146     ccm_activate()
147     throws org.omg.Components.CCMException
148     {
149         //
150
// Unused by actual OpenCCM containers
151
//
152
}
153     //
154
// IDL:omg.org/Components/SessionComponent/ccm_passivate:1.0
155
//
156
/**
157      *
158      * Called by the container when the component will be passivated.
159      *
160      * @throws org.omg.Components.CCMException
161      * Thrown if a system level error occured.
162      */

163     public void
164     ccm_passivate()
165     throws org.omg.Components.CCMException
166     {
167         //
168
// Unused by actual OpenCCM containers
169
//
170
}
171     //
172
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
173
//
174
/**
175      *
176      * Called by the container when the component will be removed.
177      *
178      * @throws org.omg.Components.CCMException
179      * Thrown if a system level error occured.
180      */

181     public void
182     ccm_remove()
183     throws org.omg.Components.CCMException
184     {
185         //
186
// TO DO: implement !!!
187
//
188
}
189     // ==================================================================
190
//
191
// Public methods for the CCM_FactoryFinderProvider local interface.
192
//
193
// ==================================================================
194
//
195
// IDL:coach.ist/itut_q816Components/CCM_FactoryFinderProvider/get_query:1.0
196
//
197
/**
198      ** Implementation of the ::itut_q816Components::CCM_FactoryFinderProvider::get_query operation.
199      **/

200     public intt.itu.itut_q816.CCM_FactoryFinder
201     get_query()
202     {
203         return this;
204     }
205     //
206
// IDL:coach.ist/itut_q816Components/CCM_FactoryFinderProvider/get_admin:1.0
207
//
208
/**
209      ** Implementation of the ::itut_q816Components::CCM_FactoryFinderProvider::get_admin operation.
210      **/

211     public intt.itu.itut_q816.CCM_FactoryFinderComponent
212     get_admin()
213     {
214         return this;
215     }
216     // ==================================================================
217
//
218
// Public methods for the ::itut_q816::CCM_FactoryFinder local interface.
219
//
220
// ==================================================================
221
//
222
// IDL:itu.intt/itut_q816/FactoryFinder/find:1.0
223
//
224
/**
225      ** Implementation of the ::itut_q816::FactoryFinder::find operation.
226      **/

227     public intt.itu.itut_x780.ManagedObjectFactory
228     find(java.lang.String JavaDoc factoryClass)
229     throws intt.itu.itut_q816.FactoryNotFound, intt.itu.itut_x780.ApplicationError
230     {
231         //
232
// DONE : implement
233
//
234
if (! factories.containsKey(factoryClass))
235             throw new intt.itu.itut_q816.FactoryNotFound(factoryClass +
236                 " has not been registered");
237
238         FactoryInfoType f_info =
239                 (FactoryInfoType) factories.get(factoryClass);
240
241
242         return f_info.factoryRef;
243     }
244     //
245
// IDL:itu.intt/itut_q816/FactoryFinder/list:1.0
246
//
247
/**
248      ** Implementation of the ::itut_q816::FactoryFinder::list operation.
249      **/

250     public intt.itu.itut_q816.FactoryInfoType[]
251     list()
252     throws intt.itu.itut_x780.ApplicationError
253     {
254         //
255
// DONE : implement
256
//
257
int f_size = factories.size();
258         if (f_size <= 0)
259             return new FactoryInfoType[0];
260
261         FactoryInfoType[] factories_list =
262         new FactoryInfoType[f_size];
263
264         factories_list =
265             (FactoryInfoType[]) factories.values().toArray(factories_list);
266
267         return factories_list;
268     }
269     // ==================================================================
270
//
271
// Public methods for the ::itut_q816::CCM_FactoryFinderComponent local interface.
272
//
273
// ==================================================================
274
//
275
// IDL:itu.intt/itut_q816/FactoryFinderComponent/register:1.0
276
//
277
/**
278      ** Implementation of the ::itut_q816::FactoryFinderComponent::register operation.
279      **/

280     public void
281     register(java.lang.String JavaDoc factoryClass,
282             intt.itu.itut_x780.ManagedObjectFactory factoryRef)
283     throws intt.itu.itut_x780.ApplicationError
284     {
285         //
286
// DONE : implement
287
//
288
if (factoryClass == null || factoryClass.length() == 0) {
289             ApplicationErrorInfoTypeImpl error_code =
290                     new ApplicationErrorInfoTypeImpl();
291             error_code.error = new UIDType(
292                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
293                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
294             error_code.details = new String JavaDoc("Factory class name is not specified!");
295
296             throw new ApplicationError(error_code);
297         }
298         if (factoryRef == null) {
299              ApplicationErrorInfoTypeImpl error_code =
300                     new ApplicationErrorInfoTypeImpl();
301             error_code.error = new UIDType(
302                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
303                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
304             error_code.details = new String JavaDoc("Factory reference is not provided!");
305
306             throw new ApplicationError(error_code);
307         }
308
309         FactoryInfoType factory_info = new FactoryInfoType(factoryClass, factoryRef);
310         factories.put(factoryClass, factory_info);
311
312     }
313     //
314
// IDL:itu.intt/itut_q816/FactoryFinderComponent/unregister:1.0
315
//
316
/**
317      ** Implementation of the ::itut_q816::FactoryFinderComponent::unregister operation.
318      **/

319     public void
320     unregister(java.lang.String JavaDoc factoryClass, intt.itu.itut_x780.ManagedObjectFactory factoryRef)
321     throws intt.itu.itut_q816.FactoryNotFound, intt.itu.itut_x780.ApplicationError
322     {
323         //
324
// DONE : implement
325
//
326

327         if (! factories.containsKey(factoryClass))
328             throw new intt.itu.itut_q816.FactoryNotFound(factoryClass +
329                 " has not been registered");
330
331         factories.remove(factoryClass);
332     }
333 }
334
Popular Tags