1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.rmi.RemoteException ; 29 30 import javax.transaction.Transaction ; 31 32 import org.objectweb.jonas_timer.TimerEvent; 33 import org.objectweb.jonas_timer.TimerEventListener; 34 import org.objectweb.jonas_timer.TimerManager; 35 36 import org.objectweb.util.monolog.api.BasicLevel; 37 38 45 public abstract class JSessionSwitch implements TimerEventListener { 46 47 protected JSessionFactory bf; 48 49 protected JSessionLocal local = null; 50 51 protected JSessionRemote remote = null; 52 53 protected TimerEvent mytimer = null; 54 55 60 public JSessionSwitch(JSessionFactory bf) throws RemoteException { 61 if (TraceEjb.isDebugIc()) { 62 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 63 } 64 this.bf = bf; 65 66 if (bf.getHome() != null) { 68 remote = ((JSessionHome) bf.getHome()).createRemoteObject(); 69 remote.setSessionSwitch(this); 70 } 71 72 if (bf.getLocalHome() != null) { 74 local = ((JSessionLocalHome) bf.getLocalHome()).createLocalObject(); 75 local.setSessionSwitch(this); 76 } 77 } 78 79 82 public JSessionLocal getLocal() { 83 return local; 84 } 85 86 89 public JSessionRemote getRemote() { 90 return remote; 91 } 92 93 96 public JSessionFactory getBeanFactory() { 97 return bf; 98 } 99 100 104 public void startTimer(int timeout) { 105 if (TraceEjb.isDebugIc()) { 106 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 107 } 108 mytimer = TimerManager.getInstance().addTimerMs(this, timeout, null, false); 109 } 110 111 114 public void stopTimer() { 115 if (TraceEjb.isDebugIc()) { 116 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 117 } 118 if (mytimer != null) { 119 mytimer.unset(); 120 } 121 } 122 123 public abstract JSessionContext getICtx(Transaction tx) throws RemoteException ; 124 public abstract void releaseICtx(Transaction tx); 125 public abstract void discardICtx(Transaction tx); 126 public abstract void setMustCommit(boolean mc); 127 public abstract void saveBeanTx(); 128 129 public abstract void pushConnectionList(); 130 public abstract void popConnectionList(); 131 public abstract void enlistConnections(Transaction tx); 132 public abstract void delistConnections(Transaction tx); 133 } 134 135 | Popular Tags |