KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_x780Components > ManagedObjectProviderComposition > ManagedObjectProviderImpl


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

28
29 package ist.coach.itut_x780Components.ManagedObjectProviderComposition;
30
31 import ist.coach.coachEmfCommon.Utils;
32 import ist.coach.coachEmfCommon.ExceptionMessages;
33
34
35 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl;
36 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
37 import ist.coach.coachEmfCommon.ManagedObjectValueTypeImpl;
38
39 import ist.coach.coachEmfCommon.ObjectDeletionImpl;
40
41 import intt.itu.itut_x780.ManagedObjectValueType;
42 import intt.itu.itut_x780.ApplicationError;
43 import intt.itu.itut_x780.AttributeValueType;
44 import intt.itu.itut_x780.UIDType;
45
46 import org.omg.CosNaming.NameComponent JavaDoc;
47 import ist.coach.coachEmfServices.EmfBasicLog.*;
48
49 /**
50  * This is the CIDL-based implementation of the
51  * OMG IDL3 IDL:coach.ist/itut_x780Components/ManagedObjectProvider:1.0 component type.
52  *
53  * @author OpenCCM CIF_Jimpl Compiler.
54  */

55 public class ManagedObjectProviderImpl
56      extends ist.coach.itut_x780Components.ManagedObjectProviderComposition.ManagedObjectProvider_impl
57 {
58     // ==================================================================
59
//
60
// Internal states.
61
//
62
// ==================================================================
63
private String JavaDoc _facade_name;
64
65     protected static java.util.Hashtable JavaDoc elements;
66     private static int notifId = 100;
67     private BasicLog logSupport;
68
69
70     /**
71      ** Context reference.
72      **/

73
74     // ==================================================================
75
//
76
// Constructors.
77
//
78
// ==================================================================
79

80     public ManagedObjectProviderImpl()
81     {}
82     // ==================================================================
83
//
84
// Public methods.
85
//
86
// ===================================================================
87

88     // ==================================================================
89
//
90
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
91
//
92
// ==================================================================
93
//
94
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
95
//
96
/**
97      ** Completes the component configuration.
98      **
99      ** @throws org.omg.Components.InvalidConfiguration
100      ** Thrown if the configuration is invalid.
101      **/

102     public void
103     configuration_complete()
104     throws org.omg.Components.InvalidConfiguration
105     {
106         //
107
// DONE : implement !!!
108
//
109

110         elements = new java.util.Hashtable JavaDoc();
111         if ((logSupport = get_context().get_connection_basic_log()) == null)
112             throw new org.omg.Components.InvalidConfiguration();
113         System.err.println(facade_name() + " configuration completed...");
114     }
115     // ==================================================================
116
//
117
// Methods for the OMG IDL Components::SessionComponent local interface.
118
//
119
// ==================================================================
120
//
121
// IDL:omg.org/Components/SessionComponent/set_session_context:1.0
122
//
123
/**
124      * Called by the container when the component session context will be fixed.
125      *
126      * @param context The session context.
127      *
128      * @throws org.omg.Components.CCMException
129      * Thrown if a system level error occured.
130      */

131
132     //
133
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
134
//
135
/**
136      *
137      * Called by the container when the component will be removed.
138      *
139      * @throws org.omg.Components.CCMException
140      * Thrown if a system level error occured.
141      */

142     public void
143     ccm_remove()
144     throws org.omg.Components.CCMException
145     {
146         Utils.pretty_log(logSupport, "System Monitor", facade_name(), (short) LogSeverity._Info,
147           "ManagedObject monitoring is shutting down...");
148         //
149
// TO DO: implement !!!
150
//
151
}
152     // ==================================================================
153
//
154
// Public methods for the CCM_ManagedObjectProvider local interface.
155
//
156
// ==================================================================
157
//
158
// IDL:coach.ist/itut_x780Components/CCM_ManagedObjectProvider/get_mgmt:1.0
159
//
160
/**
161      ** Implementation of the ::itut_x780Components::CCM_ManagedObjectProvider::get_mgmt operation.
162      **/

163     //public ist.coach.itut_x780Components.CCM_ManagedObjectMgmt
164
//get_mgmt()
165
//{
166
// return this;
167
//}
168
// ==================================================================
169
//
170
// Methods.
171
//
172
// ==================================================================
173

174     /**
175      * Implementation of the ::itut_x780Components::CCM_NamedComponent_Executor::facade_name attribute as accessor operation.
176      */

177     public String JavaDoc
178     facade_name()
179     {
180         //
181
// DONE : implement
182
//
183
return _facade_name;
184     }
185
186     /**
187      * Implementation of the ::itut_x780Components::CCM_NamedComponent_Executor::facade_name attribute as mutator operation.
188      */

189     public void
190     facade_name(String JavaDoc facade_name)
191     {
192         //
193
// DONE : implement
194
//
195
if (facade_name != null)
196             _facade_name = new String JavaDoc(facade_name);
197     }
198
199     /**
200      * Implementation of the ::itut_x780::ManagedObject_F::nameGet operation.
201      */

202     public org.omg.CosNaming.NameComponent JavaDoc[]
203     nameGet()
204     {
205         //
206
// DOÍÅ : Implement
207
//
208
return Utils.string2name(_facade_name);
209     }
210
211     /**
212      * Implementation of the ::itut_x780::ManagedObject_F::objectClassGet operation.
213      */

214     public String JavaDoc
215     objectClassGet(org.omg.CosNaming.NameComponent JavaDoc[] name)
216     throws intt.itu.itut_x780.ApplicationError
217     {
218         //
219
// DONE : implement
220
//
221
if ( ! elements.containsKey(Utils.name2string(name))) {
222             ApplicationErrorInfoTypeImpl error_code =
223                     new ApplicationErrorInfoTypeImpl();
224             error_code.error = new UIDType(
225                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
226                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
227             error_code.details = ExceptionMessages.not_exists_error;
228
229             throw new ApplicationError(error_code);
230         }
231         ManagedObjectValueType mo_value =
232             (ManagedObjectValueType) elements.get(Utils.name2string(name));
233         return mo_value.objectClass;
234     }
235
236     /**
237      * Implementation of the ::itut_x780::ManagedObject_F::attributesGet operation.
238      */

239     public intt.itu.itut_x780.ManagedObjectValueType
240     attributesGet(org.omg.CosNaming.NameComponent JavaDoc[] name, intt.itu.itut_x780.StringSetTypeHolder attributeNames)
241     throws intt.itu.itut_x780.ApplicationError
242     {
243         //
244
// DONE : implement
245
//
246
if ( ! elements.containsKey(Utils.name2string(name))) {
247             ApplicationErrorInfoTypeImpl error_code =
248                     new ApplicationErrorInfoTypeImpl();
249             error_code.error = new UIDType(
250                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
251                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
252             error_code.details = ExceptionMessages.not_exists_error;
253
254             throw new ApplicationError(error_code);
255         }
256         ManagedObjectValueType mo_value =
257             (ManagedObjectValueType) elements.get(Utils.name2string(name));
258 // TESTING LOG
259
//org.omg.CORBA.Any record, ist.coach.coachEmfServices.EmfBasicLog.NVPair[] nv)
260

261 /***************************
262         System.err.println("ManagedObjectProvider> Proceeding to invoke the Log Service");
263         try {
264           logSupport.flush();
265         }
266         catch(Exception e) {
267             System.err.println("ManagedObjectProvider> flush " + e.getMessage());
268         }
269         System.err.println("ManagedObjectProvider> Log Service call returned");
270         System.err.println("ManagedObjectProvider> Log Service records: " +
271           logSupport.get_n_records());
272 ***************************/

273         Utils.pretty_log(logSupport, Utils.name2string(name), objectClassGet(name), (short) LogSeverity._Info,
274           "attributesGet successfully finished");
275
276         //System.err.println("ManagedObjectProvider> Log Service invoked ok: " +
277
// logSupport.get_n_records());
278

279 //END OF TESTING
280
return mo_value;
281     }
282
283     /**
284      * Implementation of the ::itut_x780::ManagedObject_F::packagesGet operation.
285      */

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

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

336     public short
337     deletePolicyGet(org.omg.CosNaming.NameComponent JavaDoc[] name)
338     throws intt.itu.itut_x780.ApplicationError
339     {
340         //
341
// DONE : implement
342
//
343

344         if ( ! elements.containsKey(Utils.name2string(name))) {
345             ApplicationErrorInfoTypeImpl error_code =
346                     new ApplicationErrorInfoTypeImpl();
347             error_code.error = new UIDType(
348                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
349                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
350                 error_code.details = ExceptionMessages.not_exists_error;
351
352             throw new ApplicationError(error_code);
353         }
354         ManagedObjectValueType mo_value =
355             (ManagedObjectValueType) elements.get(Utils.name2string(name));
356         return mo_value.deletePolicy;
357     }
358
359     /**
360      * Implementation of the ::itut_x780::ManagedObject_F::destroy operation.
361      */

362     public void
363     destroy(org.omg.CosNaming.NameComponent JavaDoc[] name)
364     throws intt.itu.itut_x780.ApplicationError,
365                intt.itu.itut_x780.DeleteError
366     {
367         //
368
// DONE : implement
369
//
370
if ( ! elements.containsKey(Utils.name2string(name))) {
371             ApplicationErrorInfoTypeImpl error_code =
372                     new ApplicationErrorInfoTypeImpl();
373             error_code.error = new UIDType(
374                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
375                 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value);
376                 error_code.details = ExceptionMessages.not_exists_error;
377
378             throw new ApplicationError(error_code);
379
380         }
381         ManagedObjectValueType mo_value = null;
382         synchronized(elements) {
383             mo_value =
384             (ManagedObjectValueType) elements.remove(Utils.name2string(name));
385         }
386         org.omg.TimeBase.UtcT eventTime = new org.omg.TimeBase.UtcT(System.currentTimeMillis(),
387                     0,(short) 0,(short) 0);
388         get_context().push_objectDeletion_alarm(new ObjectDeletionImpl(eventTime, name,
389                                         mo_value.objectClass,
390                                         getUniqueNotificationIdentifier(),
391                                         mo_value.creationSource,
392                                         new AttributeValueType[0]));
393
394         Utils.pretty_log(logSupport, Utils.name2string(name), mo_value.objectClass, (short) LogSeverity._Info,
395          "Object successfully removed");
396     }
397
398     synchronized static int getUniqueNotificationIdentifier() {
399
400         notifId++;
401
402        return (notifId);
403    }
404 }
405
Popular Tags