00001
00026 package org.objectweb.jonas_ejb.container;
00027
00028 import java.io.Serializable;
00029 import java.rmi.RemoteException;
00030 import java.security.Principal;
00031 import java.util.Collection;
00032 import java.util.Date;
00033 import java.util.List;
00034
00035 import javax.ejb.EJBException;
00036 import javax.ejb.EJBHome;
00037 import javax.ejb.EJBLocalHome;
00038 import javax.ejb.RemoveException;
00039 import javax.ejb.SessionBean;
00040 import javax.ejb.Timer;
00041 import javax.ejb.TimerService;
00042 import javax.xml.rpc.handler.MessageContext;
00043
00044 import org.objectweb.util.monolog.api.BasicLevel;
00045
00050 public class JStatelessContext extends JSessionContext implements TimerService {
00051
00057 public JStatelessContext(JSessionFactory bf, SessionBean sb) {
00058 super(bf, sb);
00059 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00060 }
00061
00068 public TimerService getTimerService() throws IllegalStateException {
00069 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00070 if (getState() == 0) {
00071 throw new IllegalStateException("the instance is not allowed to call this method");
00072 }
00073 if (getState() == 1) {
00074
00075
00076 return this;
00077 }
00078 return bf.getTimerService();
00079 }
00080
00084 public void setRemoved() throws RemoteException, RemoveException {
00085 TraceEjb.interp.log(BasicLevel.DEBUG, "");
00086
00087 ismarkedremoved = true;
00088 }
00089
00096 public MessageContext getMessageContext() throws IllegalStateException {
00097 if (bs == null) {
00098 throw new IllegalStateException("No SessionSwitch for that bean");
00099 }
00100 MessageContext mc = ((JStatelessSwitch) bs).getMsgContext();
00101 if (mc == null) {
00102 throw new IllegalStateException("No ServiceEndpoint for that bean");
00103 }
00104 return mc;
00105 }
00106
00110 public void setConnectionList(List conlist) {
00111 throw new IllegalStateException("Stateless beans should not reuse connections");
00112 }
00113
00120 public Principal getCallerPrincipal() throws IllegalStateException {
00121 if (getState() < 2) {
00122 throw new IllegalStateException("the instance is not allowed to call this method");
00123 }
00124 return super.getCallerPrincipal();
00125 }
00126
00135 public boolean isCallerInRole(String roleName) throws IllegalStateException {
00136 if (getState() < 2) {
00137 throw new IllegalStateException("the instance is not allowed to call this method");
00138 }
00139 return super.isCallerInRole(roleName);
00140 }
00141
00145 public Timer createTimer(long arg0, Serializable arg1) throws IllegalArgumentException, IllegalStateException, EJBException {
00146
00147 if (getState() < 2) {
00148 throw new IllegalStateException("the instance is not allowed to call this method");
00149 }
00150 return getTimerService().createTimer(arg0, arg1);
00151 }
00152
00156 public Timer createTimer(long arg0, long arg1, Serializable arg2) throws IllegalArgumentException,
00157 IllegalStateException, EJBException {
00158
00159 if (getState() < 2) {
00160 throw new IllegalStateException("the instance is not allowed to call this method");
00161 }
00162 return getTimerService().createTimer(arg0, arg1, arg2);
00163 }
00164
00168 public Timer createTimer(Date arg0, Serializable arg1) throws IllegalArgumentException, IllegalStateException, EJBException {
00169
00170 if (getState() < 2) {
00171 throw new IllegalStateException("the instance is not allowed to call this method");
00172 }
00173 return getTimerService().createTimer(arg0, arg1);
00174 }
00175
00179 public Timer createTimer(Date arg0, long arg1, Serializable arg2) throws IllegalArgumentException, IllegalStateException, EJBException {
00180
00181 if (getState() < 2) {
00182 throw new IllegalStateException("the instance is not allowed to call this method");
00183 }
00184 return getTimerService().createTimer(arg0, arg1, arg2);
00185 }
00186
00190 public Collection getTimers() throws IllegalStateException, EJBException {
00191
00192 if (getState() < 2) {
00193 throw new IllegalStateException("the instance is not allowed to call this method");
00194 }
00195 return getTimerService().getTimers();
00196 }
00197
00198
00199 }