1 22 package org.jboss.test.txtimer.ejb; 23 24 import java.rmi.RemoteException ; 25 26 import javax.ejb.CreateException ; 27 import javax.ejb.EJBException ; 28 import javax.ejb.SessionBean ; 29 import javax.ejb.SessionContext ; 30 import javax.naming.InitialContext ; 31 32 import org.jboss.logging.Logger; 33 import org.jboss.test.txtimer.interfaces.TimerEntity; 34 import org.jboss.test.txtimer.interfaces.TimerEntityHome; 35 import org.jboss.test.txtimer.interfaces.TimerSession; 36 import org.jboss.test.txtimer.interfaces.TimerSessionHome; 37 38 41 public class TimerFacadeBean implements SessionBean 42 { 43 private static Logger log = Logger.getLogger(TimerFacadeBean.class); 44 45 private SessionContext context; 46 47 50 public void rollbackAfterCreateSession(long duration) 51 throws Exception 52 { 53 InitialContext iniCtx = new InitialContext (); 54 TimerSessionHome home = (TimerSessionHome) iniCtx.lookup(TimerSessionHome.JNDI_NAME); 55 TimerSession bean = home.create(); 56 bean.createTimer(duration, 0, null); 57 context.setRollbackOnly(); 58 } 59 60 63 public void rollbackAfterCancelSession() 64 throws Exception 65 { 66 InitialContext iniCtx = new InitialContext (); 67 TimerSessionHome home = (TimerSessionHome) iniCtx.lookup(TimerSessionHome.JNDI_NAME); 68 TimerSession bean = home.create(); 69 bean.cancelFirstTimer(); 70 context.setRollbackOnly(); 71 } 72 73 76 public void rollbackAfterCreateEntity(long duration) 77 throws Exception 78 { 79 InitialContext iniCtx = new InitialContext (); 80 TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME); 81 TimerEntity bean = home.findByPrimaryKey(new Integer (1)); 82 bean.createTimer(duration, 0, null); 83 context.setRollbackOnly(); 84 } 85 86 89 public void rollbackAfterCancelEntity() 90 throws Exception 91 { 92 InitialContext iniCtx = new InitialContext (); 93 TimerEntityHome home = (TimerEntityHome) iniCtx.lookup(TimerEntityHome.JNDI_NAME); 94 TimerEntity bean = home.findByPrimaryKey(new Integer (1)); 95 bean.cancelFirstTimer(); 96 context.setRollbackOnly(); 97 } 98 99 100 104 public void setSessionContext(SessionContext ctx) throws EJBException , RemoteException 105 { 106 this.context = ctx; 107 } 108 109 112 public void ejbCreate() throws CreateException 113 { 114 } 115 116 public void ejbRemove() throws EJBException , RemoteException 117 { 118 } 119 120 public void ejbActivate() throws EJBException , RemoteException 121 { 122 } 123 124 public void ejbPassivate() throws EJBException , RemoteException 125 { 126 } 127 } 128 | Popular Tags |