KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > itut_m3120Components > ManagedElementFactoryProviderComposition > ManagedElementFactoryProviderImpl


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_m3120Components.ManagedElementFactoryProviderComposition;
30
31 import org.omg.CosNaming.NameComponent JavaDoc;
32
33 import ist.coach.coachEmfCommon.Utils;
34 import ist.coach.coachEmfCommon.CreateController;
35 import ist.coach.coachEmfCommon.CreateBindingInfo;
36 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl;
37 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl;
38 import ist.coach.coachEmfCommon.ExceptionMessages;
39
40 import ist.coach.itut_m3120Components.ManagedElementMgmt;
41 import intt.itu.itut_x780.UIDType;
42 import intt.itu.itut_x780.CreateError;
43 import intt.itu.itut_x780.ApplicationError;
44
45 import intt.itu.itut_m3120.conditionalPackages.*;
46 import intt.itu.itut_m3120.ManagedElementFactory;
47 import intt.itu.itut_m3120.ManagedElementFactoryHelper;
48
49 import ist.coach.coachEmfServices.EmfBasicLog.*;
50 /**
51  * This is the CIDL-based implementation of the
52  * OMG IDL3 IDL:coach.ist/itut_m3120Components/ManagedElementFactoryProvider:1.0 component type.
53  *
54  * @author OpenCCM CIF_Jimpl Compiler.
55  */

56 public class ManagedElementFactoryProviderImpl
57      extends ist.coach.itut_m3120Components.ManagedElementFactoryProviderComposition.ManagedElementFactoryProvider_impl
58 {
59     // ==================================================================
60
//
61
// Internal states.
62
//
63
// ==================================================================
64
/* Business logic **/
65     intt.itu.itut_q816.ContainmentComponent c_admin = null;
66     intt.itu.itut_q816.Containment c_query = null;
67     private BasicLog logSupport;
68
69     private static final String JavaDoc FACTORY_CLASS = "ManagedElementFactory";
70     ManagedElementMgmt facade = null;
71
72     // ==================================================================
73
//
74
// Constructors.
75
//
76
// ==================================================================
77

78     public ManagedElementFactoryProviderImpl()
79     {
80     }
81     // ==================================================================
82
//
83
// Methods for the OMG IDL Components::EnterpriseComponent local interface.
84
//
85
// ==================================================================
86
//
87
// IDL:omg.org/Components/EnterpriseComponent/configuration_complete:1.0
88
//
89
/**
90      ** Completes the component configuration.
91      **
92      ** @throws org.omg.Components.InvalidConfiguration
93      ** Thrown if the configuration is invalid.
94      **/

95     public void
96     configuration_complete()
97     throws org.omg.Components.InvalidConfiguration
98     {
99         if ((facade = get_context().get_connection_facade()) == null)
100             throw new org.omg.Components.InvalidConfiguration();
101
102         if ((c_admin = get_context().get_connection_containment_admin()) == null)
103             throw new org.omg.Components.InvalidConfiguration();
104
105         if ((c_query = get_context().get_connection_containment_query()) == null)
106             throw new org.omg.Components.InvalidConfiguration();
107
108         if ((logSupport = get_context().get_connection_basic_log()) == null)
109             throw new org.omg.Components.InvalidConfiguration();
110
111             // If managers may create, then the factory must register to the
112
// factory finder service
113
intt.itu.itut_q816.FactoryFinderComponent factoryfinder_admin =
114             get_context().get_connection_factoryfinder_admin();
115
116          org.omg.CORBA.Object JavaDoc myself_o;
117          ManagedElementFactory myself = null;
118
119         try {
120             myself_o = ((org.omg.Components.SessionContext) get_context()).get_CCM_object();
121             myself = ManagedElementFactoryHelper.narrow(myself_o);
122
123             factoryfinder_admin.register(FACTORY_CLASS, myself);
124         }
125         catch(intt.itu.itut_x780.ApplicationError ex) {
126             throw new org.omg.Components.InvalidConfiguration();
127         }
128         catch(Exception JavaDoc e) {
129             System.err.println("ManagedElementFactory has problems retrieving CCM component");
130         }
131
132         System.err.println("ManagedElementFactoryProvider configuration completed...");
133     }
134     // ==================================================================
135
//
136
// Methods.
137
//
138
// ==================================================================
139

140     /**
141      * Implementation of the ::itut_m3120::ManagedElementFactory::create operation.
142      */

143     public org.omg.CosNaming.NameComponent JavaDoc[]
144     create(java.lang.String JavaDoc nameBinding,
145         org.omg.CosNaming.NameComponent JavaDoc[] superior,
146         java.lang.String JavaDoc reqID,
147         java.lang.String JavaDoc[] packageNameList,
148         intt.itu.itut_x780.AdministrativeStateType administrativeState,
149         java.lang.String JavaDoc userLabel,
150         java.lang.String JavaDoc vendorName,
151         java.lang.String JavaDoc version,
152         java.lang.String JavaDoc locationName)
153     throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError
154     {
155         //
156
// DONE : implement
157
//
158

159         String JavaDoc nameBinding_str = "intt.itu.itut_m3120.NameBindings." +
160                 nameBinding;
161
162         CreateBindingInfo info = CreateController.checkNameBinding(nameBinding_str);
163
164         String JavaDoc objectKind = info.objectKind;
165         short deletePolicy = info.deletePolicy;
166
167         // Check if the parent exists
168
if (! c_query.exists(superior)) {
169             ApplicationErrorInfoTypeImpl error_code = new ApplicationErrorInfoTypeImpl();
170             error_code.error = new UIDType(
171                 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value,
172                 intt.itu.itut_x780.ApplicationErrorConst.objectNotFound.value);
173
174             error_code.details = Utils.name2string(superior) +
175                             ExceptionMessages.parent_object_error;
176
177             throw new ApplicationError(error_code);
178         }
179                 // The system must have the capability of auto-naming objects
180
String JavaDoc allocatedId = reqID;
181         if (reqID == null || reqID.length() == 0) {
182
183             org.omg.CosNaming.NameComponent JavaDoc[][] siblings =
184                 c_query.getContained(superior);
185
186                 allocatedId = CreateController.autoCreateId(siblings);
187         }
188
189         // Construct the name of the new object
190
org.omg.CosNaming.NameComponent JavaDoc[] full_name = CreateController.createFullName(
191                     superior,
192                     allocatedId,
193                     Utils.name2facade(facade.facade_name()),
194                     objectKind);
195
196         // Decide the conditional packages that are supported.
197
String JavaDoc [] supportedConditionalPackages = packageNameList;
198          if (packageNameList.length == 0) {
199
200             System.err.println("No packages are specified." +
201                 "Trying to determine supported packages...");
202
203             if (vendorName.equalsIgnoreCase("Linux") ||
204                 vendorName.equalsIgnoreCase("RedHat Linux") ||
205                 vendorName.equalsIgnoreCase("RedHat")) {
206
207                 System.err.println("ManagedElementFactoryProvider>Found linux System...");
208
209                 System.err.println("supported packages:");
210                 System.err.println("\t" + locationNamePackageType.value);
211                 System.err.println("\t" + userLabelPackageType.value);
212                 System.err.println("\t" + vendorNamePackageType.value);
213                 System.err.println("\t" + versionPackageType.value);
214
215                 supportedConditionalPackages = new String JavaDoc[4];
216
217                 supportedConditionalPackages[0] = locationNamePackageType.value;
218                 supportedConditionalPackages[1] = userLabelPackageType.value;
219                 supportedConditionalPackages[2] = vendorNamePackageType.value;
220                 supportedConditionalPackages[3] = versionPackageType.value;
221             }
222         }
223         else {
224             System.err.println("ManagedElementFactory;create> " +
225             " will not determine supported conditional Packages," +
226                 " because Manager already specified them.");
227         }
228         Utils.pretty_log(logSupport, FACTORY_CLASS, "Factory", (short) LogSeverity._Info,
229           "proceed to create " + Utils.name2string(full_name));
230         facade.create(full_name, objectKind, supportedConditionalPackages, deletePolicy,
231                     intt.itu.itut_x780.SourceIndicatorType.managementOperation,
232                     administrativeState,
233                     userLabel,
234                     vendorName,
235                     version,
236                     locationName);
237
238
239         c_admin.addName(full_name, superior);
240         System.err.println("ManagedElementFactory>Registered " +
241           Utils.name2string(full_name) + " to the containment service");
242
243         Utils.pretty_log(logSupport, FACTORY_CLASS, "Factory", (short) LogSeverity._Info,
244           "successfully created " + Utils.name2string(full_name));
245         return full_name;
246     }
247
248     /**
249      * Implementation of the ::itut_x780::ManagedObjectFactory::create_base operation.
250      */

251     public org.omg.CosNaming.NameComponent JavaDoc[]
252     create_base(String JavaDoc nameBinding, org.omg.CosNaming.NameComponent JavaDoc[] superior, String JavaDoc reqId)
253     throws intt.itu.itut_x780.CreateError,
254
255            intt.itu.itut_x780.ApplicationError
256     {
257         //
258
// TODO : Implement
259
//
260
return null;
261     }
262
263 }
264
Popular Tags