FileDocCategorySizeDatePackage
EJBMetaDataImpl.javaAPI DocGlassfish v2 API5173Fri May 04 22:33:12 BST 2007com.sun.ejb.portable

EJBMetaDataImpl

public final class EJBMetaDataImpl extends Object implements Serializable, javax.ejb.EJBMetaData
A portable, Serializable implementation of EJBMetaData. This class can potentially be instantiated in another vendor's container so it must not refer to any non-portable RI-specific classes.

Fields Summary
private Class
keyClass
private Class
homeClass
private Class
remoteClass
private boolean
isSessionBean
private boolean
isStatelessSessionBean
private HomeHandle
homeHandle
private transient EJBHome
ejbHomeStub
Constructors Summary
public EJBMetaDataImpl(EJBHome ejbHomeStub, Class homeClass, Class remoteClass, Class keyClass, boolean isSessionBean, boolean isStatelessSessionBean)

	this.ejbHomeStub = ejbHomeStub;
	this.homeHandle = new HomeHandleImpl(ejbHomeStub);
	this.keyClass  = keyClass;
	this.homeClass  = homeClass;
	this.remoteClass  = remoteClass;
	this.isSessionBean = isSessionBean;
	this.isStatelessSessionBean = isStatelessSessionBean;
    
Methods Summary
public EJBHomegetEJBHome()

	return ejbHomeStub;
    
public java.lang.ClassgetHomeInterfaceClass()

	return homeClass;
    
public java.lang.ClassgetPrimaryKeyClass()

	if ( keyClass == null ) {
	    // for SessionBeans there is no primary key
	    throw new RuntimeException("SessionBeans do not have a primary key");
	}
	return keyClass;
    
public java.lang.ClassgetRemoteInterfaceClass()

	return remoteClass;
    
public booleanisSession()

	return isSessionBean;
    
public booleanisStatelessSession()

	return isStatelessSessionBean;
    
private voidreadObject(java.io.ObjectInputStream in)

	isSessionBean = in.readBoolean();
	isStatelessSessionBean = in.readBoolean();

	// Use thread context classloader to load home/remote/primarykey classes
	// See EJB2.0 spec section 18.4.4
	ClassLoader loader = Thread.currentThread().getContextClassLoader();
	remoteClass = loader.loadClass(in.readUTF());
	homeClass = loader.loadClass(in.readUTF());
	if ( !isSessionBean )
	    keyClass = loader.loadClass(in.readUTF());

	homeHandle = (HomeHandle)in.readObject();
	ejbHomeStub = homeHandle.getEJBHome();
	// narrow the home so that the application doesnt have to do
	// a narrow after EJBMetaData.getEJBHome().
	ejbHomeStub = (EJBHome)PortableRemoteObject.narrow(ejbHomeStub, homeClass);
    
private voidwriteObject(java.io.ObjectOutputStream out)

	out.writeBoolean(isSessionBean);
	out.writeBoolean(isStatelessSessionBean);

	// Write the String names of the Class objects, 
	// since Class objects cant be serialized unless the classes
	// they represent are Serializable.
	out.writeUTF(remoteClass.getName());
	out.writeUTF(homeClass.getName());
	if ( !isSessionBean )
	    out.writeUTF(keyClass.getName());

	out.writeObject(homeHandle);