1 28 29 package ist.coach.itut_m3120Components.ManagedElementFactoryProviderComposition; 30 31 import org.omg.CosNaming.NameComponent ; 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 56 public class ManagedElementFactoryProviderImpl 57 extends ist.coach.itut_m3120Components.ManagedElementFactoryProviderComposition.ManagedElementFactoryProvider_impl 58 { 59 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 FACTORY_CLASS = "ManagedElementFactory"; 70 ManagedElementMgmt facade = null; 71 72 78 public ManagedElementFactoryProviderImpl() 79 { 80 } 81 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 intt.itu.itut_q816.FactoryFinderComponent factoryfinder_admin = 114 get_context().get_connection_factoryfinder_admin(); 115 116 org.omg.CORBA.Object 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 e) { 129 System.err.println("ManagedElementFactory has problems retrieving CCM component"); 130 } 131 132 System.err.println("ManagedElementFactoryProvider configuration completed..."); 133 } 134 140 143 public org.omg.CosNaming.NameComponent [] 144 create(java.lang.String nameBinding, 145 org.omg.CosNaming.NameComponent [] superior, 146 java.lang.String reqID, 147 java.lang.String [] packageNameList, 148 intt.itu.itut_x780.AdministrativeStateType administrativeState, 149 java.lang.String userLabel, 150 java.lang.String vendorName, 151 java.lang.String version, 152 java.lang.String locationName) 153 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError 154 { 155 159 String nameBinding_str = "intt.itu.itut_m3120.NameBindings." + 160 nameBinding; 161 162 CreateBindingInfo info = CreateController.checkNameBinding(nameBinding_str); 163 164 String objectKind = info.objectKind; 165 short deletePolicy = info.deletePolicy; 166 167 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 String allocatedId = reqID; 181 if (reqID == null || reqID.length() == 0) { 182 183 org.omg.CosNaming.NameComponent [][] siblings = 184 c_query.getContained(superior); 185 186 allocatedId = CreateController.autoCreateId(siblings); 187 } 188 189 org.omg.CosNaming.NameComponent [] full_name = CreateController.createFullName( 191 superior, 192 allocatedId, 193 Utils.name2facade(facade.facade_name()), 194 objectKind); 195 196 String [] 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 [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 251 public org.omg.CosNaming.NameComponent [] 252 create_base(String nameBinding, org.omg.CosNaming.NameComponent [] superior, String reqId) 253 throws intt.itu.itut_x780.CreateError, 254 255 intt.itu.itut_x780.ApplicationError 256 { 257 return null; 261 } 262 263 } 264 | Popular Tags |