1 26 27 package org.objectweb.openccm.Containers; 28 29 37 38 public class RootPCAImpl 39 extends PCAImpl 40 { 41 47 50 protected org.objectweb.openccm.Containers.SystemHomeFinder home_finder_; 51 52 58 62 public 63 RootPCAImpl(org.objectweb.openccm.Containers.SystemHomeFinder home_finder) 64 { 65 super("RootPCA", null); 66 home_finder_ = home_finder; 67 init(); 68 } 69 70 76 79 protected void 80 init() 81 { 82 org.omg.CORBA.Policy [] policies = new org.omg.CORBA.Policy [7]; 83 org.omg.PortableServer.POA rootPOA = org.objectweb.openccm.corba.TheRootPOA.getRootPOA(); 84 85 policies[0] = rootPOA.create_thread_policy(org.omg.PortableServer.ThreadPolicyValue.ORB_CTRL_MODEL); 87 policies[1] = rootPOA.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT); 88 policies[2] = rootPOA.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID); 89 policies[3] = rootPOA.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.SYSTEM_ID); 90 policies[4] = rootPOA.create_implicit_activation_policy( 91 org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION); 92 policies[5] = rootPOA.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN); 93 policies[6] = rootPOA.create_request_processing_policy( 94 org.omg.PortableServer.RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY); 95 96 try 97 { 98 String name = java.lang.Long.toString(java.lang.System.currentTimeMillis()); 100 the_poa_ = rootPOA.create_POA(name, null, policies); 101 the_poa_.the_POAManager().activate(); 102 } 103 catch(org.omg.PortableServer.POAPackage.InvalidPolicy ex) 104 { 105 throw new Error ("Problem with CORBA policies !!!"); 107 } 108 catch(org.omg.PortableServer.POAPackage.AdapterAlreadyExists ex) 109 { 110 throw new Error ("RootPCA already exists !!!"); 112 } 113 catch(org.omg.PortableServer.POAManagerPackage.AdapterInactive ex) 114 { 115 throw new Error ("RootPCA already exists !!!"); 117 } 118 } 119 120 126 132 public org.omg.Components.CCMHome 133 activate_home(HomeServant servant) 134 { 135 org.omg.Components.CCMHome ref = null; 136 try 137 { 138 org.objectweb.openccm.Containers.PCA comp_pca = null; 139 HomeExecutorBase home = servant.the_home_executor(); 140 141 java.lang.String home_name = home._the_home_uid().replace('/', 'x'); 143 144 org.objectweb.openccm.Containers.PCAPolicy[] policies = null; 146 147 if(servant.the_component_configuration() == null) { 148 policies = new org.objectweb.openccm.Containers.PCAPolicy[0]; 149 } else { 150 policies = servant.the_component_configuration().create_PCAPolicies( 151 home._the_component_uid(), 152 home_finder_); 153 } 154 comp_pca = create_PCA(home_name, policies); 155 156 servant.the_PCA(comp_pca); 158 159 java.lang.String home_uid = home._the_home_uid(); 161 Interceptor inter = home._get_interceptor(home_uid); 162 163 org.objectweb.openccm.Containers.CallContext context = new HomeCallContext(servant, home_uid); 165 inter._call_context(context); 166 inter._delegate((java.lang.Object )home); 167 168 byte[] oid = the_poa_.activate_object((org.omg.PortableServer.Servant )inter); 170 ref = org.omg.Components.CCMHomeHelper.narrow(the_poa_.id_to_reference(oid)); 171 servant.the_home_ref(ref); 172 173 180 } 181 catch(org.objectweb.openccm.Containers.CreationFailed ex) 182 { 183 throw new java.lang.Error ("Error while activating home"); 185 } 186 catch(org.omg.PortableServer.POAPackage.ServantAlreadyActive ex) 187 { 188 throw new java.lang.Error ("Error while activating home"); 190 } 191 catch(org.omg.PortableServer.POAPackage.WrongPolicy ex) 192 { 193 throw new java.lang.Error ("Error while activating home"); 195 } 196 catch(org.omg.PortableServer.POAPackage.ObjectNotActive ex) 197 { 198 throw new java.lang.Error ("Error while activating home"); 200 } 201 202 return ref; 203 } 204 205 211 public void 212 deactivate_home(HomeServant servant) 213 { 214 try { 215 229 230 the_poa_.deactivate_object(the_poa_.reference_to_id(servant.the_home_ref())); 232 233 } catch (org.omg.PortableServer.POAPackage.WrongAdapter ex) { 234 throw new java.lang.Error ("Error while deactivating home"); 236 } catch (org.omg.PortableServer.POAPackage.WrongPolicy ex) { 237 throw new java.lang.Error ("Error while deactivating home"); 239 } catch (org.omg.PortableServer.POAPackage.ObjectNotActive ex) { 240 throw new java.lang.Error ("Error while deactivating home"); 242 } 243 } 244 } 245 | Popular Tags |