1 23 package com.sun.ejb.portable; 24 25 import java.io.*; 26 import javax.ejb.*; 27 import javax.rmi.PortableRemoteObject ; 28 29 35 36 public final class EJBMetaDataImpl implements javax.ejb.EJBMetaData , Serializable 37 { 38 private Class keyClass; 39 private Class homeClass; 40 private Class remoteClass; 41 private boolean isSessionBean; 42 private boolean isStatelessSessionBean; 43 private HomeHandle homeHandle; 44 45 transient private EJBHome ejbHomeStub; 47 48 49 public EJBMetaDataImpl(EJBHome ejbHomeStub, Class homeClass, 51 Class remoteClass, Class keyClass, 52 boolean isSessionBean, boolean isStatelessSessionBean) 53 { 54 this.ejbHomeStub = ejbHomeStub; 55 this.homeHandle = new HomeHandleImpl(ejbHomeStub); 56 this.keyClass = keyClass; 57 this.homeClass = homeClass; 58 this.remoteClass = remoteClass; 59 this.isSessionBean = isSessionBean; 60 this.isStatelessSessionBean = isStatelessSessionBean; 61 } 62 63 64 67 public Class getHomeInterfaceClass() 68 { 69 return homeClass; 70 } 71 72 75 public Class getRemoteInterfaceClass() 76 { 77 return remoteClass; 78 } 79 80 83 public EJBHome getEJBHome() 84 { 85 return ejbHomeStub; 86 } 87 88 91 public Class getPrimaryKeyClass() 92 { 93 if ( keyClass == null ) { 94 throw new RuntimeException ("SessionBeans do not have a primary key"); 96 } 97 return keyClass; 98 } 99 100 103 public boolean isSession() 104 { 105 return isSessionBean; 106 } 107 108 109 public boolean isStatelessSession() 110 { 111 return isStatelessSessionBean; 112 } 113 114 115 private void readObject(ObjectInputStream in) 116 throws IOException, ClassNotFoundException 117 { 118 isSessionBean = in.readBoolean(); 119 isStatelessSessionBean = in.readBoolean(); 120 121 ClassLoader loader = Thread.currentThread().getContextClassLoader(); 124 remoteClass = loader.loadClass(in.readUTF()); 125 homeClass = loader.loadClass(in.readUTF()); 126 if ( !isSessionBean ) 127 keyClass = loader.loadClass(in.readUTF()); 128 129 homeHandle = (HomeHandle)in.readObject(); 130 ejbHomeStub = homeHandle.getEJBHome(); 131 ejbHomeStub = (EJBHome)PortableRemoteObject.narrow(ejbHomeStub, homeClass); 134 } 135 136 private void writeObject(ObjectOutputStream out) 137 throws IOException 138 { 139 out.writeBoolean(isSessionBean); 140 out.writeBoolean(isStatelessSessionBean); 141 142 out.writeUTF(remoteClass.getName()); 146 out.writeUTF(homeClass.getName()); 147 if ( !isSessionBean ) 148 out.writeUTF(keyClass.getName()); 149 150 out.writeObject(homeHandle); 151 } 152 } 153 | Popular Tags |