FileDocCategorySizeDatePackage
Application.javaAPI DocGlassfish v2 API71885Fri May 04 22:31:20 BST 2007com.sun.enterprise.deployment

Application

public class Application extends RootDeploymentDescriptor implements Roles, com.sun.enterprise.util.NotificationListener, com.sun.enterprise.deployment.types.RoleMappingContainer
Objects of this type encapsulate the data and behaviour of a J2EE application.
author
Danny Coward

Fields Summary
private static final String
LIBRARY_DIRECTORY_DEFAULT_VALUE
default value for the library-directory element
private static final String
PERSISTENCE_UNIT_NAME_SEPARATOR
private String
generatedXMLDir
Store generated XML dir to be able to get the generated WSDL
private Set
modules
private long
uniqueId
unique id for this application
private boolean
virtual
represents the virtual status of this application object
private Boolean
passByReference
represents whether all ejb modules in an application will be pass by value or pass by reference
private Hashtable
cmpDescriptors
private boolean
isDirty
private com.sun.enterprise.deployment.interfaces.SecurityRoleMapper
roleMapper
private String
registrationName
name used to register this application
private String
realm
private Map
entityManagerFactories
private Set
entityManagerFactoryUnitNames
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
private Set
appRoles
private String
libraryDirectory
private List
roleMaps
private boolean
loadedFromApplicationXml
private List
resourceList
static Logger
_logger
Constructors Summary
public Application(String name, File jar)
Creates a new application object with the diven display name and file.

param
name the display name of the application
the
file object used to initialize the archivist.


                                     
         
	super(name, localStrings.getLocalString(
						"enterprise.deployment.application.description",
						"Application description"));
    
public Application()

	super("", localStrings.getLocalString(
						"enterprise.deployment.application.description",
						"Application description"));
    
Methods Summary
public voidaddAppRole(SecurityRoleDescriptor descriptor)

        Role role = new Role(descriptor.getName());
        role.setDescription(descriptor.getDescription());
        getAppRoles().add(role);
    
public voidaddApplication(com.sun.enterprise.deployment.Application application)
Add all the deployment information about the given application to me.

       for (Iterator itr = application.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    this.addEjbBundleDescriptor(ejbBundleDescriptor);
	}
	 for (Iterator itr = application.getWebBundleDescriptors().iterator(); itr.hasNext();) {
	    WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) itr.next();
	    this.addWebBundleDescriptor(webBundleDescriptor);
	}
	for (Iterator itr = application.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
	    ApplicationClientDescriptor acd = (ApplicationClientDescriptor) itr.next();
	    this.addApplicationClientDescriptor(acd);
	}
        for (Iterator itr = application.getRarDescriptors().iterator(); itr.hasNext();) {
	    ConnectorDescriptor rarDescriptor = (ConnectorDescriptor) itr.next();
	    this.addRarDescriptor(rarDescriptor);
	}
    
public voidaddApplicationClientDescriptor(ApplicationClientDescriptor applicationClientDescriptor)
Add deplyoment information about an application client.

        addBundleDescriptor(applicationClientDescriptor);
    
private voidaddBundleDescriptor(BundleDescriptor bundleDescriptor)

        ModuleDescriptor newModule = bundleDescriptor.getModuleDescriptor();
        addModule(newModule);
    
public voidaddDescriptor(java.lang.Object descriptor)

        if (descriptor instanceof EjbBundleDescriptor) {
            addEjbBundleDescriptor((EjbBundleDescriptor) descriptor);
        }
        if (descriptor instanceof WebBundleDescriptor) {
            addWebBundleDescriptor((WebBundleDescriptor) descriptor);
        }        
        if (descriptor instanceof ConnectorDescriptor) {
            addRarDescriptor((ConnectorDescriptor) descriptor);
        }        
    
public voidaddEjbBundleDescriptor(EjbBundleDescriptor ejbBundleDescriptor)
Adds a new Enterprise bean to me.

        addBundleDescriptor(ejbBundleDescriptor);
    
public voidaddEntityManagerFactory(java.lang.String unitName, java.lang.String persistenceRootUri, javax.persistence.EntityManagerFactory emf)
Set the physical entity manager factory for a persistence unit within this application. This method takes a parameter called persistenceRootUri to support for fully-qualified persistence-unit-name syntax within persistence-unit-refs and persistence-context-refs. The syntax is similar to ejb-link and messge-destination-link. See (EJB 3 core spec: 15.10.2)

param
unitName: Name of the persistence-unit
param
persistenceRootUri: uri of the root of the persistence.xml (excluding META-INF) in which the persistence unit was defined. This uri is relative to the top of the .ear.
param
emf: an entity manager factory.


        String fullyQualifiedUnitName = persistenceRootUri + 
            PERSISTENCE_UNIT_NAME_SEPARATOR + unitName;

        // Always allow fully qualified lookup.
        entityManagerFactories.put(fullyQualifiedUnitName, emf);

        // Allow unqualified lookup, unless there are multiple .ear level
        // persistence units declaring the same persistence unit name. In that
        // case, only a fully-qualified lookup will work.  Note that even
        // though the entity manager factory map might contain more than one
        // key pointing to the same entity manager factory, the behavior
        // of getEntityManagerFactories() is not affected since it returns a Set.
        if( entityManagerFactoryUnitNames.contains(unitName) ) {
            entityManagerFactories.remove(unitName);
        } else {
            entityManagerFactories.put(unitName, emf);
            entityManagerFactoryUnitNames.add(unitName);
        }
    
public voidaddModule(com.sun.enterprise.deployment.util.ModuleDescriptor descriptor)

        modules.add(descriptor);
        if (descriptor.getDescriptor()!=null) {
	    descriptor.getDescriptor().addNotificationListener(this);
            descriptor.getDescriptor().setApplication(this);
        }
        this.changed(true);
    
public voidaddRarDescriptor(ConnectorDescriptor rarDescriptor)
Add a RAR descriptor to this application.

param
RarDescriptor the Rar descriptor to add

        addBundleDescriptor(rarDescriptor);
    
public voidaddRole(com.sun.enterprise.deployment.Role role)
Adds a new abstract role

        for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();){
             WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
             wbd.addRole(role);
        }
        for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();){
             EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
             ejbd.addRole(role);
        }
	changed();
    
public voidaddSecurityRoleMapping(com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping roleMapping)

        roleMaps.add(roleMapping);
    
public voidaddWebBundleDescriptor(WebBundleDescriptor webBundleDescriptor)
Add a web bundle descriptor to this application.

param
webBundleDescriptor the web bundle descriptor to add

        addBundleDescriptor(webBundleDescriptor);
    
public voidchanged(boolean dirtyChange)
Calls changed() and sets the dirty flag.

	if (dirtyChange) {
	    this.isDirty = true;
	}
	super.changed();
    
public voidchanged()
Called when my data changes and causes notification.

	NotificationEvent ne = new NotificationEvent(this, DESCRIPTOR_CHANGED, this);
	 
	Vector listenersClone = null;
	synchronized (listeners) {
	    listenersClone = (Vector) listeners.clone();
	}
	for (Enumeration e = listenersClone.elements(); e.hasMoreElements();) {
	    NotificationListener nl = (NotificationListener) e.nextElement();
	    nl.notification(ne);   
	}
    
public booleancontainsCMPEntity()

return
true if this bundle descriptor contains at least one CMP EntityBean

	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
            if (((EjbBundleDescriptor) itr.next()).containsCMPEntity())
                return true;
        }
        return false;
    
public static com.sun.enterprise.deployment.ApplicationcreateApplication(java.lang.String name, com.sun.enterprise.deployment.util.ModuleDescriptor newModule)
Creates a new application to hold a standalone module

param
the application name
param
the standalone module descriptor
return
the application

    
        // create a new empty application
        Application application = new Application();
	application.setVirtual(true);
        if (name==null && newModule.getDescriptor()!=null) {
            name = newModule.getDescriptor().getDisplayName();
            
        }
        if (name!=null) {
            application.setDisplayName(name);
            application.setName(name);
        }
        
        // add the module to it
        newModule.setStandalone(true);
        newModule.setArchiveUri(name);
        if (newModule.getDescriptor()!=null) {
            newModule.getDescriptor().setApplication(application);
        }
        application.addModule(newModule);
        
        return application;
    
public static com.sun.enterprise.deployment.ApplicationcreateApplication(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, boolean introspect)
This method creates a top level Application object for an ear.

param
archive the archive for the application
param
introspect whether or not to create via introspection. if true, an application object is constructed in the absence of an application.xml. if false, it is constructed from reading the application.xml from the archive.

        return createApplication(archive, introspect, false);
    
public static com.sun.enterprise.deployment.ApplicationcreateApplication(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, boolean introspect, boolean directory)
This method creates a top level Application object for an ear.

param
archive the archive for the application
param
introspect whether or not to create via introspection. if true, an application object is constructed in the absence of an application.xml. if false, it is constructed from reading the application.xml from the archive.
param
directory whether the application is packaged as a directory

        if (introspect) {
            return getApplicationFromIntrospection(archive, directory);
        } else {
            return getApplicationFromAppXml(archive);
        }
    
private static java.lang.StringderiveArchiveUri(java.lang.String appRoot, java.io.File subModule, boolean deploydir)


        //if deploydir, revert the name of the directory to
        //the format of foo/bar/voodoo.ext (where ext is war/rar/jar)
        if (deploydir) {
            return FileUtils.revertFriendlyFilename(subModule.getName());
        }

        //if archive deploy, need to make sure all of the directory
        //structure is correctly included
        String uri = subModule.getAbsolutePath().substring(appRoot.length()+1);
        return uri.replace(File.separatorChar, '/");
    
public voiddoneOpening()
Called when I have just been opened

	this.isDirty = false;
	this.changed(false);
    
voiddoneSaving()

	this.isDirty = false;
	this.changed(false);
    
public java.util.SetgetAppRoles()
Return the set of com.sun.enterprise.deployment.Role objects I have (the ones defined in application xml).

        if (this.appRoles == null) {
            this.appRoles = new OrderedSet();
        }
        return this.appRoles;
    
public ApplicationClientDescriptorgetApplicationClientByName(java.lang.String name)
Obtain the application client in this application of the given display name. If the application client is not present, throw an IllegalArgumentException.

return
the ApplicationClientDescriptor object with the given display name

	for (Iterator itr = this.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
	    ApplicationClientDescriptor next = (ApplicationClientDescriptor) itr.next();
	    if (next.getDisplayName().equals(name)) {
		return next;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
						"enterprise.deployment.exceptionapphasnoappclientname",
						"This application has no application clients of name {0}", new Object []{name}));
    
public ApplicationClientDescriptorgetApplicationClientByUri(java.lang.String name)
Obtain an application client descriptor in this application of the given URI. If the appclient is not present, throw an IllegalArgumentException.

        Descriptor desc = getModuleByTypeAndUri(ModuleType.CAR, name);
        if (desc!=null && desc instanceof ApplicationClientDescriptor) {
            return (ApplicationClientDescriptor) desc;
        }         
	throw new IllegalArgumentException(name);
    
public java.util.SetgetApplicationClientDescriptors()
Return the Set of app client deploymenbt objects.

        return getBundleDescriptors(ModuleType.CAR);
    
private static com.sun.enterprise.deployment.ApplicationgetApplicationFromAppXml(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)

        ApplicationArchivist archivist = new ApplicationArchivist();
        archivist.setXMLValidation(false);

        // read the standard deployment descriptors
        Application application = null;
        try {
            application = 
                (Application) archivist.readStandardDeploymentDescriptor(archive);
        } catch (Exception ex) {
            //@@@ i18n
            _logger.log(Level.SEVERE, 
                "Error loading application.xml from " + archive.getArchiveUri());
            _logger.log(Level.SEVERE, ex.getMessage());
        }

        return application;
    
private static com.sun.enterprise.deployment.ApplicationgetApplicationFromIntrospection(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, boolean directory)
This method introspect an ear file and populate the Application object. We follow the Java EE platform specification, Section EE.8.4.2 to determine the type of the modules included in this application.

param
archive the archive representing the application root
param
directory whether this is a directory deployment

        String appRoot = archive.getArchiveUri(); //archive is a directory
        Application app = new Application();
        app.setLoadedFromApplicationXml(false);
        app.setVirtual(false);

        //name of the file without its extension
        String appName = appRoot.substring(
                            appRoot.lastIndexOf(File.separatorChar)+1);
        app.setName(appName);

        List<AbstractArchive> unknowns = new ArrayList();
        File[] files = getEligibleEntries(new File(appRoot), directory);
        for (File subModule : files) {
            AbstractArchive subArchive = null;
            try {
                try {
                    if (!directory) {
                        subArchive = new InputJarArchive();
                        ((InputJarArchive)subArchive).open(subModule.getAbsolutePath());
                    } else {
                        subArchive = new FileArchive();
                        ((FileArchive)subArchive).open(subModule.getAbsolutePath());
                    }
                } catch (IOException ex) {
                    _logger.log(Level.WARNING, ex.getMessage());
                }

                //for archive deployment, we check the sub archives by its
                //file extension; for directory deployment, we check the sub
                //directories by its name. We are now supporting directory
                //names with both "_suffix" and ".suffix".

                //Section EE.8.4.2.1.a
                String name = subModule.getName();
                String uri = deriveArchiveUri(appRoot, subModule, directory);
                if ( (!directory && name.endsWith(".war")) 
                        || (directory && 
                            (name.endsWith("_war") || 
                             name.endsWith(".war"))) ) {
                    String contextRoot = 
                    uri.substring(uri.lastIndexOf('/")+1, uri.lastIndexOf('."));
                    ModuleDescriptor md = new ModuleDescriptor();
                    md.setArchiveUri(uri);
                    md.setModuleType(ModuleType.WAR);
                    md.setContextRoot(contextRoot);
                    app.addModule(md);
                }
                //Section EE.8.4.2.1.b
                else if ( (!directory && name.endsWith(".rar"))
                            || (directory && 
                                (name.endsWith("_rar") || 
                                 name.endsWith(".rar"))) ) {
                    ModuleDescriptor md = new ModuleDescriptor();
                    md.setArchiveUri(uri);
                    md.setModuleType(ModuleType.RAR);
                    app.addModule(md);
                } 
                else if ( (!directory && name.endsWith(".jar")) 
                            || (directory && 
                                (name.endsWith("_jar") || 
                                 name.endsWith(".jar"))) ) {
                    try {
                        //Section EE.8.4.2.1.d.i
                        AppClientArchivist acArchivist = new AppClientArchivist();
                        if (acArchivist.hasStandardDeploymentDescriptor(subArchive)
                            || acArchivist.hasRuntimeDeploymentDescriptor(subArchive)
                            || acArchivist.getMainClassName(subArchive.getManifest()) != null) {

                            ModuleDescriptor md = new ModuleDescriptor();
                            md.setArchiveUri(uri);
                            md.setModuleType(ModuleType.CAR);
                            md.setManifest(subArchive.getManifest());
                            app.addModule(md);
                            continue;
                        }

                        //Section EE.8.4.2.1.d.ii
                        EjbArchivist ejbArchivist  = new EjbArchivist();
                        if (ejbArchivist.hasStandardDeploymentDescriptor(subArchive)
                            || ejbArchivist.hasRuntimeDeploymentDescriptor(subArchive)) {

                            ModuleDescriptor md = new ModuleDescriptor();
                            md.setArchiveUri(uri);
                            md.setModuleType(ModuleType.EJB);
                            app.addModule(md);
                            continue;
                        }
                    } catch (IOException ex) {
                        _logger.log(Level.WARNING, ex.getMessage());
                    }

                    //Still could not decide between an ejb and a library
                    unknowns.add(subArchive);
                } else {
                    //ignored
                }
            } finally {
                if (subArchive != null) {
                    try {
                        subArchive.close();
                    } catch (IOException ioe) {
                        _logger.log(Level.WARNING, localStrings.getLocalString("enterprise.deployment.errorClosingSubArch", "Error closing subarchive {0}", new Object[] {subModule.getAbsolutePath()}), ioe);
                    }
                }
            }
        }

        if (unknowns.size() > 0) {
            EjbComponentAnnotationDetector detector = 
                    new EjbComponentAnnotationDetector();
            for (int i = 0; i < unknowns.size(); i++) {
                File jarFile = new File(unknowns.get(i).getArchiveUri());
                try {
                    if (detector.hasAnnotationInArchive(unknowns.get(i))) {
                        String uri = deriveArchiveUri(appRoot, jarFile, directory);
                        //Section EE.8.4.2.1.d.ii, alas EJB
                        ModuleDescriptor md = new ModuleDescriptor();
                        md.setArchiveUri(uri);
                        md.setModuleType(ModuleType.EJB);
                        app.addModule(md);
                    }
                } catch (IOException ex) {
                    _logger.log(Level.WARNING, ex.getMessage());
                }
            }
        }

        return app;
    
public java.util.SetgetArchivableDescriptors()
Return all my subcomponents that have a file format (EJB, WAR and AppCLient JAR).

	Set archivableDescriptors = new HashSet();
	archivableDescriptors.addAll(this.getEjbBundleDescriptors());
	archivableDescriptors.addAll(this.getWebBundleDescriptors());
	archivableDescriptors.addAll(this.getApplicationClientDescriptors());
	archivableDescriptors.addAll(this.getRarDescriptors());
	return archivableDescriptors;
    
public java.util.SetgetBundleDescriptors(javax.enterprise.deploy.shared.ModuleType type)
Obtain a full set of bundle descriptors for a particular type

param
type the bundle descriptor type requested
return
the set of bundle descriptors

        if (type==null) {
            return null;
        }
        Set bundleSet = new HashSet();
        for (Iterator bundles = getModules();bundles.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
            if (type.equals(aModule.getModuleType())) {
                if (aModule.getDescriptor()!=null) {
                    bundleSet.add(aModule.getDescriptor());
                } else {
                    DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri());
                }
            }
        }
        return bundleSet;
    
public java.util.SetgetBundleDescriptors()
Obtain a set of all bundle descriptors, regardless of type

return
the set of bundle descriptors

        Set bundleSet = new HashSet();
        for (Iterator bundles = getModules();bundles.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
                if (aModule.getDescriptor()!=null) {
                    bundleSet.add(aModule.getDescriptor());
                } else {
                    DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri());
                }
        }
        return bundleSet;
    
public EjbCMPEntityDescriptorgetCMPDescriptorFor(java.lang.String className)
Return the EjbCMPEntityDescriptor for a bean for the given classname. It is assumed that there is a 1-to-1 mapping from class to descriptor. This is called at runtime from the Persistence Manager.

	if ( cmpDescriptors == null ) {
	    cmpDescriptors = new Hashtable();
	    Iterator ejbBundles = getEjbBundleDescriptors().iterator();
	    while ( ejbBundles.hasNext() ) {
		EjbBundleDescriptor bundle = (EjbBundleDescriptor)ejbBundles.next();
		Iterator ejbs = bundle.getEjbs().iterator();
		while ( ejbs.hasNext() ) {
		    EjbDescriptor ejb = (EjbDescriptor)ejbs.next();
		    if ( ejb instanceof EjbCMPEntityDescriptor )
			cmpDescriptors.put(ejb.getEjbImplClassName(), ejb);
		}
	    }
	}
        return (EjbCMPEntityDescriptor)cmpDescriptors.get(className);
    
public java.lang.ClassLoadergetClassLoader()

return
the class loader associated with this application

        if (classLoader==null) {
            throw new RuntimeException("No class loader associated with application " + getName());
        }
        return classLoader;
    
public java.lang.StringgetDefaultSpecVersion()

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


        
                     
       
        return ApplicationNode.SPEC_VERSION;
    
public EjbBundleDescriptorgetEjbBundleByName(java.lang.String name)
Obtain the EJB-JAR in this application of the given name. If the JAR is not present, throw an IllegalArgumentException.

return
the EjbBundleDescriptor object with the given name

	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    if (ejbBundleDescriptor.getDisplayName().equals(name))
		return ejbBundleDescriptor;
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
			"enterprise.deployment.exceptionapphasnoejbjarnamed",
			"This application has no ejb jars of name {0}", 
			new Object []{name}));
    
public EjbBundleDescriptorgetEjbBundleByUri(java.lang.String name)
Get EJB-JAR of the given URI (filename within EAR)

        Descriptor desc = getModuleByTypeAndUri(ModuleType.EJB, name);
        if (desc!=null && desc instanceof EjbBundleDescriptor) {
            return (EjbBundleDescriptor) desc;
        }
	throw new IllegalArgumentException(localStrings.getLocalString(
			"enterprise.deployment.exceptionapphasnoejbjarnamed",
			"This application has no ejb jars of name {0}", 
			new Object []{name}));
    
public java.util.SetgetEjbBundleDescriptors()
Obtain the full set of all the Ejb JAR deployment information in this application.

return
the Set of EjbBundleDescriptor objects.

        return getBundleDescriptors(ModuleType.EJB);
    
public EjbDescriptorgetEjbByName(java.lang.String ejbName)
Obtain the EJB in this application of the given display name. If the EJB is not present, throw an IllegalArgumentException.

param
ejbName the name of the bean
return
the EjbDescriptor object with the given display name

	EjbDescriptor ejbDescriptor = null;
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    if (ejbBundleDescriptor.hasEjbByName(ejbName)) {
		return ejbBundleDescriptor.getEjbByName(ejbName);
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
						"enterprise.deployment.exceptionapphasnobeannamed",
						"This application has no beans of name {0}", new Object []{ejbName}));
    
public intgetEjbComponentCount()
The number of EJB JARs in this application.

return
the number of EJB JARS

	int count = 0;
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
	    count = count + ejbd.getEjbs().size();
	}
	return count;
    
public java.util.VectorgetEjbDescriptors()
Return the Vector of ejb deployment objects.

	Vector ejbDescriptors = new Vector();
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    ejbDescriptors.addAll(ejbBundleDescriptor.getEjbs());
	}
        
	return ejbDescriptors;
    
public java.util.VectorgetEjbReferenceDescriptors()
The Vector of EJB references in all subcomponents of this application.

return
The Vector of EJB references

	Vector ejbReferenceDescriptors = new Vector();
	for (Iterator itr = this.getNamedDescriptors().iterator(); itr.hasNext();) {
	    Object next = itr.next();
	    if (next instanceof EjbReferenceDescriptor) {
		ejbReferenceDescriptors.addElement(next);
	    }
	}
	return ejbReferenceDescriptors;
    
private static java.io.File[]getEligibleEntries(java.io.File appRoot, boolean deploydir)


        //For deploydir, all modules are exploded at the top of application root
        if (deploydir) {
            return appRoot.listFiles(new DirectoryIntrospectionFilter());
        }

        //For archive deploy, recursively search the entire package
        Vector files = new Vector();
        getListOfFiles(appRoot, files, 
                new ArchiveIntrospectionFilter(appRoot.getAbsolutePath()));
        return (File[]) files.toArray(new File[files.size()]);  
    
public java.util.SetgetEntityManagerFactories()
Returns the set of physical entity manager factories associated with persistence units in this application.


        return new HashSet<EntityManagerFactory>
            (entityManagerFactories.values());

    
public javax.persistence.EntityManagerFactorygetEntityManagerFactory(java.lang.String unitName, BundleDescriptor declaringModule)
Retrieve the physical entity manager factory associated with the unitName of an application-level persistence unit. Returns null if no matching entry is found.

        
        String lookupString = unitName;

        int separatorIndex = 
            unitName.lastIndexOf(PERSISTENCE_UNIT_NAME_SEPARATOR);
        
        if( separatorIndex != -1 ) {
            String unqualifiedUnitName = 
                unitName.substring(separatorIndex + 1);
            String path = unitName.substring(0, separatorIndex);

            String persistenceRootUri = getTargetUri(declaringModule, path);

            lookupString = persistenceRootUri + 
                PERSISTENCE_UNIT_NAME_SEPARATOR + unqualifiedUnitName;
        }

        return entityManagerFactories.get(lookupString);
    
public java.lang.StringgetGeneratedXMLDirectory()
Returns the generated XML directory for this app

        return generatedXMLDir;
    
public java.util.SetgetJndiNameEnvironments()
Obtain the full set of all the subcomponents of this application that use a JNDI name environment..

return
the Set of JndiNameEnvironment objects.

	Set jndiNameEnvironments = new HashSet();
	jndiNameEnvironments.addAll(this.getWebBundleDescriptors());
	jndiNameEnvironments.addAll(this.getApplicationClientDescriptors());
	jndiNameEnvironments.addAll(this.getEjbDescriptors());
	return jndiNameEnvironments;
    
public java.lang.StringgetLibraryDirectory()
Returns an "intelligent" value for the library directory setting, meaning the current value if it has been set to a non-null, non-empty value; the default value if the value has never been set, and null if the value has been set to empty.

return
String value of the library directory setting

        if (libraryDirectory != null) {
            return (libraryDirectory.length() == 0) ? null : libraryDirectory;
        } else {
            return LIBRARY_DIRECTORY_DEFAULT_VALUE;
        }
    
public java.lang.StringgetLibraryDirectoryRawValue()

        return libraryDirectory;
    
private static voidgetListOfFiles(java.io.File directory, java.util.Vector files, java.io.FilenameFilter filter)


        File[] list = directory.listFiles(filter);
        for (int i=0;i<list.length;i++) {
            if (!list[i].isDirectory()) {
                files.add(list[i]);
            } else { 
				getListOfFiles(list[i], files, filter);
            }
        }
    
public DescriptorgetModuleByTypeAndUri(javax.enterprise.deploy.shared.ModuleType type, java.lang.String uri)

return
a bundle descriptor in this application identified by its type and uri
param
type the module type
param
uri the module path in the application archive

        for (Iterator itr = getModules();itr.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) itr.next();
            if (aModule.getModuleType().equals(type)) {
                if (aModule.getArchiveUri().equals(uri)) {
                    return aModule.getDescriptor();
                }
            }
        }
        return null;
    
public DescriptorgetModuleByUri(java.lang.String uri)
Lookup module by uri.

param
uri the module path in the application archive
return
a bundle descriptor in this application identified by uri or null if not found.

        ModuleDescriptor md = getModuleDescriptorByUri(uri);
        if (md!=null) {
            return md.getDescriptor();
        }
        return null;
    
public com.sun.enterprise.deployment.util.ModuleDescriptorgetModuleDescriptorByUri(java.lang.String uri)
Lookup module by uri.

param
uri the module path in the application archive
return
a bundle descriptor in this application identified by uri or null if not found.

        for (Iterator itr = getModules();itr.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) itr.next();
            if (aModule.getArchiveUri().equals(uri)) {
                return aModule;
            }
        }
        return null;
    
public java.lang.StringgetModuleID()

return
the module ID for this module descriptor

        return moduleID;
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type for this bundle descriptor

        return  ModuleType.EAR;
    
public java.util.IteratorgetModules()
Obtain a full set of module descriptors

return
the set of bundle descriptors

        return modules.iterator();
    
public java.util.IteratorgetModulesByType(javax.enterprise.deploy.shared.ModuleType type)
Obtain a full set of module descriptors for a particular type

param
type the bundle descriptor type requested
return
the set of bundle descriptors

        if (type==null) {
            return null;
        }
        Set moduleSet = new HashSet();
        for (Iterator bundles = getModules();bundles.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
            if (type.equals(aModule.getModuleType())) {
		moduleSet.add(aModule);
	    }
	}
	return moduleSet.iterator();
    
public java.util.CollectiongetNamedDescriptors()
return the set of descriptors with jndi names.

	Collection namedDescriptors = new Vector();
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    namedDescriptors.addAll(ejbBundleDescriptor.getNamedDescriptors());
	}
	for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
	    WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) itr.next();
	    namedDescriptors.addAll(webBundleDescriptor.getNamedDescriptors());
	}
	for (Iterator itr = this.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
	    ApplicationClientDescriptor applicationClientDescriptor = (ApplicationClientDescriptor) itr.next();
	    namedDescriptors.addAll(applicationClientDescriptor.getNamedDescriptors());
	}
	return namedDescriptors;
    
    
public java.util.VectorgetNamedReferencePairs()
Return all the Named reference pairs I have. This is a Vector of NamedReferenceDescriptors - essentially a mapping of components to the Named Objects they reference. E.g.: ejb -> ejb ejb - resource reference ejb - ejb ref ejb1 - ejb ref

	Vector pairs = new Vector();
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    pairs.addAll(ejbBundleDescriptor.getNamedReferencePairs());
	}
	for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
	    WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) itr.next();
	    pairs.addAll(webBundleDescriptor.getNamedReferencePairs());
	}
	for (Iterator itr = this.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
	    ApplicationClientDescriptor applicationClientDescriptor = (ApplicationClientDescriptor) itr.next();
	    pairs.addAll(applicationClientDescriptor.getNamedReferencePairs());
	}
	return pairs;
    
public booleangetPassByReference()
Gets the value of pass-by-reference property for this application Checks to see if the pass-by-reference property is defined. If this application's pass-by-reference property is defined, this method returns the value of the application's pass-by-reference property. Otherwise, if the application's pass-by-reference property is undefined, this method returns a default value of false.

return
boolean pass-by-reference property for this application

        boolean passByReference = false;
        
        if (this.isPassByReferenceDefined()) {
            passByReference = this.passByReference.booleanValue();
        }
        return passByReference;
    
public intgetRarComponentCount()

        return this.getRarDescriptors().size();
    
public ConnectorDescriptorgetRarDescriptorByUri(java.lang.String name)
Obtain the RAR in this application of the given URI. If the RAR is not present, throw an IllegalArgumentException.

        Descriptor desc = getModuleByTypeAndUri(ModuleType.RAR, name);
        if (desc!=null && desc instanceof ConnectorDescriptor) {
            return (ConnectorDescriptor) desc;
        }         
	throw new IllegalArgumentException(name);
    
public java.util.SetgetRarDescriptors()
Obtain the full set of all the RARs in this application.

return
the Set of RarDescriptor objects.

        return getBundleDescriptors(ModuleType.RAR);
    
public java.lang.StringgetRealm()

return
the realm for this application

        return realm;
    
public java.lang.StringgetRegistrationName()
Returns the registration name of this application.

return
the registration name of this application

        if (registrationName!=null) {
            return registrationName;
        } else {
            return getName();
        }
    
public BundleDescriptorgetRelativeBundle(BundleDescriptor origin, java.lang.String relativeTargetUri)
Get a target bundle descriptor based on an input bundle descriptor and a relative uri from the perspective of the input bundle descriptor.

param
origin bundle descriptor within this application
param
relativeTargetUri relative uri from the given bundle descriptor to another bundle within the application.
return
target BundleDescriptor or null if not found.

        String targetBundleUri = getTargetUri(origin, relativeTargetUri);
                                              
        BundleDescriptor targetBundle = null;

        if( targetBundleUri != null ) {
            Descriptor module = getModuleByUri(targetBundleUri);
            targetBundle = (module instanceof BundleDescriptor) ?
                (BundleDescriptor) module : null;
        }

        return targetBundle;
    
public java.lang.StringgetRelativeUri(BundleDescriptor origin, BundleDescriptor target)
Return the relative uri between two modules, from the perspective of the first bundle.

return
relative uri or empty string if the two bundles are the same


        String originUri = origin.getModuleDescriptor().getArchiveUri();
        String targetUri = target.getModuleDescriptor().getArchiveUri();

        StringTokenizer tokenizer = new StringTokenizer(originUri, "/");
        int numTokens = tokenizer.countTokens();       
        int numSeparators = (numTokens > 0) ? (numTokens - 1) : 0;

        StringBuffer relativeUri = new StringBuffer();

        // The simplest way to compute a relative uri is to add one "../"
        // for each sub-path in the origin URI, then add the target URI.
        // It's possible for the result to not be normalized if the origin
        // and target have at least one common root, but that shouldn't
        // matter as long as when the relative URI is resolved against the
        // origin it produces the target.
        for(int i = 0; i < numSeparators; i++) {
            relativeUri.append("../");
        }             
        
        relativeUri.append(targetUri);

        return relativeUri.toString();
    
public java.util.ListgetResourceList()

        return resourceList; 
    
public java.util.SetgetResourceReferenceDescriptors()
Return the Set of all reource references that my components have.

	Set resourceReferences = new HashSet();
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
	    resourceReferences.addAll(ejbd.getResourceReferenceDescriptors());
	}
	return resourceReferences;
    
public com.sun.enterprise.deployment.interfaces.SecurityRoleMappergetRoleMapper()
Return my mapping of rolename to users and groups on a particular server.

	if (this.roleMapper == null) {
            SecurityRoleMapperFactory factory = SecurityRoleMapperFactoryMgr.getFactory();
            if (factory==null) {
                _logger.log(Level.FINE, "SecurityRoleMapperFactory NOT set.");
            } else {
	        this.roleMapper = factory.getRoleMapper(this.getName());
            }                    
	}
	return this.roleMapper;
    
public java.util.SetgetRoles()
Return the set of roles used in this application. Currently, for release 1.0, it is an aggregation of all the roles in the sub-modules of the application.

return
the Set of roles in the application.

	Set roles = new HashSet();
	for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
	    WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
            if (wbd!=null) {
                roles.addAll(wbd.getRoles());
            }
	}
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
            if (ejbd != null) {
                roles.addAll(ejbd.getRoles());
            }
	}
	return roles;
    
public java.util.ListgetSecurityRoleMappings()

        return roleMaps;
    
public java.util.SetgetServiceReferenceDescriptors()
Obtain the set of all service reference descriptors for components in this application.

        Set serviceRefs = new HashSet();
        Set jndiNameEnvironments = this.getJndiNameEnvironments();
        for(Iterator iter = jndiNameEnvironments.iterator(); iter.hasNext();) {
            JndiNameEnvironment next = (JndiNameEnvironment) iter.next();
            serviceRefs.addAll(next.getServiceReferenceDescriptors());
        }
        return serviceRefs;
    
public EjbDescriptor[]getSortedEjbDescriptors()
Returns all the ejb descriptor in this application in ordered form. The comparison is done based on the descriptor's name.

return
all ejb descriptors in ordered form

        Vector ejbDesc  = getEjbDescriptors();
        EjbDescriptor[] descs = (EjbDescriptor[])ejbDesc.toArray(
                                    new EjbDescriptor[ejbDesc.size()]);

        // The sorting algorithm used by this api is a modified mergesort.
        // This algorithm offers guaranteed n*log(n) performance, and 
        // can approach linear performance on nearly sorted lists. 

        // since ejb name is only unique within a module, add the module uri
        // as the additional piece of information for comparison
        Arrays.sort(descs, 
            new Comparator() {
                public int compare(Object o1, Object o2) {
                    EjbDescriptor desc1 = (EjbDescriptor)o1;
                    EjbDescriptor desc2 = (EjbDescriptor)o2;
                    String moduleUri1 = desc1.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri();
                    String moduleUri2 = desc2.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri();
                    return (moduleUri1 + desc1.getName()).compareTo(
                            moduleUri2 + desc2.getName());
                }
            }
        );

        return descs;
    
public BundleDescriptorgetStandaloneBundleDescriptor()
if this application object is virtual, return the standalone bundle descriptor it is wrapping otherwise return null

return
the wrapped standalone bundle descriptor

	 if (isVirtual()) {
	     Iterator modules = getModules();
	     if (modules.hasNext()) {
		 ModuleDescriptor module = (ModuleDescriptor) modules.next();
		 if (modules.hasNext()) {
		     // this is an error, the application is virtual, 
		     // which mean a wrapper for a standalone module and 
		     // it seems I have more than one module in my list...
		     throw new IllegalStateException("Virtual application contains more than one module");
		 }
		 return module.getDescriptor();
	     }
	     return null;
	 } else {
	     return null;
	 }
     
public java.lang.StringgetTargetUri(BundleDescriptor origin, java.lang.String relativeTargetUri)
Get the uri of a target based on a source module and a a relative uri from the perspective of that source module.

param
origin bundle descriptor within this application
param
relativeTargetUri relative uri from the given bundle descriptor
return
target uri

        String targetUri = null;

        try {
            String archiveUri = origin.getModuleDescriptor().getArchiveUri();
            URI originUri = new URI(archiveUri);
            URI resolvedUri = originUri.resolve(relativeTargetUri);
            targetUri = resolvedUri.getPath();
        } catch(URISyntaxException use) {
            _logger.log(Level.FINE, "origin " + origin + " has invalid syntax",
                        use);
        }

        return targetUri;
    
public longgetUniqueId()
Returns the unique id used for this application.

return
unique id used for this application

        return this.uniqueId;
    
public WebBundleDescriptorgetWebBundleDescriptorByName(java.lang.String name)
Obtain the WAR in this application of the given display name. If the WAR is not present, throw an IllegalArgumentException.

return
the WebBundleDescriptor object with the given display name

	for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
	    WebBundleDescriptor next = (WebBundleDescriptor) itr.next();
	    if (next.getDisplayName().equals(name)) {
		return next;
	    }
	}
	throw new IllegalArgumentException(localStrings.getLocalString(
						"enterprise.deployment.exceptionapphasnowebappname",
						"This application has no web app of name {0}", new Object []{name}));
    
public WebBundleDescriptorgetWebBundleDescriptorByUri(java.lang.String name)
Get WAR of a given URI (filename within EAR)

        Descriptor desc = getModuleByTypeAndUri(ModuleType.WAR, name);
        if (desc!=null && desc instanceof WebBundleDescriptor) {
            return (WebBundleDescriptor) desc;
        }        
	throw new IllegalArgumentException(localStrings.getLocalString(
						"enterprise.deployment.exceptionapphasnowebappname",
						"This application has no web app of name {0}", new Object []{name}));
    
public java.util.SetgetWebBundleDescriptors()
Obtain the full set of all the WARs in this application.

return
the Set of WebBundleDescriptor objects.

        return getBundleDescriptors(ModuleType.WAR);
    
public intgetWebComponentCount()
The number of Web Components in this application. Current implementation only return the number of servlets inside the application, and not the JSPs since we cannot get that information from deployment descriptors.

return
the number of Web Components

	int count = 0;
	for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
	    WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
	    count = count + wbd.getWebDescriptors().size();
	}
	return count;
    
public java.util.SetgetWebServiceDescriptors()
Return a set of all com.sun.enterprise.deployment.WebService descriptors in the application.

        Set webServiceDescriptors = new HashSet();
        Set bundles = new HashSet();
        bundles.addAll(getEjbBundleDescriptors());
        bundles.addAll(getWebBundleDescriptors());
        for(Iterator iter = bundles.iterator(); iter.hasNext();) {
            BundleDescriptor next = (BundleDescriptor) iter.next();
            WebServicesDescriptor webServicesDesc = 
                next.getWebServices();
            webServiceDescriptors.addAll(webServicesDesc.getWebServices());
        }
        return webServiceDescriptors;
    
public booleanhasEjbByName(java.lang.String ejbName)
Return whether the application contains the given ejb by name..

param
ejbName the name of the bean
return
true if there is a bean matching the given name

	EjbDescriptor ejbDescriptor = null;
	for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
	    EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
	    if (ejbBundleDescriptor.hasEjbByName(ejbName)) {
		return true;
	    }
	}
	return false;
    
public booleanhasRuntimeInformation()
Return true if I have information to do with deployment on a particular operational environment.

	return true;
    
public booleanisApplication()

return
true if this module is an application object

		return true;
	
public booleanisDirty()
A flag to indicate that my data has changed since the last save.

	return this.isDirty;
    
public booleanisLoadedFromApplicationXml()

return
true if this Application is from reading application.xml from disk; false if this Application object is derived from the content of the ear file.

        return loadedFromApplicationXml;
    
public booleanisPassByReferenceDefined()

        boolean passByReferenceDefined = false;
        if (this.passByReference != null) {
            passByReferenceDefined = true;
        }
        return passByReferenceDefined;
    
public booleanisVirtual()
Returns the virtual status of this application.

return
true if this application obj represents a stand alone module

        return this.virtual;
    
public voidnotification(com.sun.enterprise.util.NotificationEvent ne)
I listen to my subcomponents for state changes..

	// so one of my descriptors is telling me it changed....
	// I actually pretend that its me that changed...
	
	this.changed(true);
    
public voidprint(java.lang.StringBuffer toStringBuffer)
A formatted String representing my state.

        toStringBuffer.append("Application");
	toStringBuffer.append("\n");
        super.print(toStringBuffer);
	toStringBuffer.append("\n smallIcon ").append(super.getSmallIconUri());
        for (Iterator itr = getModules();itr.hasNext();) {
            toStringBuffer.append("\n  Module : ");
            ((Descriptor)itr.next()).print(toStringBuffer);
        }
	toStringBuffer.append("\n EjbBundles: \n");
        if(this.getEjbBundleDescriptors() != null)
            printDescriptorSet(this.getEjbBundleDescriptors(),toStringBuffer);
	toStringBuffer.append("\n WebBundleDescriptors ");
        if(this.getWebBundleDescriptors() != null)
            printDescriptorSet(this.getWebBundleDescriptors(),toStringBuffer);
	toStringBuffer.append("\n applicationClientDescriptors ");
        if(this.getApplicationClientDescriptors() != null)
            printDescriptorSet(this.getApplicationClientDescriptors(),toStringBuffer);
	toStringBuffer.append("\n roles ").append(getRoles());
	toStringBuffer.append("\n RoleMapper ").append(this.getRoleMapper());
        toStringBuffer.append("\n Realm ").append(realm);
    
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 voidremoveApplicationClientDescriptor(ApplicationClientDescriptor applicationClientDescriptor)
Remove deplyoment information about an application client.

	this.getApplicationClientDescriptors().remove(applicationClientDescriptor);
	applicationClientDescriptor.removeNotificationListener(this);
	applicationClientDescriptor.setApplication(null);
	this.changed(true);
    
public voidremoveEjbBundleDescriptor(EjbBundleDescriptor ejbBundleDescriptor)
Remove the deployment information about an Enterprise Bean.

	this.getEjbBundleDescriptors().remove(ejbBundleDescriptor);
	ejbBundleDescriptor.removeNotificationListener(this);
	ejbBundleDescriptor.setApplication(null);
	this.changed(true);
    
public voidremoveModule(com.sun.enterprise.deployment.util.ModuleDescriptor descriptor)

	if (modules.contains(descriptor)) {
	    if (descriptor.getDescriptor() != null) {
		descriptor.getDescriptor().removeNotificationListener(this);
		descriptor.getDescriptor().setApplication(null);
	    }
	    modules.remove(descriptor);
	    this.changed(true);
	}
    
public voidremoveRarDescriptor(ConnectorDescriptor rarDescriptor)
Remove a rar descriptor from this application.

param
rarDescriptor the rar descriptor to remove

        rarDescriptor.removeNotificationListener(this);
	rarDescriptor.setApplication(null);
	this.getRarDescriptors().remove(rarDescriptor);
	this.changed(true);
    
public voidremoveRole(com.sun.enterprise.deployment.Role role)
Removes the given role.

        getAppRoles().remove(role);
        for (Iterator itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();){
	    WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next(); 
            wbd.removeRole(role); 
        } 
        for (Iterator itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();){
	    EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next(); 
            ejbd.removeRole(role); 
        }
	changed();
    
public voidremoveWebBundleDescriptor(WebBundleDescriptor webBundleDescriptor)
Remove a web bundle descriptor from this application.

param
webBundleDescriptor the web bundle descriptor to remove

	webBundleDescriptor.removeNotificationListener(this);
	webBundleDescriptor.setApplication(null);
	this.getWebBundleDescriptors().remove(webBundleDescriptor);
	this.changed(true);
    
public voidsetDescription(java.lang.String description)

        setDirty(true);
        super.setDescription(description);
    
private voidsetDirty(boolean dirty)

        this.isDirty = dirty;
	
public voidsetGeneratedXMLDirectory(java.lang.String xmlDir)

        generatedXMLDir = xmlDir;
    
public voidsetLargeIconUri(java.lang.String largeIconUri)

        setDirty(true);
        super.setLargeIconUri(largeIconUri);
    
public voidsetLibraryDirectory(java.lang.String value)

        libraryDirectory = value;
    
public voidsetLoadedFromApplicationXml(boolean bool)
This method records how this Application object is constructed. We keep this information to avoid additional disk access in DescriptorArchivist.write() when deciding if the application.xml should be copied or written to the generated/xml directory.

        loadedFromApplicationXml = bool;
    
public voidsetName(java.lang.String name)
Reset the display name of this application.

param
name the display name of the application.

	name = name.replace('/", '-");
	name = name.replace('\\", '-"); // for deploying from NT to solaris & vice versa. This will
					// need to be cleaned when we clean up the backend for registering apps
        setDirty(true);
	super.setName(name);
        if (this.getRoleMapper() != null) {
	    this.getRoleMapper().setName(name);
        }
    
public voidsetPassByReference(boolean passByReference)
Sets the pass-by-reference property for this application. EJB spec requires pass-by-value (false) which is the default. This can be set to true for non-compliant operation and possibly higher performance. For a stand-alone server, this can be used. By setting pass-by-reference in sun-application.xml, it can apply to all the enclosed ejb modules.

param
boolean true or false - pass-by-reference property of application. true - application is pass-by-reference false - application is pass-by-value

       this.passByReference = Boolean.valueOf(passByReference);
    
public voidsetRealm(java.lang.String realm)
Sets the realm for this application

        this.realm=realm;
    
public voidsetRegistrationName(java.lang.String appId)
Sets the registration name for this application. This name is used while deploying the application. The deployment process gurantees that this name is unique.

param
appId the registration name used for this application

        
        // at his point we need to swap our RoleMapper, if we have one... 
        SecurityRoleMapper roleMapper=null;
        try { 
            roleMapper = getRoleMapper();
        } catch(IllegalArgumentException ignore) {};
        
        if (roleMapper!=null) {
            SecurityRoleMapperFactory factory = SecurityRoleMapperFactoryMgr.getFactory();
            if (factory==null) {
                throw new IllegalArgumentException(localStrings.getLocalString(
                    "enterprise.deployment.norolemapperfactorydefine",
                    "This application has no role mapper factory defined"));
            }
	    factory.removeRoleMapper(getName());
            roleMapper.setName(appId);
            factory.setRoleMapper(appId, roleMapper);
        }
        
        this.registrationName = appId;        
    
public voidsetResourceList(java.util.List rList)

        resourceList = rList;
    
public voidsetRoleMapper(com.sun.enterprise.deployment.interfaces.SecurityRoleMapper roleMapper)
Sets the mapping of rolename to users and groups on a particular server.

	// should verify against the roles
	this.roleMapper = roleMapper;
	this.changed(true);
    
public voidsetSmallIconUri(java.lang.String smallIconUri)

        setDirty(true);
        super.setSmallIconUri(smallIconUri);
    
public voidsetUniqueId(long id)
Sets the unique id for this application. It traverses through all the ejbs in the application and sets the unique id for each of them. The traversal is done in ascending element order.

param
id unique id for this application

        _logger.log(Level.FINE,"[Application]uid: " + id);
        this.uniqueId   = id;

        EjbDescriptor[] descs = getSortedEjbDescriptors();

        for (int i=0; i<descs.length; i++)
        {
            // 2^16 beans max per stand alone module
            descs[i].setUniqueId( (id | i) );
            if(_logger.isLoggable(Level.FINE)){
            _logger.log(Level.FINE,"[Application]desc name: " + descs[i].getName());
            _logger.log(Level.FINE,"[Application]desc id: "+descs[i].getUniqueId());
          }
        }
    
public voidsetVirtual(boolean virtual)
Sets the virtual status of this application. If this application object represents a stand alone module, virtaul status should be true; else false.

param
virtual new value of this application's virtaul status

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

param
a visitor to traverse the descriptors

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

param
a visitor to traverse the descriptors

        aVisitor.accept(this);
        EjbBundleVisitor ejbBundleVisitor = aVisitor.getEjbBundleVisitor();
        if (ejbBundleVisitor != null) {
            for (Iterator ejbBundles = getEjbBundleDescriptors().iterator();ejbBundles.hasNext();) {
                EjbBundleDescriptor anEjbBundle = (EjbBundleDescriptor) ejbBundles.next();
                anEjbBundle.visit(ejbBundleVisitor);
            }
        }
        WebBundleVisitor webVisitor = aVisitor.getWebBundleVisitor();
        if (webVisitor != null) {
            for (Iterator webBundles = getWebBundleDescriptors().iterator();webBundles.hasNext();) {
                WebBundleDescriptor aWebBundle = (WebBundleDescriptor) webBundles.next();
                // This might be null in the case of an appclient 
                // processing a client stubs .jar whose original .ear contained
                // a .war.  This will be fixed correctly in the deployment
                // stage but until then adding a non-null check will prevent
                // the validation step from bombing.
                if( aWebBundle != null ) {
                    aWebBundle.visit(webVisitor);
                }
            }
        }
	ConnectorVisitor connectorVisitor = aVisitor.getConnectorVisitor();
        if (connectorVisitor != null) {
            for (Iterator connectors = getRarDescriptors().iterator();connectors.hasNext();) {
                ConnectorDescriptor aConnector = (ConnectorDescriptor) connectors.next();
                aConnector.visit(connectorVisitor);
            }
        }

	AppClientVisitor appclientVisitor = aVisitor.getAppClientVisitor();
        if (appclientVisitor != null) {
            for (Iterator appclients = getApplicationClientDescriptors().iterator();appclients.hasNext();) {
                ApplicationClientDescriptor appclient = (ApplicationClientDescriptor) appclients.next();
                appclient.visit(appclientVisitor);
            }
        }