JSessionSwitch.java

00001 
00026 package org.objectweb.jonas_ejb.container;
00027 
00028 import java.rmi.RemoteException;
00029 
00030 import javax.transaction.Transaction;
00031 
00032 import org.objectweb.jonas_timer.TimerEvent;
00033 import org.objectweb.jonas_timer.TimerEventListener;
00034 import org.objectweb.jonas_timer.TimerManager;
00035 
00036 import org.objectweb.util.monolog.api.BasicLevel;
00037 
00045 public abstract class JSessionSwitch implements TimerEventListener {
00046 
00047     protected JSessionFactory bf;
00048 
00049     protected JSessionLocal local = null;
00050 
00051     protected JSessionRemote remote = null;
00052 
00053     protected TimerEvent mytimer = null;
00054 
00060     public JSessionSwitch(JSessionFactory bf) throws RemoteException {
00061         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00062         this.bf = bf;
00063 
00064         // Create EJBObject if bean has a Remote Interface
00065         if (bf.getHome() != null) {
00066             remote = ((JSessionHome) bf.getHome()).createRemoteObject();
00067             remote.setSessionSwitch(this);
00068         }
00069 
00070         // Create EJBLocalObject if bean has a Local Interface
00071         if (bf.getLocalHome() != null) {
00072             local = ((JSessionLocalHome) bf.getLocalHome()).createLocalObject();
00073             local.setSessionSwitch(this);
00074         }
00075     }
00076 
00080     public JSessionLocal getLocal() {
00081         return local;
00082     }
00083 
00087     public JSessionRemote getRemote() {
00088         return remote;
00089     }
00090 
00094     public JSessionFactory getBeanFactory() {
00095         return bf;
00096     }
00097 
00102     public void startTimer(int timeout) {
00103         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00104         mytimer = TimerManager.getInstance().addTimerMs(this, timeout, null, false);
00105     }
00106 
00110     public void stopTimer() {
00111         TraceEjb.interp.log(BasicLevel.DEBUG, "");
00112         if (mytimer != null) {
00113             mytimer.unset();
00114         }
00115     }
00116     
00117     public abstract JSessionContext getICtx(Transaction tx) throws RemoteException;
00118     public abstract void releaseICtx(Transaction tx);
00119     public abstract void discardICtx(Transaction tx);
00120     public abstract void setMustCommit(boolean mc);
00121     public abstract void saveBeanTx();
00122 
00123     public abstract void pushConnectionList();
00124     public abstract void popConnectionList();
00125     public abstract void enlistConnections(Transaction tx);
00126     public abstract void delistConnections(Transaction tx);
00127 }
00128 

Generated on Tue Feb 15 15:05:42 2005 for JOnAS by  doxygen 1.3.9.1