FileDocCategorySizeDatePackage
EjbReferenceDescriptor.javaAPI DocGlassfish v2 API12494Fri May 04 22:31:22 BST 2007com.sun.enterprise.deployment

EjbReferenceDescriptor

public class EjbReferenceDescriptor extends EnvironmentProperty implements NamedDescriptor, com.sun.enterprise.deployment.types.EjbReference
An object representing a link to another ejb.
author
Jerome Dochez

Fields Summary
private EjbDescriptor
ejbDescriptor
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
private BundleDescriptor
referringBundle
private String
refType
private String
refHomeIntf
private String
refIntf
private boolean
isLocal
private String
ejbLink
holds the ejb-link value associated to this ejb reference before the ejbs were resolved
Constructors Summary
public EjbReferenceDescriptor(EjbReferenceDescriptor other)
copy constructor

param
other handle to other EjbReferenceDescriptor to clone


                     
       
	super(other);
	isLocal = other.isLocal; // boolean
	refType = other.refType; // String
	refHomeIntf = other.refHomeIntf; // String
	refIntf = other.refIntf; // String
	ejbLink = other.ejbLink; // String
	referringBundle = other.referringBundle; // copy as-is
	ejbDescriptor = other.ejbDescriptor;
	if (ejbDescriptor != null) { 
            ejbDescriptor.addEjbReferencer(this); // ???
	}
    
public EjbReferenceDescriptor(String name, String description, EjbDescriptor ejbDescriptor)
Construct an remote ejb reference to the given ejb descriptor with the given name and descriptor of the reference.

param
name the ejb-ref name as used in the referencing bean
param
optional description
param
ejbDescriptor of the referenced bean

	super(name, "", description);
	this.setEjbDescriptor(ejbDescriptor);
    
public EjbReferenceDescriptor(String name, String description, EjbDescriptor ejbDescriptor, boolean isLocal)
constructs an local or remote ejb reference to the given ejb descriptor, the desciption and the name of the reference

param
name is the name of the reference
param
description is a human readable description of the reference
param
ejbDescriptor the referenced EJB
param
isLocal true if the reference uses the local interfaces

        super(name, "", description);
        this.isLocal = isLocal;
        this.setEjbDescriptor(ejbDescriptor);
    
public EjbReferenceDescriptor()
Constructs a reference in the extrernal state.

    
Methods Summary
public booleanequals(java.lang.Object object)

	if (object instanceof EjbReference) {
	    EjbReference ejbReference = (EjbReference) object;
	    return ejbReference.getName().equals(this.getName());
	}
	return false;
    
public java.lang.StringgetBeanClassName()

return
the bean instance interface classname of the referee EJB.

        return refIntf;
    
public EjbDescriptorgetEjbDescriptor()
return the ejb to whoch I refer.

	return ejbDescriptor;
    
public java.lang.StringgetEjbHomeInterface()
Gets the home classname of the referee EJB.

return
the class name of the EJB home.

        return getHomeClassName();
    
public java.lang.StringgetEjbInterface()
Gets the local or remote interface classname of the referee EJB.

return
the classname of the EJB remote object.

        return getBeanClassName();
    
public java.lang.StringgetHomeClassName()
Gets the home classname of the referee EJB.

        return refHomeIntf;
    
public java.lang.StringgetInjectResourceType()

        return isEJB30ClientView() ?
            getEjbInterface() : getEjbHomeInterface();
    
public java.lang.StringgetJndiName()
return the jndi name of the bean to which I refer.

        String jndiName = this.getValue();
        if( isLocal() ) {
            // mapped-name has no meaning for the local ejb view.  ejb-link
            // should be used to resolve any ambiguities about the target
            // local ejb. 
            return jndiName;
        } else {
            return (jndiName != null && ! jndiName.equals("")) ? 
                jndiName : getMappedName();
        }
    
public java.lang.StringgetLinkName()

return
the name of the ejb to which I refer

	if (ejbDescriptor==null) {
            return ejbLink;
        } else {
            if (ejbLink != null && ejbLink.length()!=0) {
                return ejbLink;
            }
	    return ejbDescriptor.getName();
	}
    
public BundleDescriptorgetReferringBundleDescriptor()
Get the referring bundle, i.e. the bundle within which this EJB reference is declared.

	return referringBundle;
    
public java.lang.StringgetType()
Retusn the type of the ejb to whioch I refer.

        if (ejbDescriptor==null) {
            return refType;
        } else {
            return ejbDescriptor.getType();
        }
    
public java.lang.StringgetValue()
Return the jndi name of the bean to which I refer.

	if (ejbDescriptor == null) {
            return super.getValue();
	} else {        
            if (isLocal()) {
                return super.getValue();
            } else {
                return ejbDescriptor.getJndiName();
            }
        }
    
public booleanisEJB30ClientView()

return
true if the EJB reference is a 30 client view

        return (getHomeClassName() == null);
    
public booleanisLinked()
return true if I know the name of the ejb to which I refer.

	return ejbLink!=null;
    
public booleanisLocal()

return
true if the EJB reference uses the local interfaces of the EJB

        return isLocal;
    
public voidprint(java.lang.StringBuffer toStringBuffer)
returns a formatted string representing me.

	if (ejbDescriptor!=null) {
	    toStringBuffer.append("Resolved Ejb-Ref ").append(getName()).append("@jndi: ").append(getJndiName()).append( 
                    " - > ").append(ejbDescriptor.getName());
	} else {
	    toStringBuffer.append("Unresolved Ejb-Ref ").append(getName()).append("@jndi: ").append(getJndiName()).append("@").append( 
                getEjbHomeInterface()).append("@").append(getEjbInterface()).append("@").append(refType).append("@").append(ejbLink) ;
	}	
    
public voidsetBeanClassName(java.lang.String remoteClassName)
Sets the bean instance business interface classname of the bean to which I refer. this interface is the local object or the remote interfaces depending if the reference is local or not.

        refIntf = remoteClassName;
    
public voidsetEjbDescriptor(EjbDescriptor ejbDescriptor)
Sets the ejb descriptor to which I refer.

param
the ejb descriptor referenced, null if it is unknow at this time

	if (this.ejbDescriptor != null) {
            this.ejbDescriptor.removeEjbReferencer(this); // remove previous referencer
	}
        this.ejbDescriptor=ejbDescriptor;
	if (ejbDescriptor!=null) { 
            ejbDescriptor.addEjbReferencer(this);
            if (isLocal()) {
                if (!ejbDescriptor.isLocalInterfacesSupported() &&
                    !ejbDescriptor.isLocalBusinessInterfacesSupported()) {
                     throw new RuntimeException(localStrings.getLocalString(
                     "entreprise.deployment.invalidLocalInterfaceReference",
                     "Trying to set an ejb-local-ref on an EJB while the EJB does not define local interfaces"));
                }
            } else {
                if (!ejbDescriptor.isRemoteInterfacesSupported() &&
                    !ejbDescriptor.isRemoteBusinessInterfacesSupported()) {
                    throw new RuntimeException(localStrings.getLocalString(
                    "entreprise.deployment.invalidRemoteInterfaceReference",
                    "Trying to set an ejb-ref on an EJB, while the EJB does not define remote interfaces"));
                }
            }
	}
    
public voidsetEjbHomeInterface(java.lang.String homeClassName)
Sets the local or remote home classname of the referee EJB.

param
the class name of the EJB home.

        setHomeClassName(homeClassName);
    
public voidsetEjbInterface(java.lang.String remoteClassName)
Sets the local or remote bean interface classname of the referee EJB.

param
the classname of the EJB remote object.

        setBeanClassName(remoteClassName);
    
public voidsetHomeClassName(java.lang.String homeClassName)
Sets the home classname of the bean to whcioh I refer.

        refHomeIntf = homeClassName;
    
public voidsetInjectResourceType(java.lang.String resourceType)

        if (isEJB30ClientView()) { 
            setEjbInterface(resourceType); 
        } else {
            setEjbHomeInterface(resourceType);
        }
    
public voidsetJndiName(java.lang.String jndiName)
Sets the jndi name of the bean tyo whoch I am referring.

	this.setValue(jndiName);
    
public voidsetLinkName(java.lang.String linkName)
Sets the name of the ejb to which I refer.

        ejbLink = linkName;
    
public voidsetLocal(boolean local)
Set whether this EJB Reference uses local interfaces or remote

param
local true if the EJB reference use local interfaces

        this.isLocal = local;
    
public voidsetReferringBundleDescriptor(BundleDescriptor referringBundle)
Set the referring bundle, i.e. the bundle within which this EJB reference is declared.

	this.referringBundle = referringBundle;
    
public voidsetType(java.lang.String type)
Assigns the type of the ejb to whcoih I refer.

	refType=type;