1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.io.Serializable ; 29 import java.rmi.RemoteException ; 30 import java.security.Principal ; 31 import java.util.Collection ; 32 import java.util.Date ; 33 import java.util.List ; 34 35 import javax.ejb.EJBException ; 36 import javax.ejb.EJBHome ; 37 import javax.ejb.EJBLocalHome ; 38 import javax.ejb.RemoveException ; 39 import javax.ejb.SessionBean ; 40 import javax.ejb.Timer ; 41 import javax.ejb.TimerService ; 42 import javax.xml.rpc.handler.MessageContext ; 43 44 import org.objectweb.util.monolog.api.BasicLevel; 45 46 50 public class JStatelessContext extends JSessionContext implements TimerService { 51 52 57 public JStatelessContext(JSessionFactory bf, SessionBean sb) { 58 super(bf, sb); 59 if (TraceEjb.isDebugIc()) { 60 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 61 } 62 } 63 64 70 public TimerService getTimerService() throws IllegalStateException { 71 if (TraceEjb.isDebugIc()) { 72 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 73 } 74 if (getState() == 0) { 75 throw new IllegalStateException ("the instance is not allowed to call this method"); 76 } 77 if (getState() == 1) { 78 return this; 81 } 82 return bf.getTimerService(); 83 } 84 85 88 public void setRemoved() throws RemoteException , RemoveException { 89 if (TraceEjb.isDebugIc()) { 90 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 91 } 92 ismarkedremoved = true; 94 } 95 96 102 public MessageContext getMessageContext() throws IllegalStateException { 103 if (bs == null) { 104 throw new IllegalStateException ("No SessionSwitch for that bean"); 105 } 106 MessageContext mc = ((JStatelessSwitch) bs).getMsgContext(); 107 if (mc == null) { 108 throw new IllegalStateException ("No ServiceEndpoint for that bean"); 109 } 110 return mc; 111 } 112 113 116 public void setConnectionList(List conlist) { 117 throw new IllegalStateException ("Stateless beans should not reuse connections"); 118 } 119 120 126 public Principal getCallerPrincipal() throws IllegalStateException { 127 if (getState() < 2) { 128 throw new IllegalStateException ("the instance is not allowed to call this method"); 129 } 130 return super.getCallerPrincipal(); 131 } 132 133 141 public boolean isCallerInRole(String roleName) throws IllegalStateException { 142 if (getState() < 2) { 143 throw new IllegalStateException ("the instance is not allowed to call this method"); 144 } 145 return super.isCallerInRole(roleName); 146 } 147 148 151 public Timer createTimer(long arg0, Serializable arg1) throws IllegalArgumentException , IllegalStateException , EJBException { 152 if (getState() < 2) { 154 throw new IllegalStateException ("the instance is not allowed to call this method"); 155 } 156 return getTimerService().createTimer(arg0, arg1); 157 } 158 159 162 public Timer createTimer(long arg0, long arg1, Serializable arg2) throws IllegalArgumentException , 163 IllegalStateException , EJBException { 164 if (getState() < 2) { 166 throw new IllegalStateException ("the instance is not allowed to call this method"); 167 } 168 return getTimerService().createTimer(arg0, arg1, arg2); 169 } 170 171 174 public Timer createTimer(Date arg0, Serializable arg1) throws IllegalArgumentException , IllegalStateException , EJBException { 175 if (getState() < 2) { 177 throw new IllegalStateException ("the instance is not allowed to call this method"); 178 } 179 return getTimerService().createTimer(arg0, arg1); 180 } 181 182 185 public Timer createTimer(Date arg0, long arg1, Serializable arg2) throws IllegalArgumentException , IllegalStateException , EJBException { 186 if (getState() < 2) { 188 throw new IllegalStateException ("the instance is not allowed to call this method"); 189 } 190 return getTimerService().createTimer(arg0, arg1, arg2); 191 } 192 193 196 public Collection getTimers() throws IllegalStateException , EJBException { 197 if (getState() < 2) { 199 throw new IllegalStateException ("the instance is not allowed to call this method"); 200 } 201 return getTimerService().getTimers(); 202 } 203 204 205 } 206 | Popular Tags |