1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class ServiceInitInfoImpl 38 extends org.omg.CORBA.LocalObject 39 implements org.coach.ECA.ServiceInitInfo 40 { 41 private String _class_name = "ServiceInitInfoImpl"; 43 private ORBService _orb_service; 44 private java.util.Hashtable _orb_inits; private java.util.Hashtable _value_factories; private java.util.Hashtable _policy_factories; private java.util.Hashtable _services; private java.util.Hashtable _initial_references; private java.util.Hashtable _stringified_initial_references; 51 public 52 ServiceInitInfoImpl(ServiceImpl[] services, 53 CORBAServiceRef[] degenservices) 54 { 55 _orb_service = null; 56 _orb_inits = new java.util.Hashtable (); 57 _value_factories = new java.util.Hashtable (); 58 _policy_factories = new java.util.Hashtable (); 59 _services = new java.util.Hashtable (); 60 _initial_references = new java.util.Hashtable (); 61 _stringified_initial_references = new java.util.Hashtable (); 62 63 CORBAServiceRef csref = null; 64 for (int i=0;i<services.length;i++) { 65 csref = services[i].getCorbaServiceRef(); 66 if (csref!=null) { 67 if (csref.initial_reference!=null) { 68 _initial_references.put(csref.orb_registration_name, csref.initial_reference); 69 } 70 else { 71 _stringified_initial_references.put(csref.orb_registration_name, csref.stringified_initial_reference); 72 } 73 } 74 75 76 _services.put(services[i].service_id(), services[i]); 77 } 78 79 for (int i=0;i<degenservices.length;i++) { 80 csref = degenservices[i]; 81 if (csref.initial_reference!=null) { 82 _initial_references.put(csref.orb_registration_name, csref.initial_reference); 83 } 84 else { 85 _stringified_initial_references.put(csref.orb_registration_name, csref.stringified_initial_reference); 86 } 87 } 88 } 89 90 94 final public void 95 setORBService(ORBService orbs) 96 { 97 _orb_service = orbs; 98 } 99 100 final public ORBConfiguration 101 getORBConfiguration() 102 { 103 String [] inits = (String [])_orb_inits.values().toArray(new String [0]); 105 106 ValueFactory[] vfacts = (ValueFactory[])_value_factories.values().toArray(new ValueFactory[0]); 108 109 String [] names = (String [])_initial_references.keySet().toArray(new String [0]); 111 org.omg.CORBA.Object [] refs = (org.omg.CORBA.Object [])_initial_references.values().toArray(new org.omg.CORBA.Object [0]); 112 InitialReference[] irefs = new InitialReference[names.length]; 113 114 for (int i=0;i<names.length;i++) { 115 irefs[i] = new InitialReference(); 116 irefs[i].name = names[i]; 117 irefs[i].ref = refs[i]; 118 } 119 120 names = (String [])_stringified_initial_references.keySet().toArray(new String [0]); 122 String [] srefs = (String [])_stringified_initial_references.values().toArray(new String [0]); 123 StringifiedInitialReference[] sirefs = new StringifiedInitialReference[names.length]; 124 125 for (int i=0;i<names.length;i++) { 126 sirefs[i] = new StringifiedInitialReference(); 127 sirefs[i].name = names[i]; 128 sirefs[i].ref = srefs[i]; 129 } 130 131 return new ORBConfigurationImpl(inits, vfacts, irefs, sirefs); 132 } 133 134 138 final public org.omg.CORBA.Object 139 resolve_initial_references(String name) 140 { 141 143 org.omg.CORBA.Object ref = (org.omg.CORBA.Object )_initial_references.get(name); 148 if (ref!=null) { 149 return ref; 150 } 151 152 if (_orb_service==null) { 154 final String opname = "resolve_initial_references"; 156 final String msg = "IGNORE (operation can not be called in pre_install)"; 157 TheLogger.debug(_class_name, opname, msg); 158 return null; 159 } 160 161 return _orb_service.resolve_initial_references(name); 162 } 163 164 final public org.omg.CORBA.Current 165 get_current(String cname) 166 { 167 169 if (_orb_service==null) { 171 final String opname = "get_current"; 172 final String msg = "IGNORE (operation can not be called in pre_install)"; 173 TheLogger.debug(_class_name, opname, msg); 174 return null; 175 } 176 177 return org.omg.CORBA.CurrentHelper.narrow(_orb_service.resolve_initial_references(cname)); 178 } 179 180 final public void 181 register_orb_initializer(String sid, String orbinit) 182 { 183 ServiceImpl sinst = (ServiceImpl)_services.get(sid); 185 186 sinst.setORBInitializer(orbinit); 188 189 _orb_inits.put(sid, orbinit); 191 } 192 193 final public void 194 register_service_internal(String sid, String internal_id, 195 org.omg.CORBA.Object internal) 196 { 197 ServiceImpl sinst = (ServiceImpl)_services.get(sid); 199 200 sinst.addServiceInternal(internal_id, internal); 202 } 203 204 final public void 205 register_controller_factory(String sid, 206 org.coach.ECA.CallControllerFactory fact) 207 { 208 ServiceImpl sinst = (ServiceImpl)_services.get(sid); 210 211 sinst.setCallControllerFactory(fact); 213 } 214 215 final public void 216 register_value_factory(String sid, String typeid, 217 org.omg.CORBA.portable.ValueFactory fact) 218 { 219 222 ValueFactory vfact = new ValueFactoryImpl(typeid, fact); 224 225 _value_factories.put(sid, vfact); 227 } 228 229 final public void 230 register_policy_factory(String sid, String ptype, 231 org.coach.ECA.PolicyFactory fact) 232 { 233 ServiceImpl sinst = (ServiceImpl)_services.get(sid); 235 236 sinst.addPolicyFactory(ptype, fact); 238 } 239 } 240 | Popular Tags |