1 45 package org.openejb.client; 46 47 import java.io.IOException ; 48 import java.io.ObjectInput ; 49 import java.io.ObjectOutput ; 50 51 import javax.ejb.EJBHome ; 52 53 54 74 public class EJBMetaDataImpl implements javax.ejb.EJBMetaData , java.io.Externalizable { 75 76 80 public static final byte STATEFUL = (byte)6; 81 82 86 public static final byte STATELESS = (byte)7; 87 88 92 public static final byte BMP_ENTITY = (byte)8; 93 94 98 public static final byte CMP_ENTITY = (byte)9; 99 100 101 protected transient byte type; 102 103 protected transient String deploymentID; 104 protected transient int deploymentCode; 105 106 109 protected transient Class homeClass; 110 111 114 protected transient Class remoteClass; 115 116 119 protected transient Class keyClass; 120 121 protected transient EJBHomeProxy ejbHomeProxy; 122 123 124 public EJBMetaDataImpl() { 125 126 } 127 128 public EJBMetaDataImpl(Class homeInterface, Class remoteInterface, byte typeOfBean) { 129 this.type = typeOfBean; 130 this.homeClass = homeInterface; 131 this.remoteClass = remoteInterface; 132 } 133 134 public EJBMetaDataImpl(Class homeInterface, Class remoteInterface, Class primaryKeyClass, byte typeOfBean) { 135 this(homeInterface, remoteInterface, typeOfBean); 136 if ( type == CMP_ENTITY || type == BMP_ENTITY ) { 137 this.keyClass = primaryKeyClass; 138 } 139 } 140 141 public EJBMetaDataImpl(Class homeInterface, Class remoteInterface, Class primaryKeyClass, byte typeOfBean, String deploymentID) { 142 this(homeInterface, remoteInterface, primaryKeyClass, typeOfBean); 143 this.deploymentID = deploymentID; 144 } 145 146 public EJBMetaDataImpl(Class homeInterface, Class remoteInterface, Class primaryKeyClass, byte typeOfBean, String deploymentID, int deploymentCode) { 147 this(homeInterface, remoteInterface, primaryKeyClass, typeOfBean, deploymentID); 148 this.deploymentCode = deploymentCode; 149 } 150 153 public Class getPrimaryKeyClass() { 154 if ( type != BMP_ENTITY && type != CMP_ENTITY ){ 155 throw new java.lang.UnsupportedOperationException (); 157 } 158 return keyClass; 159 } 160 161 164 public EJBHome getEJBHome() { 165 return ejbHomeProxy; 166 } 167 168 171 public Class getHomeInterfaceClass() { 172 return homeClass; 173 } 174 175 181 public boolean isStatelessSession() { 182 return type == STATELESS; 183 } 184 185 188 public Class getRemoteInterfaceClass() { 189 return remoteClass; 190 } 191 192 197 public boolean isSession() { 198 return ( type == STATEFUL || type == STATELESS ); 199 } 200 201 protected void setEJBHomeProxy(EJBHomeProxy home) { 202 ejbHomeProxy = home; 203 } 204 205 public void writeExternal(ObjectOutput out) throws IOException { 209 out.writeObject( homeClass ); 210 out.writeObject( remoteClass ); 211 out.writeObject( keyClass ); 212 out.writeObject( ejbHomeProxy ); 213 out.writeByte( type ); 214 out.writeUTF( deploymentID ); 215 out.writeShort( (short)deploymentCode ); 216 } 217 218 public void readExternal(ObjectInput in) throws IOException ,ClassNotFoundException { 219 homeClass = (Class ) in.readObject(); 220 remoteClass = (Class ) in.readObject(); 221 keyClass = (Class ) in.readObject(); 222 ejbHomeProxy = (EJBHomeProxy) in.readObject(); 223 type = in.readByte(); 224 deploymentID = in.readUTF(); 225 deploymentCode = in.readShort(); 226 } 227 228 } | Popular Tags |