1 26 27 package org.objectweb.openccm.plugins.transaction.deployment; 28 29 import org.objectweb.openccm.Deployment.CCMHomeLocal; 30 import org.omg.Components.CCMObject ; 31 import org.omg.CosTransactions.Coordinator ; 32 33 41 public class CCMHomeResourceImpl 42 extends org.omg.CORBA.LocalObject 43 implements CCMHomeResource 44 { 45 53 protected CCMHomeLocal the_home_; 54 55 58 protected Coordinator the_coordinator_; 59 60 64 protected CCMHomeListenerTransaction the_listener_; 65 66 70 protected ResourceManagerLocal the_resource_manager_; 71 72 75 protected org.objectweb.ccm.util.Vector objects_; 76 77 78 84 92 public 93 CCMHomeResourceImpl(CCMHomeListenerTransaction listener, 94 CCMHomeLocal home, 95 Coordinator coordinator, 96 ResourceManagerLocal manager) 97 { 98 the_home_ = home; 99 objects_ = new org.objectweb.ccm.util.Vector (); 100 register(listener, coordinator, manager); 101 } 102 103 protected void 109 register(CCMHomeListenerTransaction listener, 110 Coordinator coordinator, 111 ResourceManagerLocal resource_manager) 112 { 113 the_listener_ = listener; 114 the_coordinator_ = coordinator; 115 the_resource_manager_ = resource_manager; 116 117 the_listener_.add_resource(this); 118 the_resource_manager_.add_home(this); 119 } 120 121 122 protected void 123 unregister( ) 124 { 125 try { 126 the_coordinator_ = null ; 127 the_listener_.remove_resource(this); 128 the_resource_manager_.remove_home (this); 129 } catch ( org.omg.Components.RemoveFailure ex ) { } 130 } 131 132 133 137 protected void 138 commit_add () 139 { 140 for (int i = 0; i < objects_.size(); i++) { 141 CCMObject obj_ref = (CCMObject) objects_.elementAt(i) ; 142 } 144 } 145 146 150 protected void 151 removeItself() 152 { 153 unregister(); 154 } 155 156 162 175 public void 176 on_create (CCMObject ref) 177 { 178 objects_.addElement (ref); 179 } 180 181 189 public void 190 on_add (CCMObject ref ) 191 { 192 } 193 194 202 public void 203 on_remove (CCMObject ref) 204 { 205 } 206 207 214 public void 215 on_destroy () 216 { 217 } 218 219 233 public org.omg.CosTransactions.Vote 234 prepare() 235 throws org.omg.CosTransactions.HeuristicMixed, 236 org.omg.CosTransactions.HeuristicHazard 237 { 238 return org.omg.CosTransactions.Vote.VoteCommit; 239 } 240 241 248 public void 249 rollback() 250 throws org.omg.CosTransactions.HeuristicCommit, 251 org.omg.CosTransactions.HeuristicMixed, 252 org.omg.CosTransactions.HeuristicHazard 253 { 254 for (int i = 0; i < objects_.size(); i++) { 255 CCMObject obj_ref = (CCMObject) objects_.elementAt(i) ; 256 try { 257 obj_ref.remove(); 258 } catch (org.omg.Components.RemoveFailure ex) { } 259 } 260 removeItself(); 261 } 262 263 270 public void 271 commit() 272 throws org.omg.CosTransactions.NotPrepared, 273 org.omg.CosTransactions.HeuristicRollback, 274 org.omg.CosTransactions.HeuristicMixed, 275 org.omg.CosTransactions.HeuristicHazard 276 { 277 commit_add(); 278 removeItself(); 279 } 280 281 282 289 public void 290 commit_one_phase() 291 throws org.omg.CosTransactions.HeuristicHazard 292 { 293 commit_add(); 294 removeItself(); 295 } 296 297 298 305 public void 306 forget() 307 { 308 removeItself(); 309 } 310 311 312 326 public org.objectweb.openccm.Deployment.CCMHomeLocal 327 get_home() 328 { 329 return the_home_; 330 } 331 332 345 public Coordinator 346 coordinator() 347 { 348 return the_coordinator_; 349 } 350 } 351 352 353 354 355 | Popular Tags |