1 22 package org.jboss.test.dtm.ejb; 23 24 import java.rmi.RemoteException ; 25 26 import javax.ejb.EJBException ; 27 import javax.naming.Context ; 28 import javax.naming.InitialContext ; 29 import javax.rmi.PortableRemoteObject ; 30 31 import org.jboss.logging.Logger; 32 import org.jboss.test.dtm.interfaces.Worker; 33 import org.jboss.test.dtm.interfaces.WorkerHome; 34 import org.jboss.test.util.ejb.SessionSupport; 35 36 42 public class PassThroughBean 43 extends SessionSupport 44 { 45 private static transient Logger log = 46 Logger.getLogger(PassThroughBean.class); 47 48 private String testName; 49 private Worker workerSession; 50 51 public void ejbCreate(String name) 52 { 53 this.testName = name; 54 log = Logger.getLogger(PassThroughBean.class.getName() + "#" + testName); 55 log.debug("ejbCreate(" + name + "), ctx=" + sessionCtx); 56 initWorker(); 57 } 58 59 public void setBalances(int value1, int value2) 60 { 61 try 62 { 63 workerSession.setBalances(value1, value2); 64 } 65 catch (RemoteException e) 66 { 67 throw new EJBException (e); 68 } 69 } 70 71 public int[] getBalances() 72 { 73 try 74 { 75 return workerSession.getBalances(); 76 } 77 catch (RemoteException e) 78 { 79 throw new EJBException (e); 80 } 81 } 82 83 public void addToBalances(int value) 84 { 85 try 86 { 87 workerSession.addToBalances(value); 88 } 89 catch (RemoteException e) 90 { 91 throw new EJBException (e); 92 } 93 } 94 95 public void setRollbackOnly() 96 { 97 try 98 { 99 workerSession.setRollbackOnly(); 100 } 101 catch (RemoteException e) 102 { 103 throw new EJBException (e); 104 } 105 } 106 107 public void tellFirstAccountToSetRollbackOnly() 108 { 109 try 110 { 111 workerSession.tellFirstAccountToSetRollbackOnly(); 112 } 113 catch (RemoteException e) 114 { 115 throw new EJBException (e); 116 } 117 } 118 119 public void tellSecondAccountToSetRollbackOnly() 120 { 121 try 122 { 123 workerSession.tellSecondAccountToSetRollbackOnly(); 124 } 125 catch (RemoteException e) 126 { 127 throw new EJBException (e); 128 } 129 } 130 131 private void initWorker() 132 { 133 try 134 { 135 Object objref; 136 WorkerHome home; 137 Context iniCtx = new InitialContext (); 138 139 objref = iniCtx.lookup("java:comp/env/ejb/WorkerEJB"); 140 home = (WorkerHome) 141 PortableRemoteObject.narrow(objref, WorkerHome.class); 142 workerSession = home.create("Worker(" + testName + ")"); 143 } 144 catch (Exception e) 145 { 146 throw new EJBException (e); 147 } 148 } 149 150 } 151 | Popular Tags |