1 45 package org.openejb.core.ivm; 46 47 import java.io.ObjectStreamException ; 48 49 import javax.ejb.EJBHome ; 50 51 import org.openejb.DeploymentInfo; 52 import org.openejb.util.proxy.ProxyManager; 53 54 60 public class IntraVmMetaData implements javax.ejb.EJBMetaData , java.io.Serializable { 61 62 69 final public static byte ENTITY = DeploymentInfo.BMP_ENTITY; 70 71 78 final public static byte STATEFUL = DeploymentInfo.STATEFUL; 79 80 87 final public static byte STATELESS = DeploymentInfo.STATELESS; 88 89 92 protected Class homeClass; 93 94 97 protected Class remoteClass; 98 99 103 protected Class keyClass; 104 105 108 protected EJBHome homeStub; 109 110 117 protected byte type; 118 119 130 public IntraVmMetaData(Class homeInterface, Class remoteInterface, byte typeOfBean) { 131 this(homeInterface,remoteInterface, null, typeOfBean); 132 } 133 134 148 public IntraVmMetaData(Class homeInterface, Class remoteInterface, Class primaryKeyClass, byte typeOfBean) { 149 if(typeOfBean!=ENTITY && typeOfBean!=STATEFUL && typeOfBean!=STATELESS) { 150 if(typeOfBean==DeploymentInfo.CMP_ENTITY) { 151 typeOfBean=ENTITY; 152 }else { 153 throw new IllegalArgumentException ("typeOfBean parameter not in range: "+typeOfBean); 154 } 155 } 156 if(homeInterface==null || remoteInterface==null) { 157 throw new IllegalArgumentException (); 158 } 159 if(typeOfBean==ENTITY && primaryKeyClass==null) { 160 throw new IllegalArgumentException (); 161 } 162 type = typeOfBean; 163 homeClass = homeInterface; 164 remoteClass = remoteInterface; 165 keyClass = primaryKeyClass; 166 } 167 168 173 public Class getHomeInterfaceClass( ) { 174 return homeClass; 175 } 176 177 182 public Class getRemoteInterfaceClass() { 183 return remoteClass; 184 } 185 186 198 public Class getPrimaryKeyClass( ) { 199 if ( type == ENTITY ) 200 return keyClass; 201 else 202 throw new UnsupportedOperationException ("Session objects are private resources and do not have primary keys"); 203 } 204 205 211 public boolean isSession( ) { 212 return(type == STATEFUL || type ==STATELESS); 213 } 214 215 221 public boolean isStatelessSession() { 222 return type == STATELESS; 223 } 224 225 230 public void setEJBHome(EJBHome home) { 231 homeStub = home; 232 } 233 234 239 public javax.ejb.EJBHome getEJBHome() { 240 return homeStub; 241 } 242 243 256 protected Object writeReplace() throws ObjectStreamException { 257 258 262 if(IntraVmCopyMonitor.isIntraVmCopyOperation()){ 263 return new IntraVmArtifact(this); 264 268 }else if(IntraVmCopyMonitor.isStatefulPassivationOperation()){ 269 return this; 270 274 }else{ 275 BaseEjbProxyHandler handler = (BaseEjbProxyHandler)ProxyManager.getInvocationHandler(homeStub); 276 return org.openejb.OpenEJB.getApplicationServer().getEJBMetaData(handler.getProxyInfo()); 277 } 278 } 279 } | Popular Tags |