FileDocCategorySizeDatePackage
DescriptorArchivist.javaAPI DocGlassfish v2 API6351Fri May 04 22:34:30 BST 2007com.sun.enterprise.ddgenerator.sun

DescriptorArchivist

public class DescriptorArchivist extends Object
This class is responsible for writing deployment descriptors after a deployment action has occured to a abstract archive instance.
author
Jerome Dochez

Fields Summary
Constructors Summary
public DescriptorArchivist()
Creates a new instance of DescriptorArchivist

    
Methods Summary
public voidwrite(com.sun.enterprise.deployment.Application application, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
writes an application deployment descriptors

param
the application object
param
the abstract archive

        if (application.isVirtual()) {
            ModuleDescriptor aModule = (ModuleDescriptor) application.getModules().next();
            Archivist moduleArchivist = ArchivistFactory.getArchivistForType(aModule.getModuleType());
            write(aModule.getDescriptor(), moduleArchivist,  out);
        } else {
            // this is a real application.
            
            // let's start by writing out all submodules deployment descriptors
            for (Iterator modules = application.getModules();modules.hasNext();) {
                ModuleDescriptor aModule = (ModuleDescriptor) modules.next();
                Archivist moduleArchivist = ArchivistFactory.getArchivistForType(aModule.getModuleType());
                if (aModule.getAlternateDescriptor()!=null) {
                    // the application is using alternate deployment descriptors
                    String runtimeDDPath = "sun-" + aModule.getAlternateDescriptor();
                    DeploymentDescriptorFile ddFile = moduleArchivist.getConfigurationDDFile();
                    if (ddFile!=null) {
                        OutputStream os = out.putNextEntry(runtimeDDPath);
                        ddFile.write(aModule.getDescriptor(), os);
                        out.closeEntry();
                    }
                } else {
                    AbstractArchive moduleArchive = out.getEmbeddedArchive(aModule.getArchiveUri());
                    write(aModule.getDescriptor(),  moduleArchivist, moduleArchive);
                }
            }
            
            // now let's write the application runtime descriptor
            ApplicationArchivist archivist = new ApplicationArchivist();
            archivist.setDescriptor(application);
            archivist.writeRuntimeDeploymentDescriptors(out);                        
        }
    
public voidwrite(com.sun.enterprise.deployment.BundleDescriptor bundle, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
writes a bundle descriptor

param
the bundle descriptor
param
the abstract archive

        Archivist archivist = ArchivistFactory.getArchivistForArchive(out);
        write(bundle, archivist, out);
    
protected voidwrite(com.sun.enterprise.deployment.BundleDescriptor bundle, com.sun.enterprise.deployment.archivist.Archivist archivist, com.sun.enterprise.deployment.deploy.shared.AbstractArchive out)
writes a bundle descriptor

param
the bundle descriptor
param
the archivist responsible for writing such bundle type
param
the archive to write to

        
        archivist.setDescriptor(bundle);
        archivist.writeRuntimeDeploymentDescriptors(out);
        
        // now if this is a web bundle descriptor, we may need to rewrite the standard 
        // deployment descriptors if we have web services since the servlet implementation
        // has been switched
        if (bundle.getModuleType().equals(ModuleType.WAR)) {
            WebBundleDescriptor webBundle = (WebBundleDescriptor) bundle;
            if (webBundle.hasWebServices()) {
                archivist.writeStandardDeploymentDescriptors(out);
            }
        }