FileDocCategorySizeDatePackage
WebComponentDescriptor.javaAPI DocGlassfish v2 API14922Fri May 04 22:31:24 BST 2007None

WebComponentDescriptor

public class WebComponentDescriptor extends Descriptor
I am a superclass representing the common data nad behavior of the deployment information about a JSP or JavaServlet in J2EE.
author
Danny Coward

Fields Summary
private WebBundleDescriptor
webBundleDescriptor
public static final String
BASIC_AUTHENTICATION
Constant for Basic authentication.
public static final String
FORM_AUTHENTICATION
Constant for Form authentication.
public static final String
SSL_AUTHENTICATION
Constant for Secure authentication.
public static final String
GET
Constant for the htpp GET method.
public static final String
PUT
Constant for the http PUT method.
public static final String
POST
Constant for the http POST method.
public static final String
DELETE
Constant for the http DELET method.
private Set
initializationParameters
private Set
urlPatterns
private String
canonicalName
private int
loadOnStartUp
private Set
securityRoleReferences
private RunAsIdentityDescriptor
runAs
private String
implFile
private boolean
isServlet
Constructors Summary
public WebComponentDescriptor()
The default constructor.

    
           

      
public WebComponentDescriptor(WebComponentDescriptor other)

        setCanonicalName(other.getCanonicalName());
        setServlet(other.isServlet()); 
        setWebComponentImplementation(
            other.getWebComponentImplementation()); 
        getInitializationParameterSet().addAll(
            other.getInitializationParameterSet()); 
        getUrlPatternsSet().addAll(other.getUrlPatternsSet());
        setLoadOnStartUp(other.getLoadOnStartUp());
        getSecurityRoleReferenceSet().addAll(
            other.getSecurityRoleReferenceSet());
        setRunAsIdentity(other.getRunAsIdentity());
        setWebBundleDescriptor(other.getWebBundleDescriptor());
    
Methods Summary
public voidadd(com.sun.enterprise.deployment.WebComponentDescriptor other)

        // do not do anything if the canonical name of the two web 
        // components are different
        if (! getCanonicalName().equals(other.getCanonicalName())) {
            return;
        }
        // do not do anything if the type of the two web 
        // components are different
        if ( (isServlet() && !other.isServlet()) || 
             (!isServlet() && other.isServlet()) ) {
            return;
        }

        // for simple String types, we can rely on Set API
        getUrlPatternsSet().addAll(other.getUrlPatternsSet());

        // for complex types, only added it if the complex type with same 
        // name is not in the set yet 

        for (Iterator initParamIter = 
            other.getInitializationParameterSet().iterator();  
            initParamIter.hasNext();) {
            InitializationParameter initParam = 
                (InitializationParameter)initParamIter.next();
            if (getInitializationParameterByName(initParam.getName()) == null) {
                getInitializationParameterSet().add(initParam);
            } 
        }
        for (Iterator secRoleRefIter = 
            other.getSecurityRoleReferenceSet().iterator();
            secRoleRefIter.hasNext();) {
            SecurityRoleReference secRoleRef =
                (SecurityRoleReference) secRoleRefIter.next();
            if (getSecurityRoleReferenceByName(secRoleRef.getRolename()) 
                == null) {
                getSecurityRoleReferenceSet().add(secRoleRef);
            }
        }

        // only set these values if they are not set in the current
        // web component already

        if (getLoadOnStartUp() == -1) {
            setLoadOnStartUp(other.getLoadOnStartUp());
        }
        if (getRunAsIdentity() == null) {  
            setRunAsIdentity(other.getRunAsIdentity());
        }
        if (getWebComponentImplementation() == null) {
            setWebComponentImplementation(
                other.getWebComponentImplementation()); 
        }
    
public voidaddInitializationParameter(com.sun.enterprise.deployment.web.InitializationParameter initializationParameter)
Adds a servlet initialization parameter to this component.

	this.getInitializationParameterSet().add(initializationParameter);
	this.changed();
    
public voidaddSecurityRoleReference(com.sun.enterprise.deployment.web.SecurityRoleReference securityRoleReference)
Adds a security role reference to this web component.

	this.getSecurityRoleReferenceSet().add(securityRoleReference);
	this.changed();
    
public voidaddUrlPattern(java.lang.String urlPattern)
Adds an alias to this web component.

	this.getUrlPatternsSet().add(urlPattern);
	this.changed();
    
public voidchanged()

	if (this.getWebBundleDescriptor() != null) {
	    this.getWebBundleDescriptor().changed();
	} else {
	    super.changed();
	}
    
public booleanequals(java.lang.Object other)

        if (other instanceof WebComponentDescriptor &&
            this.getCanonicalName().equals(((
            WebComponentDescriptor)other).getCanonicalName())) {
                return true;
        }
        return false;
    
public ApplicationgetApplication()

	if (this.getWebBundleDescriptor()!=null) {
	    return this.getWebBundleDescriptor().getApplication();
        }
	return null;
     
public java.lang.StringgetCanonicalName()
The canonical name for the web component.

	if (this.canonicalName == null) {
	    this.canonicalName = this.getName();
	}
	return this.canonicalName;
    
public com.sun.enterprise.deployment.web.InitializationParametergetInitializationParameterByName(java.lang.String name)
Return a matching initialization parameter by its name if there is one.

	for (Iterator itr = this.getInitializationParameterSet().iterator(); itr.hasNext();) {
	    InitializationParameter next = (InitializationParameter) itr.next();
	    if (next.getName().equals(name)) {
		return next;
	    }
	}
	return null;
    
private java.util.SetgetInitializationParameterSet()

	if (this.initializationParameters == null) {
	    this.initializationParameters = new OrderedSet();
	}
	return this.initializationParameters = new OrderedSet(this.initializationParameters);
    
public java.util.EnumerationgetInitializationParameters()
Return the Set of servlet initialization parameters.

	return (new Vector(this.getInitializationParameterSet())).elements();
    
public intgetLoadOnStartUp()
Return the order on which this component will be loaded by the web server.

	return this.loadOnStartUp;
    
public RunAsIdentityDescriptorgetRunAsIdentity()
Sets the run-as of the referee EJB.

param
the value of run-as

         return this.runAs;
     
public com.sun.enterprise.deployment.web.SecurityRoleReferencegetSecurityRoleReferenceByName(java.lang.String roleReferenceName)
Return a matching role reference by name or null if there is none matching.

	for (Enumeration e = this.getSecurityRoleReferences(); e.hasMoreElements();) {
	    SecurityRoleReference nextRR = (SecurityRoleReference) e.nextElement();
	    if (nextRR.getRolename().equals( roleReferenceName )) {
		return nextRR; 
	    }
	}
	return null;   
    
java.util.SetgetSecurityRoleReferenceSet()

	if (this.securityRoleReferences == null) {
	    this.securityRoleReferences = new OrderedSet();
	}
	return this.securityRoleReferences = new OrderedSet(this.securityRoleReferences);
    
public java.util.EnumerationgetSecurityRoleReferences()
Return the Set of security role references that I have.

	return (new Vector(this.getSecurityRoleReferenceSet())).elements();
    
public java.util.EnumerationgetUrlPatterns()
Returns an enumeration of (String) URL pattern aliases for this component.

	return (new Vector(this.getUrlPatternsSet())).elements();
    
public java.util.SetgetUrlPatternsSet()
Return the set of URL pattern aliases for this component.

	if (this.urlPatterns == null) {
	    this.urlPatterns = new OrderedSet();
	}
	return this.urlPatterns;
    
public booleangetUsesCallerIdentity()

	return (this.runAs==null);
     
public WebBundleDescriptorgetWebBundleDescriptor()
Return the web app object to which I belong or null

	return this.webBundleDescriptor;
    
public java.lang.StringgetWebComponentImplementation()

         return implFile;         
     
public inthashCode()

        int result = 17;
        result = 37*result + getCanonicalName().hashCode();
        return result;
    
public booleanisServlet()

         return isServlet;
     
public voidprint(java.lang.StringBuffer toStringBuffer)
A formatted string representing my state.

	super.print(toStringBuffer);
        toStringBuffer.append("WebComponentDescriptor\n");        
	toStringBuffer.append( "\n initializationParameters ").append(initializationParameters);
	toStringBuffer.append( "\n urlPatterns ").append(urlPatterns);
	toStringBuffer.append( "\n canonicalName ").append(canonicalName);
	toStringBuffer.append( "\n loadOnStartUp ").append(loadOnStartUp);
	toStringBuffer.append( "\n securityRoleReferences ").append(securityRoleReferences);
        if (isServlet()) {
            toStringBuffer.append( "\n servlet className ").append(getWebComponentImplementation());            
        } else {
            toStringBuffer.append( "\n jspFileName ").append(getWebComponentImplementation());            
        }        
    
public voidremoveInitializationParameter(com.sun.enterprise.deployment.web.InitializationParameter initializationParameter)
Removes the given servlet initialization parameter from this component.

	this.getInitializationParameterSet().remove(initializationParameter);
	this.changed();
    
public voidremoveSecurityRoleReference(com.sun.enterprise.deployment.web.SecurityRoleReference securityRoleReference)
Removes the given security role reference from this web component.

	this.getSecurityRoleReferenceSet().remove(securityRoleReference);
	this.changed();
    
public voidremoveUrlPattern(java.lang.String urlPattern)
Removes a URL pattern from this web component.

	this.getUrlPatternsSet().remove(urlPattern);
	this.changed();
    
public voidsetCanonicalName(java.lang.String canonicalName)
Sets the canonical name of this web component.

	this.canonicalName = canonicalName;
	this.changed();
    
public voidsetLoadOnStartUp(int loadOnStartUp)
Sets the order on which this component will be loaded by the web server.

	this.loadOnStartUp = loadOnStartUp;
	this.changed();
    
public voidsetLoadOnStartUp(java.lang.String loadOnStartUp)
Sets the order on which this component will be loaded by the web server.

        this.loadOnStartUp = Integer.decode(loadOnStartUp).intValue();
        this.changed();
    
public voidsetRunAsIdentity(RunAsIdentityDescriptor runAs)
Gets the run-as of the referee EJB.

return
the value of run-as.

         if (this.runAs == null) {
             this.runAs = runAs;
         }
     
public voidsetServlet(boolean isServlet)

         this.isServlet=isServlet;
     
public voidsetUsesCallerIdentity(boolean isCallerID)

	if (isCallerID) { 
	    this.runAs = null;
	} else {
	    this.runAs = new RunAsIdentityDescriptor("");
        }
     
voidsetWebBundleDescriptor(WebBundleDescriptor webBundleDescriptor)

	this.webBundleDescriptor = webBundleDescriptor;
    
public voidsetWebComponentImplementation(java.lang.String implFile)
sets the implementation file for this web component, the implementation file is either a servlet class name of a jsp file name.

param
implFile the servlet class name or the jsp file

     
                                            
         
         if (!isServlet &&  !implFile.startsWith("/")) {
		implFile = "/" + implFile;
	 }             
         this.implFile = implFile;
         changed();