1 26 27 package org.objectweb.openccm.plugins.transaction.deployment; 28 29 import org.objectweb.openccm.Deployment.ComponentServerLocal; 30 import org.omg.Components.Deployment.Container ; 31 import org.omg.CosTransactions.Coordinator ; 32 33 41 public class ComponentServerResourceImpl 42 extends org.omg.CORBA.LocalObject 43 implements ComponentServerResource 44 { 45 53 protected ComponentServerLocal the_component_server_; 54 55 58 protected Coordinator the_coordinator_; 59 60 63 protected ComponentServerListenerTransaction the_listener_; 64 65 68 protected ResourceManagerLocal the_resource_manager_; 69 70 73 protected org.objectweb.ccm.util.Vector containers_; 74 75 76 89 public 90 ComponentServerResourceImpl(ComponentServerListenerTransaction listener, 91 ComponentServerLocal component_server, 92 Coordinator coordinator, 93 ResourceManagerLocal resource_manager) 94 { 95 the_component_server_ = component_server; 96 containers_ = new org.objectweb.ccm.util.Vector(); 97 register(listener, coordinator, resource_manager); 98 } 99 100 protected void 106 register(ComponentServerListenerTransaction listener, 107 Coordinator coordinator, 108 ResourceManagerLocal resource_manager) 109 { 110 the_listener_ = listener; 111 the_coordinator_ = coordinator; 112 the_resource_manager_ = resource_manager; 113 114 the_listener_.add_resource(this); 115 the_resource_manager_.add_component_server(this); 116 } 117 118 119 protected void 120 unregister( ) 121 { 122 try { 123 the_coordinator_ = null; 124 the_listener_.remove_resource(this); 125 the_resource_manager_.remove_component_server(this); 126 } catch ( org.omg.Components.RemoveFailure ex ) { } 127 } 128 129 130 134 protected void 135 commit_add () 136 { 137 for (int i=0 ; i<containers_.size() ; i++) { 138 Container cont_ref = (Container) containers_.elementAt(i); 139 the_component_server_.add_container (cont_ref); 140 } 141 } 142 143 147 protected void 148 removeItself() 149 { 150 unregister(); 151 } 152 153 159 172 public void 173 on_create (Container cont_ref) 174 { 175 containers_.addElement (cont_ref); 176 } 177 178 186 public void 187 on_add (Container cont_ref) {} 188 189 197 public void 198 on_remove (Container cont_ref) {} 199 200 207 public void 208 on_destroy () {} 209 210 223 public org.omg.CosTransactions.Vote 224 prepare() 225 throws org.omg.CosTransactions.HeuristicMixed, 226 org.omg.CosTransactions.HeuristicHazard 227 { 228 return org.omg.CosTransactions.Vote.VoteCommit; 229 } 230 231 238 public void 239 rollback() 240 throws org.omg.CosTransactions.HeuristicCommit, 241 org.omg.CosTransactions.HeuristicMixed, 242 org.omg.CosTransactions.HeuristicHazard 243 { 244 for (int i=0 ; i < containers_.size() ; i++) { 245 Container cont_ref = (Container) containers_.elementAt(i); 246 try { 247 cont_ref.remove(); 248 } catch (org.omg.Components.RemoveFailure ex) { } 249 } 250 removeItself(); 251 } 252 253 260 public void 261 commit() 262 throws org.omg.CosTransactions.NotPrepared, 263 org.omg.CosTransactions.HeuristicRollback, 264 org.omg.CosTransactions.HeuristicMixed, 265 org.omg.CosTransactions.HeuristicHazard 266 { 267 commit_add (); 268 removeItself(); 269 } 270 271 278 public void 279 commit_one_phase() 280 throws org.omg.CosTransactions.HeuristicHazard 281 { 282 commit_add (); 283 removeItself(); 284 } 285 286 293 public void 294 forget() 295 { 296 removeItself(); 297 } 298 299 312 public org.objectweb.openccm.Deployment.ComponentServerLocal 313 get_component_server () 314 { 315 return the_component_server_; 316 } 317 318 333 346 public Coordinator 347 coordinator() 348 { 349 return the_coordinator_; 350 } 351 } 352 353 354 355 356 357 358 359 360 361 362 | Popular Tags |