FileDocCategorySizeDatePackage
ApplicationClientDescriptor.javaAPI DocGlassfish v2 API26384Fri May 04 22:31:20 BST 2007None

ApplicationClientDescriptor

public class ApplicationClientDescriptor extends BundleDescriptor implements com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer, com.sun.enterprise.deployment.types.ResourceReferenceContainer, com.sun.enterprise.deployment.types.ServiceReferenceContainer, com.sun.enterprise.deployment.types.ResourceEnvReferenceContainer, WritableJndiNameEnvironment, com.sun.enterprise.deployment.types.EjbReferenceContainer
I represent all the deployment information about an application client [{0}].
author
Danny Coward

Fields Summary
private Set
environmentProperties
private Set
ejbReferences
private Set
jmsDestReferences
private Set
messageDestReferences
private Set
resourceReferences
private Set
serviceReferences
private Set
entityManagerFactoryReferences
private Set
entityManagerReferences
private Set
postConstructDescs
private Set
preDestroyDescs
private String
mainClassName
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
private String
callbackHandler
private com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptor
jwsAccessDescriptor
Constructors Summary
Methods Summary
public voidaddEjbReferenceDescriptor(EjbReferenceDescriptor ejbReference)
Add a reference to an ejb.

        addEjbReferenceDescriptor((EjbReference) ejbReference);
    
public voidaddEjbReferenceDescriptor(com.sun.enterprise.deployment.types.EjbReference ejbReference)

	this.getEjbReferenceDescriptors().add(ejbReference);
        ejbReference.setReferringBundleDescriptor(this);
	this.changed();
    
public voidaddEntityManagerFactoryReferenceDescriptor(EntityManagerFactoryReferenceDescriptor reference)

 
        reference.setReferringBundleDescriptor(this);
        this.getEntityManagerFactoryReferenceDescriptors().add(reference);
        this.changed();
    
public voidaddEntityManagerReferenceDescriptor(EntityManagerReferenceDescriptor reference)

 
        reference.setReferringBundleDescriptor(this);
        this.getEntityManagerReferenceDescriptors().add(reference);
        this.changed();
    
public voidaddEnvironmentProperty(EnvironmentProperty environmentProperty)
Adds an environment property to this application client [{0}].

	this.getEnvironmentProperties().add(environmentProperty);
	this.changed();
    
public voidaddJmsDestinationReferenceDescriptor(JmsDestinationReferenceDescriptor jmsDestReference)

	this.getJmsDestinationReferenceDescriptors().add(jmsDestReference);
	this.changed();
    
public voidaddMessageDestinationReferenceDescriptor(MessageDestinationReferenceDescriptor messageDestRef)

 
        messageDestRef.setReferringBundleDescriptor(this);

        this.getMessageDestinationReferenceDescriptors().add(messageDestRef);
        this.changed();
    
public voidaddPostConstructDescriptor(LifecycleCallbackDescriptor postConstructDesc)

        String className = postConstructDesc.getLifecycleCallbackClass();
        boolean found = false;
        for (LifecycleCallbackDescriptor next :
             getPostConstructDescriptors()) {
            if ( (next.getLifecycleCallbackClass() != null) && 
                next.getLifecycleCallbackClass().equals(className)) {
                found = true;
                break;
            }
        }
        if (!found) {
            getPostConstructDescriptors().add(postConstructDesc);
        }
    
public voidaddPreDestroyDescriptor(LifecycleCallbackDescriptor preDestroyDesc)

        String className = preDestroyDesc.getLifecycleCallbackClass();
        boolean found = false;
        for (LifecycleCallbackDescriptor next :
             getPreDestroyDescriptors()) {
            if ( (next.getLifecycleCallbackClass() != null) && 
                next.getLifecycleCallbackClass().equals(className)) {
                found = true;
                break;
            }
        }
        if (!found) {
            getPreDestroyDescriptors().add(preDestroyDesc);
        }
    
public voidaddResourceReferenceDescriptor(ResourceReferenceDescriptor resourceReference)
Adds a reference to a resource.

	this.getResourceReferenceDescriptors().add(resourceReference);
	this.changed();
    
public voidaddServiceReferenceDescriptor(ServiceReferenceDescriptor serviceRef)

        serviceRef.setBundleDescriptor(this);
        this.getServiceReferenceDescriptors().add(serviceRef);
        this.changed();
    
public java.util.CollectionfindReferencedPUs()
This method is used to find out the precise list of PUs that are referenced by the appclient. An appclient can not use container managed EM as there is no support for JTA in our ACC, so this method only returns the list of PUs referenced via @PersistenceUnit or .

return
list of PU that are actually referenced by the appclient.

        return findReferencedPUsViaPURefs(this);
    
public java.lang.StringgetCallbackHandler()
Get the classname of the callback handler.

	return callbackHandler;
     
public java.util.SetgetComponentClassNames()

return
a set of class names that need to have full annotation processing

        Set set = new HashSet<String>();
        set.add(getMainClassName());
        return set;
    
public java.lang.StringgetDefaultSpecVersion()

return
the default version of the deployment descriptor loaded by this descriptor

        return AppClientNode.SPEC_VERSION;
    
public com.sun.enterprise.deployment.types.EjbReferencegetEjbReference(java.lang.String name)
Looks up an ejb reference with the given name. Throws an IllegalArgumentException if it is not found.

	for (Iterator itr = this.getEjbReferenceDescriptors().iterator(); itr.hasNext();) {
	    EjbReference ejr = (EjbReference) itr.next();
	    if (ejr.getName().equals(name)) {
		return ejr;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
            "exceptionappclienthasnoejbrefbyname", 
            "This application client [{0}] has no ejb reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public EjbReferenceDescriptorgetEjbReferenceByName(java.lang.String name)
Looks up an ejb reference with the given name. Throws an IllegalArgumentException if it is not found.

	for (Iterator itr = this.getEjbReferenceDescriptors().iterator(); itr.hasNext();) {
	    EjbReferenceDescriptor ejr = (EjbReferenceDescriptor) itr.next();
	    if (ejr.getName().equals(name)) {
		return ejr;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
            "exceptionappclienthasnoejbrefbyname", 
            "This application client [{0}] has no ejb reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.SetgetEjbReferenceDescriptors()
Return the set of references to ejbs that I have.

	if (this.ejbReferences == null) {
	    this.ejbReferences = new OrderedSet();
	}
	return this.ejbReferences = new OrderedSet(this.ejbReferences);
    
public EntityManagerFactoryReferenceDescriptorgetEntityManagerFactoryReferenceByName(java.lang.String name)
Return the entity manager factory reference descriptor corresponding to the given name.

        for (EntityManagerFactoryReferenceDescriptor next :
             getEntityManagerFactoryReferenceDescriptors()) {

            if (next.getName().equals(name)) {
                return next;
            }
        }
	throw new IllegalArgumentException(localStrings.getLocalString(
            "exceptionappclienthasnoentitymgrfactoryrefbyname", 
            "This application client [{0}] has no entity manager factory reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.SetgetEntityManagerFactoryReferenceDescriptors()

        return entityManagerFactoryReferences;
    
public EntityManagerReferenceDescriptorgetEntityManagerReferenceByName(java.lang.String name)
Return the entity manager factory reference descriptor corresponding to the given name.

	throw new IllegalArgumentException(localStrings.getLocalString(
            "exceptionappclienthasnoentitymgrrefbyname", 
            "This application client [{0}] has no entity manager reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.SetgetEntityManagerReferenceDescriptors()

        return entityManagerReferences;
    
public java.util.SetgetEnvironmentProperties()
Returns the set of environment properties of this app client.

	if (this.environmentProperties == null) {
	    this.environmentProperties = new OrderedSet();
	}
	return this.environmentProperties = new OrderedSet(this.environmentProperties);
    
public EnvironmentPropertygetEnvironmentPropertyByName(java.lang.String name)
Returns the environment property object searching on the supplied key. throws an illegal argument exception if no such environment property exists.

	for (Iterator itr = this.getEnvironmentProperties().iterator(); 
             itr.hasNext();) {
	    EnvironmentProperty ev = (EnvironmentProperty) itr.next();
	    if (ev.getName().equals(name)) {
		return ev;   
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
            "enterprise.deployment.exceptionappclienthasnoenvpropertybyname", 
            "This application client [{0}] has no environment property by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.ListgetInjectableResourcesByClass(java.lang.String className)

        return getInjectableResourcesByClass(className, this);
    
public InjectionInfogetInjectionInfoByClass(java.lang.String className)

        return getInjectionInfoByClass(className, this);
    
public com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptorgetJavaWebStartAccessDescriptor()

        if (jwsAccessDescriptor == null) {
            jwsAccessDescriptor = new JavaWebStartAccessDescriptor();
            jwsAccessDescriptor.setBundleDescriptor(this);
        }
        return jwsAccessDescriptor;
    
public JmsDestinationReferenceDescriptorgetJmsDestinationReferenceByName(java.lang.String name)
Return a JMS destination reference by the same name or throw an IllegalArgumentException.

	for (Iterator itr = this.getJmsDestinationReferenceDescriptors().iterator(); itr.hasNext();) {
	    JmsDestinationReferenceDescriptor jdr = (JmsDestinationReferenceDescriptor) itr.next();
	    if (jdr.getName().equals(name)) {
		return jdr;   
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
	    "enterprise.deployment.exceptionappclienthasnojmsdestrefbyname",
	    "This application client [{0}] has no resource environment reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.SetgetJmsDestinationReferenceDescriptors()
Return the set of JMS destination references this ejb declares.

	if (this.jmsDestReferences == null) {
	    this.jmsDestReferences = new OrderedSet();
	}
	return this.jmsDestReferences = new OrderedSet(this.jmsDestReferences);
    
public java.lang.StringgetMainClassName()
Return the fq Java clasname of this application client [{0}].

	if (this.mainClassName == null) {
            this.mainClassName = "";
	}
	return this.mainClassName;
    
public MessageDestinationReferenceDescriptorgetMessageDestinationReferenceByName(java.lang.String name)
Looks up an message destination reference with the given name. Throws an IllegalArgumentException if it is not found.

	for (Iterator itr = 
                 this.getMessageDestinationReferenceDescriptors().iterator(); 
             itr.hasNext();) {
	    MessageDestinationReferenceDescriptor mdr = 
                (MessageDestinationReferenceDescriptor) itr.next();
	    if (mdr.getName().equals(name)) {
		return mdr;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
		"exceptionappclienthasnomsgdestrefbyname", 
                "This application client [{0}] has no message destination reference by the name of [{1}]", 
                new Object[] {getName(), name}));
    
public java.util.SetgetMessageDestinationReferenceDescriptors()

        if( this.messageDestReferences == null ) {
            this.messageDestReferences = new OrderedSet();
        }
        return this.messageDestReferences = 
            new OrderedSet(this.messageDestReferences);
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type for this bundle descriptor

        return ModuleType.CAR;
    
public java.util.CollectiongetNamedDescriptors()
Return the set of named descriptors I reference.

	return super.getNamedDescriptorsFrom(this);
    
public java.util.VectorgetNamedReferencePairs()
Return the set of named reference pairs I reference.

	return super.getNamedReferencePairsFrom(this);
    
public LifecycleCallbackDescriptorgetPostConstructDescriptorByClass(java.lang.String className)

        return getPostConstructDescriptorByClass(className, this);
    
public java.util.SetgetPostConstructDescriptors()

        return postConstructDescs;
    
public LifecycleCallbackDescriptorgetPreDestroyDescriptorByClass(java.lang.String className)

        return getPreDestroyDescriptorByClass(className, this);
    
public java.util.SetgetPreDestroyDescriptors()

        return preDestroyDescs;
    
public ResourceReferenceDescriptorgetResourceReferenceByName(java.lang.String name)
Looks up a reference to a resource by its name (getName()). Throws an IllegalArgumentException if no such descriptor is found.

	for (Iterator itr = this.getResourceReferenceDescriptors().iterator(); itr.hasNext();) {
	    ResourceReferenceDescriptor rr = (ResourceReferenceDescriptor) itr.next();
	    if (rr.getName().equals(name)) {
		return rr;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
	    "exceptionappclienthasnoresourcerefbyname",
	    "This application client [{0}] has no resource reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.SetgetResourceReferenceDescriptors()
Return the set of references to resources that I have.

	if (this.resourceReferences == null) {
	    this.resourceReferences = new OrderedSet();
	}
	return this.resourceReferences = new OrderedSet(this.resourceReferences);
    
public ServiceReferenceDescriptorgetServiceReferenceByName(java.lang.String name)
Looks up an service reference with the given name. Throws an IllegalArgumentException if it is not found.

	for (Iterator itr = this.getServiceReferenceDescriptors().iterator(); 
             itr.hasNext();) {
	    ServiceReferenceDescriptor srd = (ServiceReferenceDescriptor) 
                itr.next();
	    if (srd.getName().equals(name)) {
		return srd;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
            "enterprise.deployment.exceptionappclienthasnoservicerefbyname", 
            "This application client [{0}] has no service reference by the name of [{1}]", 
            new Object[] {getName(), name}));
    
public java.util.SetgetServiceReferenceDescriptors()

        if( this.serviceReferences == null ) {
            this.serviceReferences = new OrderedSet();
        }
        return this.serviceReferences = new OrderedSet(this.serviceReferences);
    
public booleanhasRuntimeInformation()
Return true if there is runtime information in this object that must be saved.

        
                      
       
	for (Iterator itr = this.getNamedDescriptors().iterator(); itr.hasNext();) {
	    NamedDescriptor next = (NamedDescriptor) itr.next();
	    if (!"".equals(next.getJndiName())) {
		return true;
	    }
	}
	return false;
    
public booleanhasWebServiceClients()

return
true if this bundle descriptor defines web service clients

        return !(getServiceReferenceDescriptors().isEmpty());
    
public booleanhasWebServices()

return
true if this bundle descriptor defines web services

        return false;
    
public voidprint(java.lang.StringBuffer toStringBuffer)

        toStringBuffer.append("Application Client Descriptor");
	toStringBuffer.append("\n ");
        super.print(toStringBuffer);
	toStringBuffer.append("\n environmentProperties ").append(environmentProperties);
	toStringBuffer.append("\n ejbReferences ");
        if(ejbReferences != null)
            printDescriptorSet(ejbReferences,toStringBuffer);
        toStringBuffer.append("\n jmsDestReferences ");
        if(jmsDestReferences != null)
            printDescriptorSet(jmsDestReferences,toStringBuffer);
        toStringBuffer.append("\n messageDestReferences ");
        if(messageDestReferences != null)
            printDescriptorSet(messageDestReferences,toStringBuffer);
	toStringBuffer.append("\n resourceReferences ");
        if(resourceReferences != null)
            printDescriptorSet(resourceReferences,toStringBuffer);
        toStringBuffer.append("\n serviceReferences ");
        if(serviceReferences != null)
            printDescriptorSet(serviceReferences,toStringBuffer);
	toStringBuffer.append("\n mainClassName ").append(mainClassName);
    
private voidprintDescriptorSet(java.util.Set descSet, java.lang.StringBuffer sbuf)

        for(Iterator itr = descSet.iterator(); itr.hasNext();){
            Object obj = itr.next();
            if(obj instanceof Descriptor)
                ((Descriptor)obj).print(sbuf);
            else
                sbuf.append(obj);
        }
    
public voidremoveEjbReferenceDescriptor(EjbReferenceDescriptor ejbReference)
Removes the given reference to an ejb.

        removeEjbReferenceDescriptor((EjbReference) ejbReference);        
    
public voidremoveEjbReferenceDescriptor(com.sun.enterprise.deployment.types.EjbReference ejbReference)

	this.getEjbReferenceDescriptors().remove(ejbReference);
	ejbReference.setReferringBundleDescriptor(null);
	this.changed();
    
public voidremoveEnvironmentProperty(EnvironmentProperty environmentProperty)
Remove the given environment property

	this.getEnvironmentProperties().remove(environmentProperty);
	this.changed();
    
public voidremoveJmsDestinationReferenceDescriptor(JmsDestinationReferenceDescriptor jmsDestReference)

	this.getJmsDestinationReferenceDescriptors().remove(jmsDestReference);
	this.changed();
    
public voidremoveMessageDestinationReferenceDescriptor(MessageDestinationReferenceDescriptor msgDestRef)

        this.getMessageDestinationReferenceDescriptors().remove(msgDestRef);
        this.changed();
    
public voidremoveResourceReferenceDescriptor(ResourceReferenceDescriptor resourceReference)
Removes the given resource reference from this app client.

	this.getResourceReferenceDescriptors().remove(resourceReference);
	this.changed();
    
public voidremoveServiceReferenceDescriptor(ServiceReferenceDescriptor serviceRef)

        this.getServiceReferenceDescriptors().remove(serviceRef);
        this.changed();
    
public voidsetCallbackHandler(java.lang.String handler)
Set the classname of the callback handler.

	callbackHandler = handler;
	this.changed();
     
public voidsetJavaWebStartAccessDescriptor(com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptor descr)

        descr.setBundleDescriptor(this);
        jwsAccessDescriptor = descr;
        this.changed();
    
public voidsetMainClassName(java.lang.String mainClassName)
Sets the main classname of this app client.

	this.mainClassName = mainClassName;
	this.changed();
    
public voidvisit(com.sun.enterprise.deployment.util.DescriptorVisitor aVisitor)
visit the descriptor and all sub descriptors with a DOL visitor implementation

param
aVisitor a visitor to traverse the descriptors

        if (aVisitor instanceof AppClientVisitor) {
            visit((AppClientVisitor) aVisitor);
        } else {
            super.visit(aVisitor);
        }
    
public voidvisit(com.sun.enterprise.deployment.util.AppClientVisitor aVisitor)
visit the descriptor and all sub descriptors with a DOL visitor implementation

param
aVisitor a visitor to traverse the descriptors

        aVisitor.accept(this);

        // Visit all injectables first.  In some cases, basic type information
        // has to be derived from target inject method or inject field.
        for(InjectionCapable injectable : getInjectableResources(this)) {
            aVisitor.accept(injectable);
        }

        Set ejbRefs = getEjbReferenceDescriptors();
        for (Iterator itr = ejbRefs.iterator();itr.hasNext();) {
            aVisitor.accept((EjbReference) itr.next());
        }

        for (Iterator itr=getResourceReferenceDescriptors().iterator();
             itr.hasNext();) {
            ResourceReferenceDescriptor next = 
                (ResourceReferenceDescriptor) itr.next();
            aVisitor.accept(next);
        }

        for (Iterator itr=getJmsDestinationReferenceDescriptors().iterator();
             itr.hasNext();) {
            JmsDestinationReferenceDescriptor next = 
                (JmsDestinationReferenceDescriptor) itr.next();
            aVisitor.accept(next);
        }

        Set msgDestRefs = getMessageDestinationReferenceDescriptors(); 
        for (Iterator itr = msgDestRefs.iterator();itr.hasNext();) {
            aVisitor.accept((MessageDestinationReferencer) itr.next());
        }

        for (Iterator itr = getMessageDestinations().iterator();
                itr.hasNext();) {
            MessageDestinationDescriptor msgDestDescriptor =
                (MessageDestinationDescriptor)itr.next();
            aVisitor.accept(msgDestDescriptor);
        }

        Set serviceRefs = getServiceReferenceDescriptors();
        for (Iterator itr = serviceRefs.iterator();itr.hasNext();) {
            aVisitor.accept((ServiceReferenceDescriptor) itr.next());
        }