1 45 package org.openejb.core.ivm; 46 47 import java.io.ObjectStreamException ; 48 49 import javax.ejb.EJBHome ; 50 import javax.ejb.EJBObject ; 51 52 import org.openejb.util.proxy.ProxyManager; 53 54 60 public class IntraVmHandle implements java.io.Serializable , javax.ejb.HomeHandle , javax.ejb.Handle { 61 67 protected Object theProxy; 68 69 73 public IntraVmHandle() { 74 this(null); 75 } 76 77 83 public IntraVmHandle(Object proxy) { 84 this.theProxy = proxy; 85 } 86 87 93 protected void setProxy(Object prxy) { 94 theProxy = prxy; 95 } 96 97 102 public EJBHome getEJBHome( ) { 103 return(EJBHome )theProxy; 104 } 105 106 111 public EJBObject getEJBObject( ) { 112 return(EJBObject )theProxy; 113 } 114 115 public Object getPrimaryKey() { 116 return ((BaseEjbProxyHandler) org.openejb.util.proxy.ProxyManager.getInvocationHandler(theProxy)).primaryKey; 117 } 118 119 132 protected Object writeReplace() throws ObjectStreamException { 133 137 if(IntraVmCopyMonitor.isIntraVmCopyOperation()){ 138 return new IntraVmArtifact(this); 139 143 }else if(IntraVmCopyMonitor.isStatefulPassivationOperation()){ 144 return this; 145 149 }else{ 150 BaseEjbProxyHandler handler = (BaseEjbProxyHandler)ProxyManager.getInvocationHandler(theProxy); 151 if(theProxy instanceof javax.ejb.EJBObject ) { 152 return org.openejb.OpenEJB.getApplicationServer().getHandle(handler.getProxyInfo()); 153 } else if(theProxy instanceof javax.ejb.EJBHome ) { 154 return org.openejb.OpenEJB.getApplicationServer().getHomeHandle(handler.getProxyInfo()); 155 }else { 156 throw new RuntimeException ("Invalid proxy type. Handles are only supported by EJBObject types in EJB 1.1"); 157 } 158 } 159 } 160 161 } | Popular Tags |