KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_m3120Components > ManagedElementFactoryProviderMonolithicImpl


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_m3120Components;
22
23 import org.omg.CosNaming.NameComponent JavaDoc;
24
25 import ist.coach.coachEmfCommon.Utils;
26 import ist.coach.coachEmfCommon.CreateController;
27 import ist.coach.coachEmfCommon.CreateBindingInfo;
28 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl;
29 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
30 import ist.coach.coachEmfCommon.ExceptionMessages;
31
32 import intt.itu.itut_x780.UIDType;
33 import intt.itu.itut_x780.CreateError;
34 import intt.itu.itut_x780.ApplicationError;
35
36 import intt.itu.itut_m3120.conditionalPackages.*;
37 import intt.itu.itut_m3120.ManagedElementFactory;
38 import intt.itu.itut_m3120.ManagedElementFactoryHelper;
39 /**
40  ** Implementation skeleton class for the ::itut_m3120Components::ManagedElementFactoryProvider component.
41  ** Business operations MUST be completed !!!
42  **/

43 public class ManagedElementFactoryProviderMonolithicImpl
44        extends org.omg.CORBA.LocalObject JavaDoc
45        implements CCM_ManagedElementFactoryProvider,
46                   org.omg.Components.SessionComponent
47 {
48     // ==================================================================
49
//
50
// Internal State.
51
//
52
// ===================================================================
53
/* Business logic **/
54     intt.itu.itut_q816.ContainmentComponent c_admin = null;
55     intt.itu.itut_q816.Containment c_query = null;
56
57     private static final String JavaDoc FACTORY_CLASS = "ManagedElementFactory";
58     ManagedElementMgmt facade = null;
59
60     /**
61      ** Context reference.
62      **/

63     private CCM_ManagedElementFactoryProvider_Context the_context_;
64     // ==================================================================
65
//
66
// Constructor.
67
//
68
// ===================================================================
69
/**
70      ** The default constructor.
71      **/

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

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

112     public void
113     configuration_complete()
114     throws org.omg.Components.InvalidConfiguration
115     {
116         if ((facade = the_context_.get_connection_facade()) == null)
117             throw new org.omg.Components.InvalidConfiguration();
118
119         if ((c_admin = the_context_.get_connection_containment_admin()) == null)
120             throw new org.omg.Components.InvalidConfiguration();
121
122         if ((c_query = the_context_.get_connection_containment_query()) == null)
123             throw new org.omg.Components.InvalidConfiguration();
124
125             // If managers may create, then the factory must register to the
126
// factory finder service
127
intt.itu.itut_q816.FactoryFinderComponent factoryfinder_admin =
128             the_context_.get_connection_factoryfinder_admin();
129
130          org.omg.CORBA.Object JavaDoc myself_o;
131          ManagedElementFactory myself = null;
132
133         try {
134             myself_o = ((org.omg.Components.SessionContext) the_context_).get_CCM_object();
135             myself = ManagedElementFactoryHelper.narrow(myself_o);
136
137             factoryfinder_admin.register(FACTORY_CLASS, myself);
138         }
139         catch(intt.itu.itut_x780.ApplicationError ex) {
140             throw new org.omg.Components.InvalidConfiguration();
141         }
142         catch(Exception JavaDoc e) {
143             System.err.println("ManagedElementFactory has problems retrieving CCM component");
144         }
145
146         System.err.println("ManagedElementFactoryProvider configuration completed...");
147     }
148     // ==================================================================
149
//
150
// Methods for the OMG IDL Components::SessionComponent local interface.
151
//
152
// ==================================================================
153
//
154
// IDL:omg.org/Components/SessionComponent/set_session_context:1.0
155
//
156
/**
157      * Called by the container when the component session context will be fixed.
158      *
159      * @param context The session context.
160      *
161      * @throws org.omg.Components.CCMException
162      * Thrown if a system level error occured.
163      */

164     public void
165     set_session_context(org.omg.Components.SessionContext context)
166     throws org.omg.Components.CCMException
167     {
168         the_context_ = (CCM_ManagedElementFactoryProvider_Context)context;
169     }
170     //
171
// IDL:omg.org/Components/SessionComponent/ccm_activate:1.0
172
//
173
/**
174      *
175      * Called by the container when the component will be activated.
176      *
177      * @throws org.omg.Components.CCMException
178      * Thrown if a system level error occured.
179      */

180     public void
181     ccm_activate()
182     throws org.omg.Components.CCMException
183     {
184         //
185
// Unused by actual OpenCCM containers
186
//
187
}
188     //
189
// IDL:omg.org/Components/SessionComponent/ccm_passivate:1.0
190
//
191
/**
192      *
193      * Called by the container when the component will be passivated.
194      *
195      * @throws org.omg.Components.CCMException
196      * Thrown if a system level error occured.
197      */

198     public void
199     ccm_passivate()
200     throws org.omg.Components.CCMException
201     {
202         //
203
// Unused by actual OpenCCM containers
204
//
205
}
206     //
207
// IDL:omg.org/Components/SessionComponent/ccm_remove:1.0
208
//
209
/**
210      *
211      * Called by the container when the component will be removed.
212      *
213      * @throws org.omg.Components.CCMException
214      * Thrown if a system level error occured.
215      */

216     public void
217     ccm_remove()
218     throws org.omg.Components.CCMException
219     {
220         //
221
// TO DO: implement !!!
222
//
223
}
224     // ==================================================================
225
//
226
// Public methods for the CCM_ManagedElementFactoryProvider local interface.
227
//
228
// ==================================================================
229
//
230
// IDL:itu.intt/itut_m3120/ManagedElementFactory/create:1.0
231
//
232
/**
233      ** Implementation of the ::itut_m3120::ManagedElementFactory::create operation.
234      **/

235     public org.omg.CosNaming.NameComponent JavaDoc[]
236     create(java.lang.String JavaDoc nameBinding,
237         org.omg.CosNaming.NameComponent JavaDoc[] superior,
238         java.lang.String JavaDoc reqID,
239         java.lang.String JavaDoc[] packageNameList,
240         intt.itu.itut_x780.AdministrativeStateType administrativeState,
241         java.lang.String JavaDoc userLabel,
242         java.lang.String JavaDoc vendorName,
243         java.lang.String JavaDoc version,
244         java.lang.String JavaDoc locationName)
245     throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError
246     {
247         //
248
// DONE : implement
249
//
250

251         String JavaDoc nameBinding_str = "intt.itu.itut_m3120.NameBindings." +
252                 nameBinding;
253
254         CreateBindingInfo info = CreateController.checkNameBinding(nameBinding_str);
255
256         String JavaDoc objectKind = info.objectKind;
257         short deletePolicy = info.deletePolicy;
258
259         // Check if the parent exists
260
if (! c_query.exists(superior)) {
261             ApplicationErrorInfoTypeImpl error_code = new ApplicationErrorInfoTypeImpl();
262             error_code.error = new UIDType(
263                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
264                 intt.itu.itut_x780.ApplicationErrorConst.objectNotFound.value);
265
266             error_code.details = Utils.name2string(superior) +
267                             ExceptionMessages.parent_object_error;
268
269             throw new ApplicationError(error_code);
270         }
271                 // The system must have the capability of auto-naming objects
272
String JavaDoc allocatedId = reqID;
273         if (reqID == null || reqID.length() == 0) {
274
275             org.omg.CosNaming.NameComponent JavaDoc[][] siblings =
276                 c_query.getContained(superior);
277
278                 allocatedId = CreateController.autoCreateId(siblings);
279         }
280
281         // Construct the name of the new object
282
org.omg.CosNaming.NameComponent JavaDoc[] full_name = CreateController.createFullName(
283                     superior,
284                     allocatedId,
285                     Utils.name2facade(facade.facade_name()),
286                     objectKind);
287
288         // Decide the conditional packages that are supported.
289
String JavaDoc [] supportedConditionalPackages = packageNameList;
290          if (packageNameList.length == 0) {
291
292             System.err.println("No packages are specified." +
293                 "Trying to determine supported packages...");
294
295             if (vendorName.equalsIgnoreCase("Linux") ||
296                 vendorName.equalsIgnoreCase("RedHat Linux") ||
297                 vendorName.equalsIgnoreCase("RedHat")) {
298
299                 System.err.println("ManagedElementFactoryProvider>Found linux System...");
300
301                 System.err.println("supported packages:");
302                 System.err.println("\t" + locationNamePackageType.value);
303                 System.err.println("\t" + userLabelPackageType.value);
304                 System.err.println("\t" + vendorNamePackageType.value);
305                 System.err.println("\t" + versionPackageType.value);
306
307                 supportedConditionalPackages = new String JavaDoc[4];
308
309                 supportedConditionalPackages[0] = locationNamePackageType.value;
310                 supportedConditionalPackages[1] = userLabelPackageType.value;
311                 supportedConditionalPackages[2] = vendorNamePackageType.value;
312                 supportedConditionalPackages[3] = versionPackageType.value;
313             }
314         }
315         else {
316             System.err.println("ManagedElementFactory;create> " +
317             " will not determine supported conditional Packages," +
318                 " because Manager already specified them.");
319         }
320         facade.create(full_name, objectKind, supportedConditionalPackages, deletePolicy,
321                     intt.itu.itut_x780.SourceIndicatorType.managementOperation,
322                     administrativeState,
323                     userLabel,
324                     vendorName,
325                     version,
326                     locationName);
327
328
329         c_admin.addName(full_name, superior);
330         System.err.println("ManagedElementFactory>Registered " +
331           Utils.name2string(full_name) + " to the containment service");
332
333         return full_name;
334     }
335     //
336
// IDL:itu.intt/itut_x780/ManagedObjectFactory/create_base:1.0
337
//
338
/**
339      ** Implementation of the ::itut_x780::ManagedObjectFactory::create_base operation.
340      **/

341     public org.omg.CosNaming.NameComponent JavaDoc[]
342     create_base(java.lang.String JavaDoc nameBinding, org.omg.CosNaming.NameComponent JavaDoc[] superior, java.lang.String JavaDoc reqId)
343     throws intt.itu.itut_x780.CreateError, intt.itu.itut_x780.ApplicationError
344     {
345         //
346
// TODO : implement
347
//
348
return null;
349     }
350 }
351
Popular Tags