1 28 29 30 package org.objectweb.corba.runtime; 31 32 import org.omg.PortableServer.THREAD_POLICY_ID ; 34 import org.omg.PortableServer.ThreadPolicy ; 35 import org.omg.PortableServer.ThreadPolicyValue ; 36 import org.omg.PortableServer.ThreadPolicyValueHelper; 37 import org.omg.PortableServer.LIFESPAN_POLICY_ID ; 38 import org.omg.PortableServer.LifespanPolicy ; 39 import org.omg.PortableServer.LifespanPolicyValue ; 40 import org.omg.PortableServer.LifespanPolicyValueHelper; 41 import org.omg.PortableServer.ID_UNIQUENESS_POLICY_ID ; 42 import org.omg.PortableServer.IdUniquenessPolicy ; 43 import org.omg.PortableServer.IdUniquenessPolicyValue ; 44 import org.omg.PortableServer.IdUniquenessPolicyValueHelper; 45 import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID ; 46 import org.omg.PortableServer.IdAssignmentPolicy ; 47 import org.omg.PortableServer.IdAssignmentPolicyValue ; 48 import org.omg.PortableServer.IdAssignmentPolicyValueHelper; 49 import org.omg.PortableServer.IMPLICIT_ACTIVATION_POLICY_ID ; 50 import org.omg.PortableServer.ImplicitActivationPolicy ; 51 import org.omg.PortableServer.ImplicitActivationPolicyValue ; 52 import org.omg.PortableServer.ImplicitActivationPolicyValueHelper; 53 import org.omg.PortableServer.SERVANT_RETENTION_POLICY_ID ; 54 import org.omg.PortableServer.ServantRetentionPolicy ; 55 import org.omg.PortableServer.ServantRetentionPolicyValue ; 56 import org.omg.PortableServer.ServantRetentionPolicyValueHelper; 57 import org.omg.PortableServer.REQUEST_PROCESSING_POLICY_ID ; 58 import org.omg.PortableServer.RequestProcessingPolicy ; 59 import org.omg.PortableServer.RequestProcessingPolicyValue ; 60 import org.omg.PortableServer.RequestProcessingPolicyValueHelper; 61 62 65 public class POAFactoryImpl 66 extends org.omg.CORBA.LocalObject 67 implements SystemFactory 68 { 69 static private String _class_name = "POAFactoryImpl"; 71 72 protected 74 POAFactoryImpl() 75 { 76 } 77 78 82 static public SystemFactory 83 create_factory() 84 { 85 return new POAFactoryImpl(); 86 } 87 88 92 static private org.omg.CORBA.Policy [] 93 checkPolicies(org.omg.CORBA.Policy [] pols, 94 ORBService orbs) 95 { 96 final String opname = "checkPolicies"; 97 98 java.util.Vector rpols = new java.util.Vector (); 109 110 boolean threadingpol_set = false; 111 boolean lifespanpol_set = false; 112 boolean iduniqpol_set = false; 113 boolean idassignpol_set = false; 114 boolean servantretpol_set = false; 115 boolean reqprocpol_set = false; 116 boolean implactpol_set = false; 117 for (int i=0;i<pols.length;i++) { 118 if (pols[i].policy_type()==THREAD_POLICY_ID.value) { 119 rpols.add(pols[i]); 121 threadingpol_set = true; 122 } 123 else if (pols[i].policy_type()==LIFESPAN_POLICY_ID.value) { 124 rpols.add(pols[i]); 126 lifespanpol_set = true; 127 } 128 else if (pols[i].policy_type()==ID_UNIQUENESS_POLICY_ID.value) { 129 rpols.add(pols[i]); 131 iduniqpol_set = true; 132 } 133 else if (pols[i].policy_type()==ID_ASSIGNMENT_POLICY_ID.value) { 134 IdAssignmentPolicy idassignpol = (IdAssignmentPolicy )pols[i]; 136 if (idassignpol.value()!=IdAssignmentPolicyValue.USER_ID) { 137 final String msg = "IGNORE (was expecting USER_ID)"; 139 TheLogger.debug(_class_name, opname, msg); 140 } else { 141 rpols.add(pols[i]); 142 idassignpol_set = true; 143 } 144 } 145 else if (pols[i].policy_type()==IMPLICIT_ACTIVATION_POLICY_ID.value) { 146 ImplicitActivationPolicy implactpol = (ImplicitActivationPolicy )pols[i]; 148 if (implactpol.value()!=ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION) { 149 final String msg = "IGNORE (was expecting NO_IMPLICIT_ACTIVATION)"; 151 TheLogger.debug(_class_name, opname, msg); 152 } else { 153 rpols.add(pols[i]); 154 implactpol_set = true; 155 } 156 } 157 else if (pols[i].policy_type()==SERVANT_RETENTION_POLICY_ID.value) { 158 ServantRetentionPolicy servantretpol = (ServantRetentionPolicy )pols[i]; 160 if (servantretpol.value()!=ServantRetentionPolicyValue.RETAIN) { 161 final String msg = "IGNORE (was expecting RETAIN)"; 163 TheLogger.debug(_class_name, opname, msg); 164 } else { 165 rpols.add(pols[i]); 166 servantretpol_set = true; 167 } 168 } 169 else if (pols[i].policy_type()==REQUEST_PROCESSING_POLICY_ID.value) { 170 RequestProcessingPolicy reqprocpol = (RequestProcessingPolicy )pols[i]; 172 if (reqprocpol.value()!=RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY) { 173 final String msg = "IGNORE (was expecting USE_ACTIVE_OBJECT_MAP_ONLY)"; 175 TheLogger.debug(_class_name, opname, msg); 176 } else { 177 rpols.add(pols[i]); 178 reqprocpol_set = true; 179 } 180 } 181 else { 182 rpols.add(pols[i]); 183 } 184 } 185 186 org.omg.CORBA.Policy pol = null; 188 org.omg.CORBA.Any value = null; 189 if (!threadingpol_set) { 190 value = orbs.create_any(); 191 ThreadPolicyValueHelper.insert(value, ThreadPolicyValue.ORB_CTRL_MODEL); 192 pol = orbs.create_policy(THREAD_POLICY_ID.value, value); 193 rpols.add(pol); 194 } 195 196 if (!lifespanpol_set) { 197 value = orbs.create_any(); 198 LifespanPolicyValueHelper.insert(value, LifespanPolicyValue.TRANSIENT); 199 pol = orbs.create_policy(LIFESPAN_POLICY_ID.value, value); 200 rpols.add(pol); 201 } 202 203 if (!iduniqpol_set) { 204 value = orbs.create_any(); 205 IdUniquenessPolicyValueHelper.insert(value, IdUniquenessPolicyValue.UNIQUE_ID); 206 pol = orbs.create_policy(ID_UNIQUENESS_POLICY_ID.value, value); 207 rpols.add(pol); 208 } 209 210 if (!idassignpol_set) { 211 value = orbs.create_any(); 212 IdAssignmentPolicyValueHelper.insert(value, IdAssignmentPolicyValue.USER_ID); 213 pol = orbs.create_policy(ID_ASSIGNMENT_POLICY_ID.value, value); 214 rpols.add(pol); 215 } 216 217 if (!servantretpol_set) { 218 value = orbs.create_any(); 219 ServantRetentionPolicyValueHelper.insert(value, ServantRetentionPolicyValue.RETAIN); 220 pol = orbs.create_policy(SERVANT_RETENTION_POLICY_ID.value, value); 221 rpols.add(pol); 222 } 223 224 if (!reqprocpol_set) { 225 value = orbs.create_any(); 226 RequestProcessingPolicyValueHelper.insert(value, RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY); 227 pol = orbs.create_policy(REQUEST_PROCESSING_POLICY_ID.value, value); 228 rpols.add(pol); 229 } 230 231 if (!implactpol_set) { 232 value = orbs.create_any(); 233 ImplicitActivationPolicyValueHelper.insert(value, ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION); 234 pol = orbs.create_policy(IMPLICIT_ACTIVATION_POLICY_ID.value, value); 235 rpols.add(pol); 236 } 237 238 return (org.omg.CORBA.Policy [])rpols.toArray(new org.omg.CORBA.Policy [0]); 239 } 240 241 static private org.omg.PortableServer.POA 242 createPOA(POAConfiguration cfg) 243 { 244 ORBService orbs = cfg.orb_service(); 246 247 org.omg.PortableServer.POA root_poa = null; 249 root_poa = org.omg.PortableServer.POAHelper.narrow(orbs.resolve_initial_references("RootPOA")); 250 251 org.omg.PortableServer.POA poa = null; 253 org.omg.CORBA.Policy [] rpols = checkPolicies(cfg.policies(), orbs); 254 String name = ""; 255 try { 256 if ((cfg.name()==null) || (cfg.name().equals(""))) { 258 name = Double.toString(Math.random()); 260 } 261 else { 262 name = cfg.name(); 263 } 264 265 poa = root_poa.create_POA(name, null, rpols); 266 poa.the_POAManager().activate(); 267 } catch (Exception ex) { 268 final String opname = "createPOA"; 269 TheLogger.error(_class_name, opname, "FAILED", ex); 270 return null; 271 } 272 273 return poa; 274 } 275 276 280 final public SystemComponent 281 create_system_component(SystemConfiguration cfg) 282 { 283 POAConfiguration poacfg = (POAConfiguration)cfg; 284 285 org.omg.PortableServer.POA poa = createPOA(poacfg); 287 288 POAServiceImpl poas = new POAServiceImpl(poa); 290 291 poas.system_configuration_complete(poacfg); 293 294 return poas; 295 } 296 } 297 | Popular Tags |