1 22 package org.jboss.tutorial.consumer_deployment_descriptor.bean; 23 24 import java.util.HashMap ; 25 import java.util.Map ; 26 import org.jboss.annotation.JndiInject; 27 import javax.ejb.Remote ; 28 import javax.ejb.Stateless ; 29 import javax.ejb.TransactionAttribute ; 30 import javax.ejb.TransactionAttributeType ; 31 import org.jboss.ejb3.mdb.ProducerManager; 32 import org.jboss.ejb3.mdb.ProducerObject; 33 34 41 @Stateless 42 @Remote (Tester.class) 43 public class TesterBean implements Tester 44 { 45 private ExampleProducerXA xa; 46 private ProducerManager xaManager; 47 48 @JndiInject(jndiName="org.jboss.tutorial.consumer_deployment_descriptor.bean.ExampleProducerXA") 49 public void setXa(ExampleProducerXA xa) 50 { 51 this.xa = xa; 52 this.xaManager = ((ProducerObject)xa).getProducerManager(); 53 } 54 55 private ExampleProducer local; 56 private ProducerManager localManager; 57 58 @JndiInject(jndiName="org.jboss.tutorial.consumer_deployment_descriptor.bean.ExampleProducerLocal") 59 public void setLocal(ExampleProducer local) 60 { 61 this.local = local; 62 this.localManager = ((ProducerObject)local).getProducerManager(); 63 } 64 65 @TransactionAttribute (TransactionAttributeType.REQUIRED) 66 public void testXA() throws Exception 67 { 68 69 xaManager.connect(); 70 xa.method1("testXA", 1); 71 Map <String , String > map = new HashMap <String , String >(); 72 map.put("hello", "world"); 73 map.put("great", "ejb3"); 74 xa.method2("testXA2", map); 75 System.out.println("end TESTXA **"); 76 xaManager.close(); 77 } 78 79 public void testLocal() throws Exception 80 { 81 82 localManager.connect(); 83 local.method1("testLocal", 1); 84 Map <String , String > map = new HashMap <String , String >(); 85 map.put("hello", "world"); 86 map.put("great", "ejb3"); 87 local.method2("testLocal2", map); 88 localManager.close(); 89 } 90 91 } 92 | Popular Tags |