FileDocCategorySizeDatePackage
AppClientArchivist.javaAPI DocGlassfish v2 API10958Fri May 04 22:31:36 BST 2007com.sun.enterprise.deployment.archivist

AppClientArchivist

public class AppClientArchivist extends Archivist
This class is responsible for handling J2EE app client files.
author
Sheetal Vartak
version

Fields Summary
com.sun.enterprise.deployment.ApplicationClientDescriptor
descriptor
com.sun.enterprise.deployment.io.DeploymentDescriptorFile
standardDD
Constructors Summary
public AppClientArchivist()
Creates new ApplicationClientArchvisit

    
        
      
        handleRuntimeInfo = true;
    
Methods Summary
protected com.sun.enterprise.deployment.util.ModuleDescriptoraddToArchive(ApplicationArchivist appArch, java.lang.String externalDD)
Add this archive to an application archivist

param
application archive to add itself to
param
library jars for this archive
param
external deployment descriptor path

    
            
        ModuleDescriptor module = super.addToArchive(appArch, externalDD);
        if (module!=null) {
            ApplicationClientDescriptor acd = (ApplicationClientDescriptor) module.getDescriptor();
            AbstractArchive jarFile = abstractArchiveFactory.openArchive(getArchiveUri());
            Manifest jarManifest = jarFile.getManifest();
            if (jarManifest!=null) {
                String mainClassName = getMainClassName(jarManifest);
                if (mainClassName!=null) {
                    acd.setMainClassName(mainClassName);
                }
            }            
            jarFile.close();            
        }
        return module;
    
protected java.lang.StringgetArchiveExtension()

        return APPCLIENT_EXTENSION;
    
public com.sun.enterprise.deployment.io.DeploymentDescriptorFilegetConfigurationDDFile()

return
if exists the DeploymentDescriptorFile responsible for handling the configuration deployment descriptors

        return new AppClientRuntimeDDFile();
    
public com.sun.enterprise.deployment.DescriptorgetDefaultBundleDescriptor()

return
a default BundleDescriptor for this archivist

        ApplicationClientDescriptor appClientDesc = 
            new ApplicationClientDescriptor();
        return appClientDesc;
    
public com.sun.enterprise.deployment.DescriptorgetDescriptor()

return
the Descriptor for this archvist

        return descriptor;
    
public java.lang.StringgetMainClassName(java.util.jar.Manifest m)

return
the manifest attribute Main-class

        if (m!=null) {
            return m.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
        }
        return null;
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type handled by this archivist as defined in the application DTD

        return ModuleType.CAR;
    
public com.sun.enterprise.deployment.io.DeploymentDescriptorFilegetStandardDDFile()

return
the DeploymentDescriptorFile responsible for handling standard deployment descriptor

        return standardDD;
    
protected booleanpostHandles(com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive)

        //check the main-class attribute
        if (getMainClassName(abstractArchive.getManifest()) != null) {
            return true;
        }

        return false;
    
protected voidpostOpen(com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
perform any post deployment descriptor reading action

param
the deployment descriptor for the module
param
the module archive

        
        super.postOpen(descriptor, archive);
        
        ApplicationClientDescriptor appClient = (ApplicationClientDescriptor) descriptor;
        ModuleContentValidator mdv = new ModuleContentValidator(archive);
        appClient.visit(mdv);
    
protected voidpostStandardDDsRead(com.sun.enterprise.deployment.RootDeploymentDescriptor descriptor, com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive)
perform any action after all standard DDs is read

param
the deployment descriptor for the module
param
the module archive

        super.postStandardDDsRead(descriptor, archive);
        // look for MAIN_CLASS
        ApplicationClientDescriptor appClient = (ApplicationClientDescriptor)descriptor;
        Manifest m = archive.getManifest();
        appClient.setMainClassName(getMainClassName(m));
    
public voidreadPersistenceDeploymentDescriptors(com.sun.enterprise.deployment.deploy.shared.AbstractArchive archive, com.sun.enterprise.deployment.Descriptor descriptor)

        if (logger.isLoggable(Level.FINE)) {
            logger.logp(Level.FINE, "AppClientArchivist",
                    "readPersistenceDeploymentDescriptors", "archive = {0}",
                    archive.getURI());
        }
        // note we pass "" as the PURootPath because META-INF/persistence.xml
        // can only be present on the top level in an client-jar, so the root of
        // persistence unit is always same as the root of an client-jar file.
        // hence relative distance between them is empty.
        readPersistenceDeploymentDescriptor(archive, "", descriptor);
    
public voidsetDescriptor(com.sun.enterprise.deployment.Descriptor descriptor)
Set the DOL descriptor for this Archivist, used by super classes

        if (descriptor instanceof ApplicationClientDescriptor) {
            this.descriptor = (ApplicationClientDescriptor) descriptor;
        } else {
           if (descriptor instanceof Application) {
                // this is acceptable if the application actually represents
                // a standalone module
                java.util.Set appClientBundles = ((Application) descriptor).getApplicationClientDescriptors();
                if (appClientBundles.size()>0) {
                    this.descriptor = (ApplicationClientDescriptor) appClientBundles.iterator().next();
                    if (this.descriptor.getModuleDescriptor().isStandalone())
                        return;
                    else
                        this.descriptor=null;
                }
            }
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.descriptorFailure", new Object[] {this});
            throw new RuntimeException("Error setting descriptor " + descriptor + " in " + this);
        }
    
public voidvalidate(java.lang.ClassLoader aClassLoader)
validates the DOL Objects associated with this archivist, usually it requires that a class loader being set on this archivist or passed as a parameter

        ClassLoader cl = aClassLoader;
        if (cl==null) {
            cl = classLoader;
        }
        if (cl==null) {
            return;
        }
        descriptor.setClassLoader(cl);
        descriptor.visit((AppClientVisitor) new ApplicationValidator());        
    
protected voidwriteContents(com.sun.enterprise.deployment.deploy.shared.AbstractArchive in, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out, java.util.Vector entriesToSkip)
writes the content of an archive to a JarFile

param
the input archive
param
the archive output stream to write to
param
the files to not write from the original archive

   
        
        // prepare the manifest file to add the main class entry
        if (manifest==null) {
            manifest = new Manifest();
        }
	manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, MANIFEST_VERSION_VALUE);        
        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, 
            ((ApplicationClientDescriptor) getDescriptor()).getMainClassName());
        
        super.writeContents(in, out, entriesToSkip);