1 25 26 package org.objectweb.jonas_ejb.container; 27 28 import java.io.IOException ; 29 import java.io.ObjectOutputStream ; 30 import java.io.OutputStream ; 31 import java.rmi.Remote ; 32 import java.rmi.server.RemoteObject ; 33 import java.rmi.server.RemoteStub ; 34 35 import javax.ejb.EJBHome ; 36 import javax.ejb.EJBObject ; 37 import javax.ejb.Handle ; 38 import javax.ejb.SessionContext ; 39 import javax.transaction.UserTransaction ; 40 41 import org.objectweb.util.monolog.api.BasicLevel; 42 43 47 public class JStatefulOutputStream extends ObjectOutputStream { 48 49 53 protected JStatefulOutputStream(OutputStream out) throws IOException { 54 super(out); 55 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "constructor"); 56 enableReplaceObject(true); 57 } 58 59 62 protected Object replaceObject(Object obj) throws IOException { 63 Object ret; 64 65 if (obj instanceof EJBObject ) { 66 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "EJBObject"); 68 ret = ((EJBObject ) obj).getHandle(); 69 } else if (obj instanceof EJBHome ) { 70 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "EJBHome"); 72 ret = ((EJBHome ) obj).getHomeHandle(); 73 } else if (obj instanceof UserTransaction ) { 74 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "UserTransaction"); 76 ret = new JWrapper(JWrapper.USER_TX, null); 77 } else if (obj instanceof SessionContext ) { 78 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "SessionContext"); 80 ret = new JWrapper(JWrapper.SESSION_CTX, null); 81 } else if (obj instanceof Handle ) { 82 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "Handle"); 85 ret = new JWrapper(JWrapper.HANDLE, (Handle ) obj); 86 } else if ((obj instanceof Remote ) && !(obj instanceof RemoteStub )) { 87 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "Remote"); 89 Remote remote = (Remote ) obj; 90 try { 91 ret = RemoteObject.toStub(remote); 92 } catch (IOException ignore) { 93 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "Cannot convert to stub"); 94 ret = obj; 95 } 96 } else { 97 TraceEjb.ssfpool.log(BasicLevel.DEBUG, "Other:" + obj); 99 ret = obj; 100 } 101 return ret; 102 } 103 } 104 | Popular Tags |