1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.io.Serializable ; 29 import java.rmi.RemoteException ; 30 import java.util.List ; 31 32 import javax.ejb.EJBLocalObject ; 33 import javax.ejb.EJBObject ; 34 import javax.ejb.RemoveException ; 35 import javax.ejb.SessionBean ; 36 import javax.ejb.SessionContext ; 37 import javax.xml.rpc.handler.MessageContext ; 38 39 import org.objectweb.util.monolog.api.BasicLevel; 40 41 47 48 public abstract class JSessionContext extends JContext implements SessionContext , Serializable { 49 50 protected JSessionSwitch bs = null; 51 52 protected boolean ismarkedremoved; 53 54 59 public JSessionContext(JSessionFactory bf, SessionBean eb) { 60 super(bf, eb); 61 if (TraceEjb.isDebugIc()) { 62 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 63 } 64 } 65 66 70 78 public EJBObject getEJBObject() throws IllegalStateException { 79 if (TraceEjb.isDebugIc()) { 80 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 81 } 82 if (ismarkedremoved || bs == null) { 83 if (ismarkedremoved) 84 TraceEjb.logger.log(BasicLevel.ERROR, "marked removed"); 85 else 86 TraceEjb.logger.log(BasicLevel.ERROR, "no SessionSwitch"); 87 throw new IllegalStateException ("getEJBObject: EJB is removed"); 88 } 89 EJBObject ejbobject = bs.getRemote(); 90 if (ejbobject == null) { 91 throw new IllegalStateException ("No Remote Interface for this bean"); 92 } 93 return ejbobject; 94 } 95 96 105 public EJBLocalObject getEJBLocalObject() throws IllegalStateException { 106 if (TraceEjb.isDebugIc()) { 107 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 108 } 109 if (ismarkedremoved || bs == null) { 110 if (ismarkedremoved) 111 TraceEjb.logger.log(BasicLevel.ERROR, "marked removed"); 112 else 113 TraceEjb.logger.log(BasicLevel.ERROR, "no SessionSwitch"); 114 throw new IllegalStateException ("getEJBLocalObject: EJB is removed"); 115 } 116 EJBLocalObject ejblocalobject = bs.getLocal(); 117 if (ejblocalobject == null) throw new IllegalStateException ("No Local Object for this bean"); 118 return ejblocalobject; 119 } 120 121 127 public abstract MessageContext getMessageContext() throws java.lang.IllegalStateException ; 128 129 133 public boolean getRollbackOnly() throws IllegalStateException { 134 if (TraceEjb.isDebugIc()) { 135 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 136 } 137 138 if (getState() < 2) { 139 throw new IllegalStateException ("the instance is not allowed to call this method"); 140 } 141 return super.getRollbackOnly(); 142 } 143 144 148 152 public void initSessionContext(JSessionSwitch bs) { 153 if (TraceEjb.isDebugIc()) { 154 TraceEjb.interp.log(BasicLevel.DEBUG, ""); 155 } 156 this.bs = bs; 157 ismarkedremoved = false; 158 } 159 160 166 public SessionBean getInstance() throws RemoteException { 168 if (instance == null) { 169 TraceEjb.logger.log(BasicLevel.ERROR, "null!"); 170 throw new RemoteException ("No instance available"); 171 } 172 return (SessionBean ) instance; 173 } 174 175 178 public boolean isMarkedRemoved() { 179 return ismarkedremoved; 180 } 181 182 186 abstract public void setRemoved() throws RemoteException , RemoveException ; 187 abstract public void setConnectionList(List conlist); 188 } 189 | Popular Tags |