1 26 27 package org.objectweb.openccm.plugins.transaction.deployment; 28 29 import org.objectweb.openccm.Deployment.listener.simple.ComponentServerListenerSimple; 30 31 32 40 public class ComponentServerListenerTransaction 41 extends ComponentServerListenerSimple 42 { 43 51 protected org.objectweb.ccm.util.Vector resources_; 52 53 63 public 64 ComponentServerListenerTransaction() 65 { 66 resources_ = new org.objectweb.ccm.util.Vector (); 67 } 68 69 79 protected org.objectweb.openccm.Deployment.listener.ComponentServerListener 80 _new() 81 { 82 return new ComponentServerListenerTransaction(); 83 } 84 85 90 protected ComponentServerResource 91 get_resource() 92 { 93 try { 94 org.omg.CORBA.Object obj = org.objectweb.openccm.corba.TheORB.getORB().resolve_initial_references("TransactionCurrent"); 95 org.omg.CosTransactions.Current current = org.omg.CosTransactions.CurrentHelper.narrow( obj ); 96 org.omg.CosTransactions.Control control = current.get_control(); 97 if (control == null) return null ; 98 org.omg.CosTransactions.Coordinator coordinator = control.get_coordinator(); 99 ComponentServerResource resource = null; 100 101 for ( int i=0; i<resources_.size(); i++ ) { 102 resource = ( ComponentServerResource ) resources_.elementAt( i ); 103 104 if ( coordinator.is_same_transaction(resource.coordinator()) ) 105 return resource; 106 } 107 return new ComponentServerResourceImpl(this, 108 source_, 109 coordinator, 110 TheTransactionManager.get_instance().getCurrent()); 111 } catch ( Exception ex ) { 112 return null; 113 } 114 } 115 116 122 public void 123 add_resource(ComponentServerResource resource) 124 { 125 resources_.addElement( resource ); 126 } 127 128 public void 129 remove_resource(ComponentServerResource resource) 130 { 131 resources_.removeElement( resource ); 132 } 133 134 147 public org.objectweb.openccm.Deployment.listener.ContainerListener 148 get_sub_listener() 149 { 150 return new ContainerListenerTransaction(); 151 } 152 153 166 public void 167 on_create (org.omg.Components.Deployment.Container ref) 168 { 169 delegate_.on_create (ref); 170 ComponentServerResource resource = get_resource(); 171 if (resource == null) 172 super.on_create(ref); 173 else 174 resource.on_create(ref); 175 } 176 } 177 178 179 180 181 182 183 | Popular Tags |