1 21 package ist.coach.itut_m3120Components; 22 23 import org.omg.CosNaming.NameComponent ; 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 43 public class ManagedElementFactoryProviderMonolithicImpl 44 extends org.omg.CORBA.LocalObject 45 implements CCM_ManagedElementFactoryProvider, 46 org.omg.Components.SessionComponent 47 { 48 54 intt.itu.itut_q816.ContainmentComponent c_admin = null; 55 intt.itu.itut_q816.Containment c_query = null; 56 57 private static final String FACTORY_CLASS = "ManagedElementFactory"; 58 ManagedElementMgmt facade = null; 59 60 63 private CCM_ManagedElementFactoryProvider_Context the_context_; 64 72 public 73 ManagedElementFactoryProviderMonolithicImpl() 74 { 75 the_context_ = null; 76 } 77 93 public CCM_ManagedElementFactoryProvider_Context 94 getContext() 95 { 96 return the_context_; 97 } 98 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 intt.itu.itut_q816.FactoryFinderComponent factoryfinder_admin = 128 the_context_.get_connection_factoryfinder_admin(); 129 130 org.omg.CORBA.Object 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 e) { 143 System.err.println("ManagedElementFactory has problems retrieving CCM component"); 144 } 145 146 System.err.println("ManagedElementFactoryProvider configuration completed..."); 147 } 148 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 180 public void 181 ccm_activate() 182 throws org.omg.Components.CCMException 183 { 184 } 188 198 public void 199 ccm_passivate() 200 throws org.omg.Components.CCMException 201 { 202 } 206 216 public void 217 ccm_remove() 218 throws org.omg.Components.CCMException 219 { 220 } 224 235 public org.omg.CosNaming.NameComponent [] 236 create(java.lang.String nameBinding, 237 org.omg.CosNaming.NameComponent [] superior, 238 java.lang.String reqID, 239 java.lang.String [] packageNameList, 240 intt.itu.itut_x780.AdministrativeStateType administrativeState, 241 java.lang.String userLabel, 242 java.lang.String vendorName, 243 java.lang.String version, 244 java.lang.String locationName) 245 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError 246 { 247 251 String nameBinding_str = "intt.itu.itut_m3120.NameBindings." + 252 nameBinding; 253 254 CreateBindingInfo info = CreateController.checkNameBinding(nameBinding_str); 255 256 String objectKind = info.objectKind; 257 short deletePolicy = info.deletePolicy; 258 259 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 String allocatedId = reqID; 273 if (reqID == null || reqID.length() == 0) { 274 275 org.omg.CosNaming.NameComponent [][] siblings = 276 c_query.getContained(superior); 277 278 allocatedId = CreateController.autoCreateId(siblings); 279 } 280 281 org.omg.CosNaming.NameComponent [] full_name = CreateController.createFullName( 283 superior, 284 allocatedId, 285 Utils.name2facade(facade.facade_name()), 286 objectKind); 287 288 String [] 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 [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 341 public org.omg.CosNaming.NameComponent [] 342 create_base(java.lang.String nameBinding, org.omg.CosNaming.NameComponent [] superior, java.lang.String reqId) 343 throws intt.itu.itut_x780.CreateError, intt.itu.itut_x780.ApplicationError 344 { 345 return null; 349 } 350 } 351 | Popular Tags |