1 26 27 package org.objectweb.openccm.Containers; 28 29 37 38 public class PCAImpl 39 extends org.omg.CORBA.LocalObject 40 implements org.objectweb.openccm.Containers.PCA, 41 org.objectweb.openccm.Containers.PCAHooks 42 { 43 49 52 protected java.lang.String the_name_; 53 54 57 protected org.objectweb.openccm.Containers.PCA the_parent_; 58 59 62 protected org.objectweb.ccm.util.Vector children_ ; 63 64 67 protected org.objectweb.ccm.util.Vector policies_; 68 69 72 protected org.omg.PortableServer.POA the_poa_; 73 74 77 protected ServantLocatorImpl the_servant_locator_; 78 79 85 89 protected 90 PCAImpl(java.lang.String name, 91 org.objectweb.openccm.Containers.PCA parent) 92 { 93 the_name_ = name; 94 the_parent_ = parent; 95 the_poa_ = null; 96 the_servant_locator_ = null; 97 policies_ = new org.objectweb.ccm.util.Vector(); 98 children_ = new org.objectweb.ccm.util.Vector(); 99 } 100 101 107 113 public PCA 114 create_PCA(java.lang.String name, 115 org.objectweb.openccm.Containers.PCAPolicy[] policies) 116 throws org.objectweb.openccm.Containers.CreationFailed 117 { 118 PCAImpl pca_ = null; 119 try 120 { 121 pca_ = new PCAImpl(name, this); 123 124 org.omg.PortableServer.POA rootPOA = org.objectweb.openccm.corba.TheRootPOA.getRootPOA(); 126 pca_.policies_.add(rootPOA.create_thread_policy(org.omg.PortableServer.ThreadPolicyValue.ORB_CTRL_MODEL)); 127 pca_.policies_.add(rootPOA.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT)); 128 pca_.policies_.add(rootPOA.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID)); 129 pca_.policies_.add(rootPOA.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID)); 130 pca_.policies_.add(rootPOA.create_implicit_activation_policy( 131 org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION)); 132 pca_.policies_.add(rootPOA.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN)); 133 pca_.policies_.add(rootPOA.create_request_processing_policy( 134 org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER)); 135 136 pca_.the_servant_locator_ = new ServantLocatorImpl(); 138 139 for (int i=0;i<policies.length;i++) 141 policies[i].apply(pca_); 142 143 org.omg.CORBA.Policy [] corba_policies = (org.omg.CORBA.Policy [])pca_.policies_.toArray(new org.omg.CORBA.Policy [0]); 145 pca_.the_poa_ = the_poa_.create_POA(name, null, corba_policies); 146 pca_.the_servant_locator_.setPOA(pca_.the_poa_); 147 pca_.the_poa_.set_servant_manager(pca_.the_servant_locator_); 148 pca_.the_poa_.the_POAManager().activate(); 149 } 150 catch(org.omg.PortableServer.POAPackage.InvalidPolicy ex) 151 { 152 throw new org.objectweb.openccm.Containers.CreationFailed(ex.getMessage()); 153 } 154 catch(org.omg.PortableServer.POAPackage.AdapterAlreadyExists ex) 155 { 156 throw new org.objectweb.openccm.Containers.CreationFailed(ex.getMessage()); 157 } 158 catch(org.omg.PortableServer.POAPackage.WrongPolicy ex) 159 { 160 throw new org.objectweb.openccm.Containers.CreationFailed(ex.getMessage()); 161 } 162 catch(org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) 163 { 164 throw new org.objectweb.openccm.Containers.CreationFailed(ex.getMessage()); 165 } 166 167 children_.add(pca_); 168 return pca_; 169 } 170 171 177 public org.omg.Components.CCMObject 178 create_component_reference(HomeServant home_servant) 179 { 180 org.omg.Components.CCMObject ref = null; 181 ref = org.omg.Components.CCMObjectHelper.narrow(the_servant_locator_.createReference(home_servant)); 182 return ref; 183 } 184 185 191 public org.omg.Components.CCMObject 192 create_component_reference_with_instance(HomeServant home_servant, 193 org.omg.Components.EnterpriseComponent instance) 194 { 195 org.omg.Components.CCMObject ref = null; 196 ref = org.omg.Components.CCMObjectHelper.narrow(the_servant_locator_.createReference(home_servant, instance)); 197 return ref; 198 } 199 200 206 public org.omg.Components.CCMObject 207 find_component_reference_with_instance(HomeServant home_servant, 208 org.omg.Components.EnterpriseComponent instance) 209 { 210 org.omg.Components.CCMObject ref = null; 211 ref = org.omg.Components.CCMObjectHelper.narrow(the_servant_locator_.findReference(home_servant, instance)); 212 return ref; 213 } 214 215 221 public org.omg.Components.CCMObject 222 create_registered_component_reference(HomeServant home_servant, 223 org.omg.Components.PrimaryKeyBase key) 224 { 225 org.omg.Components.CCMObject ref = null; 226 ref = org.omg.Components.CCMObjectHelper.narrow(the_servant_locator_.createReference(home_servant, key)); 227 return ref; 228 } 229 230 236 public org.omg.Components.CCMHome 237 activate_home(HomeServant home) 238 { 239 throw new java.lang.Error ("Only the RootPCA can activate homes"); 240 } 241 242 248 public void 249 deactivate_home(HomeServant home) 250 { 251 throw new java.lang.Error ("Only the RootPCA can deactivate homes"); 252 } 253 254 260 public java.lang.String 261 the_name() 262 { 263 return the_name_; 264 } 265 266 272 public org.objectweb.openccm.Containers.PCA 273 the_parent() 274 { 275 return the_parent_; 276 } 277 278 284 public org.objectweb.openccm.Containers.PCA[] 285 children() 286 { 287 return (org.objectweb.openccm.Containers.PCA[])children_.toArray(new org.objectweb.openccm.Containers.PCA[0]); 288 } 289 290 296 302 public void 303 add_native_policy(NativePolicy policy) 304 { 305 policies_.add(policy); 306 } 307 } 308 | Popular Tags |