1 21 package ist.coach.itut_q816Components; 22 23 import intt.itu.itut_x780.UIDType; 24 import intt.itu.itut_x780.ApplicationError; 25 import intt.itu.itut_q816.FactoryInfoType; 26 import intt.itu.itut_x780.ManagedObjectFactory; 27 import intt.itu.itut_x780.ManagedObjectFactoryHelper; 28 29 import org.omg.CosNaming.NameComponent ; 30 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 31 35 public class FactoryFinderProviderMonolithicImpl 36 extends org.omg.CORBA.LocalObject 37 implements CCM_FactoryFinderProvider, 38 intt.itu.itut_q816.CCM_FactoryFinder, 39 intt.itu.itut_q816.CCM_FactoryFinderComponent, 40 org.omg.Components.SessionComponent 41 { 42 50 private CCM_FactoryFinderProvider_Context the_context_; 51 52 53 java.util.Hashtable factories = null; 54 62 public 63 FactoryFinderProviderMonolithicImpl() 64 { 65 the_context_ = null; 66 factories = new java.util.Hashtable (); 67 } 68 84 public CCM_FactoryFinderProvider_Context 85 getContext() 86 { 87 return the_context_; 88 } 89 103 public void 104 configuration_complete() 105 throws org.omg.Components.InvalidConfiguration 106 { 107 System.err.println("FactoryFinderProvider configuration completed..."); 111 112 } 113 129 public void 130 set_session_context(org.omg.Components.SessionContext context) 131 throws org.omg.Components.CCMException 132 { 133 the_context_ = (CCM_FactoryFinderProvider_Context)context; 134 } 135 145 public void 146 ccm_activate() 147 throws org.omg.Components.CCMException 148 { 149 } 153 163 public void 164 ccm_passivate() 165 throws org.omg.Components.CCMException 166 { 167 } 171 181 public void 182 ccm_remove() 183 throws org.omg.Components.CCMException 184 { 185 } 189 200 public intt.itu.itut_q816.CCM_FactoryFinder 201 get_query() 202 { 203 return this; 204 } 205 211 public intt.itu.itut_q816.CCM_FactoryFinderComponent 212 get_admin() 213 { 214 return this; 215 } 216 227 public intt.itu.itut_x780.ManagedObjectFactory 228 find(java.lang.String factoryClass) 229 throws intt.itu.itut_q816.FactoryNotFound, intt.itu.itut_x780.ApplicationError 230 { 231 if (! factories.containsKey(factoryClass)) 235 throw new intt.itu.itut_q816.FactoryNotFound(factoryClass + 236 " has not been registered"); 237 238 FactoryInfoType f_info = 239 (FactoryInfoType) factories.get(factoryClass); 240 241 242 return f_info.factoryRef; 243 } 244 250 public intt.itu.itut_q816.FactoryInfoType[] 251 list() 252 throws intt.itu.itut_x780.ApplicationError 253 { 254 int f_size = factories.size(); 258 if (f_size <= 0) 259 return new FactoryInfoType[0]; 260 261 FactoryInfoType[] factories_list = 262 new FactoryInfoType[f_size]; 263 264 factories_list = 265 (FactoryInfoType[]) factories.values().toArray(factories_list); 266 267 return factories_list; 268 } 269 280 public void 281 register(java.lang.String factoryClass, 282 intt.itu.itut_x780.ManagedObjectFactory factoryRef) 283 throws intt.itu.itut_x780.ApplicationError 284 { 285 if (factoryClass == null || factoryClass.length() == 0) { 289 ApplicationErrorInfoTypeImpl error_code = 290 new ApplicationErrorInfoTypeImpl(); 291 error_code.error = new UIDType( 292 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 293 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 294 error_code.details = new String ("Factory class name is not specified!"); 295 296 throw new ApplicationError(error_code); 297 } 298 if (factoryRef == null) { 299 ApplicationErrorInfoTypeImpl error_code = 300 new ApplicationErrorInfoTypeImpl(); 301 error_code.error = new UIDType( 302 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 303 intt.itu.itut_x780.ApplicationErrorConst.invalidParameter.value); 304 error_code.details = new String ("Factory reference is not provided!"); 305 306 throw new ApplicationError(error_code); 307 } 308 309 FactoryInfoType factory_info = new FactoryInfoType(factoryClass, factoryRef); 310 factories.put(factoryClass, factory_info); 311 312 } 313 319 public void 320 unregister(java.lang.String factoryClass, intt.itu.itut_x780.ManagedObjectFactory factoryRef) 321 throws intt.itu.itut_q816.FactoryNotFound, intt.itu.itut_x780.ApplicationError 322 { 323 327 if (! factories.containsKey(factoryClass)) 328 throw new intt.itu.itut_q816.FactoryNotFound(factoryClass + 329 " has not been registered"); 330 331 factories.remove(factoryClass); 332 } 333 } 334 | Popular Tags |