KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_x780Components > ManagedObjectProviderMonolithicImpl


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_x780Components;
22
23 import ist.coach.coachEmfCommon.Utils;
24 import ist.coach.coachEmfCommon.ExceptionMessages;
25 import intt.itu.itut_x780.UIDType;
26 import intt.itu.itut_x780.CreateError;
27 import intt.itu.itut_x780.ApplicationError;
28 import intt.itu.itut_x780.AttributeValueType;
29
30 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl;
31 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
32 import ist.coach.coachEmfCommon.ManagedObjectValueTypeImpl;
33 import ist.coach.coachEmfCommon.ObjectCreationImpl;
34 import ist.coach.coachEmfCommon.ObjectDeletionImpl;
35
36 import intt.itu.itut_x780.ManagedObjectValueType;
37 import org.omg.CosNaming.NameComponent JavaDoc;
38
39 import ist.coach.itut_x780Components.CCM_ManagedObjectProvider_Context;
40 /**
41  ** Implementation skeleton class for the ::itut_x780Components::ManagedObjectProvider component.
42  **/

43 public class ManagedObjectProviderMonolithicImpl
44        extends org.omg.CORBA.LocalObject JavaDoc
45        implements CCM_ManagedObjectProvider,
46                   ist.coach.itut_x780Components.CCM_ManagedObjectMgmt,
47                   org.omg.Components.SessionComponent
48 {
49     // ==================================================================
50
//
51
// Internal State.
52
//
53
// ===================================================================
54
private String JavaDoc _facade_name;
55
56     java.util.Hashtable JavaDoc elements;
57     private int notifId = 100;
58     /**
59      ** Context reference.
60      **/

61     private CCM_ManagedObjectProvider_Context the_context_;
62     // ==================================================================
63
//
64
// Constructor.
65
//
66
// ===================================================================
67
/**
68      ** The default constructor.
69      **/

70     public
71     ManagedObjectProviderMonolithicImpl()
72     {
73         the_context_ = null;
74     }
75     // ==================================================================
76
//
77
// Internal methods.
78
//
79
// ===================================================================
80
// ==================================================================
81
//
82
// Public methods.
83
//
84
// ===================================================================
85
/**
86      ** To obtain the context.
87      **
88      ** @return The context that has been previously set by
89      ** the set_session_context operation.
90      **/

91     public CCM_ManagedObjectProvider_Context
92     getContext()
93     {
94         return the_context_;
95     }
96     // ==================================================================
97
//
98
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
99
//
100
// ==================================================================
101
//
102
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
103
//
104
/**
105      ** Completes the component configuration.
106      **
107      ** @throws org.omg.Components.InvalidConfiguration
108      ** Thrown if the configuration is invalid.
109      **/

110     public void
111     configuration_complete()
112     throws org.omg.Components.InvalidConfiguration
113     {
114         //
115
// DONE : implement !!!
116
//
117

118         elements = new java.util.Hashtable JavaDoc();
119         System.err.println(facade_name() + " configuration completed...");
120     }
121     // ==================================================================
122
//
123
// Methods for the OMG IDL Components::SessionComponent local interface.
124
//
125
// ==================================================================
126
//
127
// IDL:omg.org/Components/SessionComponent/set_session_context:1.0
128
//
129
/**
130      * Called by the container when the component session context will be fixed.
131      *
132      * @param context The session context.
133      *
134      * @throws org.omg.Components.CCMException
135      * Thrown if a system level error occured.
136      */

137     public void
138     set_session_context(org.omg.Components.SessionContext context)
139     throws org.omg.Components.CCMException
140     {
141         the_context_ = (CCM_ManagedObjectProvider_Context)context;
142     }
143     //
144
// IDL:omg.org/Components/SessionComponent/ccm_activate:1.0
145
//
146
/**
147      *
148      * Called by the container when the component will be activated.
149      *
150      * @throws org.omg.Components.CCMException
151      * Thrown if a system level error occured.
152      */

153     public void
154     ccm_activate()
155     throws org.omg.Components.CCMException
156     {
157         //
158
// Unused by actual OpenCCM containers
159
//
160
}
161     //
162
// IDL:omg.org/Components/SessionComponent/ccm_passivate:1.0
163
//
164
/**
165      *
166      * Called by the container when the component will be passivated.
167      *
168      * @throws org.omg.Components.CCMException
169      * Thrown if a system level error occured.
170      */

171     public void
172     ccm_passivate()
173     throws org.omg.Components.CCMException
174     {
175         //
176
// Unused by actual OpenCCM containers
177
//
178
}
179     //
180
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
181
//
182
/**
183      *
184      * Called by the container when the component will be removed.
185      *
186      * @throws org.omg.Components.CCMException
187      * Thrown if a system level error occured.
188      */

189     public void
190     ccm_remove()
191     throws org.omg.Components.CCMException
192     {
193         //
194
// TO DO: implement !!!
195
//
196
}
197     // ==================================================================
198
//
199
// Public methods for the CCM_ManagedObjectProvider local interface.
200
//
201
// ==================================================================
202
//
203
// IDL:coach.ist/itut_x780Components/CCM_ManagedObjectProvider/get_mgmt:1.0
204
//
205
/**
206      ** Implementation of the ::itut_x780Components::CCM_ManagedObjectProvider::get_mgmt operation.
207      **/

208     public ist.coach.itut_x780Components.CCM_ManagedObjectMgmt
209     get_mgmt()
210     {
211         return this;
212     }
213     //
214
// IDL:coach.ist/itut_x780Components/CCM_NamedComponent_Executor/facade_name:1.0
215
//
216
/**
217      ** Implementation of the ::itut_x780Components::CCM_NamedComponent_Executor::facade_name attribute as accessor operation.
218      **/

219     public java.lang.String JavaDoc
220     facade_name()
221     {
222         //
223
// DONE : implement
224
//
225
return _facade_name;
226     }
227
228     /**
229      ** Implementation of the ::itut_x780Components::CCM_NamedComponent_Executor::facade_name attribute as mutator operation.
230      **/

231     public void
232     facade_name(java.lang.String JavaDoc val)
233     {
234         //
235
// DONE : implement
236
//
237
if (val != null)
238             _facade_name = new String JavaDoc(val);
239     }
240     //
241
// IDL:/nameGet:1.0
242
//
243
/**
244      ** Implementation of the ManagedObject_F::nameGet operation.
245      **/

246     public NameComponent JavaDoc[] nameGet() {
247         return Utils.string2name(_facade_name);
248     }
249     //
250
// IDL:itu.intt/itut_x780/ManagedObject_F/objectClassGet:1.0
251
//
252
/**
253      ** Implementation of the ::itut_x780::ManagedObject_F::objectClassGet operation.
254      **/

255     public java.lang.String JavaDoc
256     objectClassGet(org.omg.CosNaming.NameComponent JavaDoc[] name)
257     throws intt.itu.itut_x780.ApplicationError
258     {
259         //
260
// DONE : implement
261
//
262
if ( ! elements.containsKey(Utils.name2string(name))) {
263             ApplicationErrorInfoTypeImpl error_code =
264                     new ApplicationErrorInfoTypeImpl();
265             error_code.error = new UIDType(
266                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
267                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
268             error_code.details = ExceptionMessages.not_exists_error;
269
270             throw new ApplicationError(error_code);
271         }
272         ManagedObjectValueType mo_value =
273             (ManagedObjectValueType) elements.get(Utils.name2string(name));
274         return mo_value.objectClass;
275     }
276     //
277
// IDL:itu.intt/itut_x780/ManagedObject_F/attributesGet:1.0
278
//
279
/**
280      ** Implementation of the ::itut_x780::ManagedObject_F::attributesGet operation.
281      **/

282     public intt.itu.itut_x780.ManagedObjectValueType
283     attributesGet(org.omg.CosNaming.NameComponent JavaDoc[] name,
284                 intt.itu.itut_x780.StringSetTypeHolder attributeNames)
285     throws intt.itu.itut_x780.ApplicationError
286     {
287         //
288
// DONE : implement
289
//
290
if ( ! elements.containsKey(Utils.name2string(name))) {
291             ApplicationErrorInfoTypeImpl error_code =
292                     new ApplicationErrorInfoTypeImpl();
293             error_code.error = new UIDType(
294                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
295                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
296             error_code.details = ExceptionMessages.not_exists_error;
297
298             throw new ApplicationError(error_code);
299         }
300         ManagedObjectValueType mo_value =
301             (ManagedObjectValueType) elements.get(Utils.name2string(name));
302         return mo_value;
303     }
304     //
305
// IDL:itu.intt/itut_x780/ManagedObject_F/packagesGet:1.0
306
//
307
/**
308      ** Implementation of the ::itut_x780::ManagedObject_F::packagesGet operation.
309      **/

310     public java.lang.String JavaDoc[]
311     packagesGet(org.omg.CosNaming.NameComponent JavaDoc[] name)
312     throws intt.itu.itut_x780.ApplicationError
313     {
314         //
315
// DONE : implement
316
//
317
if ( ! elements.containsKey(Utils.name2string(name))) {
318             ApplicationErrorInfoTypeImpl error_code =
319                     new ApplicationErrorInfoTypeImpl();
320             error_code.error = new UIDType(
321                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
322                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
323                 error_code.details = ExceptionMessages.not_exists_error;
324
325             throw new ApplicationError(error_code);
326         }
327         ManagedObjectValueType mo_value =
328             (ManagedObjectValueType) elements.get(Utils.name2string(name));
329         return mo_value.packages;
330     }
331     //
332
//
333
// IDL:itu.intt/itut_x780/ManagedObject_F/creationSourceGet:1.0
334
//
335
/**
336      ** Implementation of the ::itut_x780::ManagedObject_F::creationSourceGet operation.
337      **/

338     public intt.itu.itut_x780.SourceIndicatorType
339     creationSourceGet(org.omg.CosNaming.NameComponent JavaDoc[] name)
340     throws intt.itu.itut_x780.ApplicationError
341     {
342         //
343
// DONE : implement
344
//
345
if ( ! elements.containsKey(Utils.name2string(name))) {
346             ApplicationErrorInfoTypeImpl error_code =
347                     new ApplicationErrorInfoTypeImpl();
348             error_code.error = new UIDType(
349                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
350                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
351                 error_code.details = ExceptionMessages.not_exists_error;
352
353             throw new ApplicationError(error_code);
354         }
355         ManagedObjectValueType mo_value =
356             (ManagedObjectValueType) elements.get(Utils.name2string(name));
357         return mo_value.creationSource;
358     }
359     //
360
// IDL:itu.intt/itut_x780/ManagedObject_F/deletePolicyGet:1.0
361
//
362
/**
363      ** Implementation of the ::itut_x780::ManagedObject_F::deletePolicyGet operation.
364      **/

365     public short
366     deletePolicyGet(org.omg.CosNaming.NameComponent JavaDoc[] name)
367     throws intt.itu.itut_x780.ApplicationError
368     {
369         //
370
// DONE : implement
371
//
372

373         if ( ! elements.containsKey(Utils.name2string(name))) {
374             ApplicationErrorInfoTypeImpl error_code =
375                     new ApplicationErrorInfoTypeImpl();
376             error_code.error = new UIDType(
377                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
378                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
379                 error_code.details = ExceptionMessages.not_exists_error;
380
381             throw new ApplicationError(error_code);
382         }
383         ManagedObjectValueType mo_value =
384             (ManagedObjectValueType) elements.get(Utils.name2string(name));
385         return mo_value.deletePolicy;
386     }
387     //
388
// IDL:itu.intt/itut_x780/ManagedObject_F/destroy:1.0
389
//
390
/**
391      ** Implementation of the ::itut_x780::ManagedObject_F::destroy operation.
392      **/

393     public void
394     destroy(org.omg.CosNaming.NameComponent JavaDoc[] name)
395     throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.DeleteError
396     {
397         //
398
// DONE : implement
399
//
400
if ( ! elements.containsKey(Utils.name2string(name))) {
401             ApplicationErrorInfoTypeImpl error_code =
402                     new ApplicationErrorInfoTypeImpl();
403             error_code.error = new UIDType(
404                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
405                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
406                 error_code.details = ExceptionMessages.not_exists_error;
407
408             throw new ApplicationError(error_code);
409
410         }
411         ManagedObjectValueType mo_value =
412             (ManagedObjectValueType) elements.remove(Utils.name2string(name));
413         org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(),
414                     0,(short) 0,(short) 0);
415         the_context_.push_objectDeletion_alarm(new ObjectDeletionImpl(eventTime, name,
416                                         mo_value.objectClass,
417                                         getUniqueNotificationIdentifier(),
418                                         mo_value.creationSource,
419                                         new AttributeValueType[0]));
420     }
421     // ==================================================================
422
//
423
// Public methods for the ::itut_x780Components::CCM_ManagedObjectMgmt local interface.
424
//
425
// ==================================================================
426
//
427
// IDL:coach.ist/itut_x780Components/ManagedObjectMgmt/create:1.0
428
//
429
/**
430      ** Implementation of the ::itut_x780Components::ManagedObjectMgmt::create operation.
431      **/

432     public void
433     create(org.omg.CosNaming.NameComponent JavaDoc[] name,
434             String JavaDoc objectClass,
435             String JavaDoc[] packages,
436             short deletePolicy,
437             intt.itu.itut_x780.SourceIndicatorType sourceIndicator)
438     throws intt.itu.itut_x780.CreateError, intt.itu.itut_x780.ApplicationError
439     {
440         //
441
// DONE : implement
442
//
443
if (elements.containsKey(Utils.name2string(name))) {
444             System.err.println(Utils.name2string(name) + " already exists!");
445             CreateErrorInfoTypeImpl error_code = new CreateErrorInfoTypeImpl();
446             error_code.error = new UIDType(
447                 intt.itu.itut_x780.CreateErrorConst.moduleName.value,
448                 intt.itu.itut_x780.CreateErrorConst.duplicateName.value);
449
450             error_code.details = ExceptionMessages.already_exists_error;
451             throw new CreateError(error_code);
452         }
453         ManagedObjectValueTypeImpl value_type =
454                 new ManagedObjectValueTypeImpl(name, objectClass, packages,
455                         sourceIndicator, deletePolicy);
456
457         elements.put(Utils.name2string(name), value_type);
458
459         org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(),
460                     0,(short) 0,(short) 0);
461
462         //System.err.println("ManagedObjectProvider attempts to push object creation alarm...");
463
the_context_.push_objectCreation_alarm(new ObjectCreationImpl(eventTime, name,
464                                         objectClass,
465                                         getUniqueNotificationIdentifier(),
466                                         sourceIndicator,
467                                         new AttributeValueType[0]));
468
469     }
470
471
472     private int getUniqueNotificationIdentifier() {
473
474        notifId++;
475
476        return (notifId);
477    }
478
479 }
480
Popular Tags