1 26 27 package org.objectweb.openccm.plugins.transaction.deployment; 28 29 import org.objectweb.openccm.Deployment.ContainerLocal; 30 import org.omg.Components.CCMHome; 31 import org.omg.CosTransactions.Coordinator; 32 33 41 public class ContainerResourceImpl 42 extends org.omg.CORBA.LocalObject 43 implements ContainerResource 44 { 45 53 protected ContainerLocal the_container_; 54 55 58 protected Coordinator the_coordinator_; 59 60 64 protected ContainerListenerTransaction the_listener_; 65 66 70 protected ResourceManagerLocal the_resource_manager_; 71 72 75 protected org.objectweb.ccm.util.Vector homes_; 76 77 78 90 public 91 ContainerResourceImpl (ContainerListenerTransaction listener, 92 ContainerLocal container, 93 Coordinator coordinator, 94 ResourceManagerLocal resource_manager) 95 { 96 the_container_ = container ; 97 homes_ = new org.objectweb.ccm.util.Vector(); 98 register(listener, coordinator, resource_manager); 99 } 100 101 protected void 107 register(ContainerListenerTransaction listener, 108 Coordinator coordinator, 109 ResourceManagerLocal resource_manager) 110 { 111 the_listener_ = listener; 112 the_coordinator_ = coordinator; 113 the_resource_manager_ = resource_manager; 114 115 the_listener_.add_resource(this); 116 the_resource_manager_.add_container(this); 117 } 118 119 120 protected void 121 unregister( ) 122 { 123 try { 124 the_coordinator_ = null ; 125 the_listener_.remove_resource(this); 126 the_resource_manager_.remove_container (this); 127 } catch ( org.omg.Components.RemoveFailure ex ) { } 128 } 129 130 131 132 136 protected void 137 commit_add () 138 { 139 for (int i=0 ; i < homes_.size() ; i++) { 140 CCMHome home_ref = (CCMHome) homes_.elementAt(i) ; 141 the_container_.add_home (home_ref); 142 } 143 } 144 145 149 protected void 150 removeItself() 151 { 152 unregister(); 153 } 154 155 161 167 175 public void 176 on_create (CCMHome ref) 177 { 178 homes_.addElement (ref); 179 } 180 181 189 public void 190 on_add (CCMHome ref) { } 191 192 200 public void 201 on_remove (CCMHome ref) { } 202 203 210 public void 211 on_destroy () { } 212 213 226 public org.omg.CosTransactions.Vote 227 prepare() 228 throws org.omg.CosTransactions.HeuristicMixed, 229 org.omg.CosTransactions.HeuristicHazard 230 { 231 return org.omg.CosTransactions.Vote.VoteCommit; 232 } 233 234 241 public void 242 rollback() 243 throws org.omg.CosTransactions.HeuristicCommit, 244 org.omg.CosTransactions.HeuristicMixed, 245 org.omg.CosTransactions.HeuristicHazard 246 { 247 for (int i=0 ; i<homes_.size() ; i++) { 248 CCMHome home_ref = (CCMHome) homes_.elementAt(i) ; 249 try { 250 home_ref.remove_home(); 251 } catch (org.omg.Components.RemoveFailure ex) { } 252 } 253 removeItself(); 254 } 255 256 263 public void 264 commit() 265 throws org.omg.CosTransactions.NotPrepared, 266 org.omg.CosTransactions.HeuristicRollback, 267 org.omg.CosTransactions.HeuristicMixed, 268 org.omg.CosTransactions.HeuristicHazard 269 { 270 commit_add (); 271 removeItself(); 272 } 273 274 281 public void 282 commit_one_phase() 283 throws org.omg.CosTransactions.HeuristicHazard 284 { 285 commit_add (); 286 removeItself(); 287 } 288 289 296 public void 297 forget() 298 { 299 removeItself(); 300 } 301 302 315 public org.objectweb.openccm.Deployment.ContainerLocal 316 get_container () 317 { 318 return the_container_; 319 } 320 321 334 public Coordinator 335 coordinator() 336 { 337 return the_coordinator_; 338 } 339 } 340 341 342 343 344 345 346 347 | Popular Tags |