1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.rmi.NoSuchObjectException ; 29 import java.rmi.RemoteException ; 30 31 import javax.ejb.RemoveException ; 32 import javax.transaction.Transaction ; 33 import javax.xml.rpc.handler.MessageContext ; 34 35 import org.objectweb.util.monolog.api.BasicLevel; 36 37 42 public class JStatelessSwitch extends JSessionSwitch { 43 44 47 private JStatelessContext bctx = null; 48 49 52 private JServiceEndpoint se = null; 53 54 59 public JStatelessSwitch(JStatelessFactory bf) throws RemoteException { 60 super(bf); 61 if (TraceEjb.isDebugIc()) { 62 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 63 } 64 65 if (bf.getSEHome() != null) { 67 se = bf.getSEHome().createServiceEndpointObject(); 68 se.setSessionSwitch(this); 69 } 70 } 71 72 76 80 public synchronized void timeoutExpired(Object arg) { 81 if (TraceEjb.logger.isLoggable(BasicLevel.WARN)) { 82 TraceEjb.logger.log(BasicLevel.WARN, "stateless session '" + bf.getEJBName() + "' : timeout expired"); 83 } 84 mytimer = null; 85 if (bctx != null) { 86 try { 87 bctx.setRemoved(); 88 ((JStatelessFactory) bf).releaseJContext(bctx); 89 bctx = null; 90 } catch (RemoteException e) { 91 TraceEjb.logger.log(BasicLevel.WARN, "timeout expired", e); 92 } catch (RemoveException e) { 93 TraceEjb.logger.log(BasicLevel.WARN, "timeout expired", e); 94 } 95 } 96 noLongerUsed(); 97 } 98 99 103 106 public JServiceEndpoint getServiceEndpoint() { 107 return se; 108 } 109 110 113 public MessageContext getMsgContext() { 114 if (se == null) { 115 TraceEjb.logger.log(BasicLevel.ERROR, "No ServiceEndpoint for this bean"); 116 return null; 117 } 118 return se.getMessageContext(); 119 } 120 121 127 public JSessionContext getICtx(Transaction tx) throws RemoteException { 128 if (TraceEjb.isDebugIc()) { 129 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 130 } 131 bctx = (JStatelessContext) ((JStatelessFactory) bf).getJContext(this); 132 return bctx; 133 } 134 135 140 public void releaseICtx(Transaction tx) { 141 if (TraceEjb.isDebugIc()) { 142 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 143 } 144 145 if (bctx == null) { 146 return; 147 } 148 if (bctx.isMarkedRemoved()) { 149 stopTimer(); 150 noLongerUsed(); 151 } 152 ((JStatelessFactory) bf).releaseJContext(bctx); 153 bctx = null; 154 } 155 156 161 public void discardICtx(Transaction tx) { 162 if (TraceEjb.isDebugIc()) { 163 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 164 } 165 166 if (bctx == null) { 168 return; 169 } 170 171 stopTimer(); 172 noLongerUsed(); 173 174 ((JStatelessFactory) bf).releaseJContext(bctx); 175 bctx = null; 176 177 } 178 179 182 public void noLongerUsed() { 183 if (TraceEjb.isDebugIc()) { 184 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 185 } 186 187 if (remote != null) { 189 try { 190 remote.unexportObject(); 191 } catch (NoSuchObjectException e) { 192 TraceEjb.logger.log(BasicLevel.ERROR, "exception", e); 193 } 194 } 195 196 bf.removeEJB(this); 199 } 200 201 205 public void setMustCommit(boolean mc) { 206 } 207 208 211 public void pushConnectionList() { 212 } 213 214 217 public void popConnectionList() { 218 } 219 220 224 public void enlistConnections(Transaction tx) { 225 } 226 230 public void delistConnections(Transaction tx) { 231 } 232 235 public void saveBeanTx() { 236 } 237 } 238 | Popular Tags |