1 26 27 package org.objectweb.openccm.plugins.transaction.deployment; 28 29 import org.objectweb.openccm.Deployment.listener.simple.ContainerListenerSimple; 30 31 39 public class ContainerListenerTransaction 40 extends ContainerListenerSimple 41 { 42 50 protected org.objectweb.ccm.util.Vector resources_; 51 52 62 public 63 ContainerListenerTransaction() 64 { 65 resources_ = new org.objectweb.ccm.util.Vector (); 66 } 67 68 78 protected org.objectweb.openccm.Deployment.listener.ContainerListener 79 _new() 80 { 81 return new ContainerListenerTransaction(); 82 } 83 84 89 protected ContainerResource 90 get_resource() 91 { 92 try { 93 org.omg.CORBA.Object obj = org.objectweb.openccm.corba.TheORB.getORB() 94 .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 ContainerResource resource = null; 100 101 for ( int i=0; i<resources_.size(); i++ ) { 102 resource = ( ContainerResource ) resources_.elementAt( i ); 103 104 if ( coordinator.is_same_transaction( resource.coordinator() ) ) 105 return resource; 106 } 107 return new ContainerResourceImpl(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(ContainerResource resource) 124 { 125 resources_.addElement( resource ); 126 } 127 128 public void 129 remove_resource(ContainerResource resource) 130 { 131 resources_.addElement( resource ); 132 } 133 134 135 148 public void 149 on_create (org.omg.Components.CCMHome ref) 150 { 151 delegate_.on_create (ref); 152 ContainerResource resource = get_resource(); 153 if (resource == null) 154 super.on_create(ref); 155 else 156 resource.on_create(ref); 157 } 158 159 160 173 public org.objectweb.openccm.Deployment.listener.CCMHomeListener 174 get_sub_listener() 175 { 176 return new CCMHomeListenerTransaction(); 177 } 178 } 179 180 181 | Popular Tags |