Package com.sun.enterprise.deployment.util

Examples of com.sun.enterprise.deployment.util.ModuleDescriptor


   
        // Let's get an archivist for the new archive to be added and delegate
        Archivist newArchivist = getPluggableArchivists().getArchivistForArchive(newArchive);
        newArchivist.initializeContext(this);
        newArchivist.setArchiveUri(newArchive.getArchiveUri());
        ModuleDescriptor newModule = newArchivist.addToArchive(this, externalDD);
        newArchivist.prepareForInclusion(out);
                       
        // now update the manifest for this archivist... and writes the libray jars
        // to our application archive...
        if (libraryJars!=null && !libraryJars.isEmpty()) {
            StringBuffer classPath = new StringBuffer();
            for (Iterator e = libraryJars.iterator(); e.hasNext();) {
                String libUri = (String) e.next();
                File libFile = new File(libUri);
                if (libFile.exists()) {
                    classPath.append(libUri);
                    classPath.append(' ');
                    addFileToArchive(out, libFile.getAbsolutePath(), libUri);
                } else {
                    throw new FileNotFoundException("Library file " + libFile.getAbsolutePath() + " not found");
                }
            }
            Manifest manifest = newArchivist.getManifest();
            if (manifest==null) {
                manifest = new Manifest();
                newArchivist.setManifest(manifest);
            }
            Attributes atts = manifest.getMainAttributes();
            atts.putValue(Attributes.Name.CLASS_PATH.toString(), classPath.toString());
        }   
       
        // now include the new module in the output archive
        AbstractArchive newModuleJar = out.getEmbeddedArchive(newModule.getArchiveUri());
       
        // write and close
        newArchivist.writeContents(newModuleJar);
        out.closeEntry(newModuleJar);       
               
View Full Code Here


            throw new IOException("Application object not set on archivist");
        }
        Iterator<ModuleDescriptor> modulesItr = application.getModules();
        boolean returnValue = true;
        while(modulesItr.hasNext()) {
            ModuleDescriptor md = modulesItr.next();
            AbstractArchive sub = archive.getEmbeddedArchive(md.getArchiveUri());
            if (sub!=null) {
                Archivist subArchivist = getPluggableArchivists().getArchivistForType(md.getModuleType());
                if (!subArchivist.performOptionalPkgDependenciesCheck(sub))
                    returnValue = false;
            }
        }
        return returnValue;
View Full Code Here

    public void copyInto(Application a, AbstractArchive source,
                         AbstractArchive target, boolean overwriteManifest)
        throws IOException {
        Vector entriesAdded = new Vector();
        for (Iterator modules  = a.getModules();modules.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) modules.next();
            entriesAdded.add(aModule.getArchiveUri());
            AbstractArchive subSource = source.getEmbeddedArchive(aModule.getArchiveUri());
            AbstractArchive subTarget = target.getEmbeddedArchive(aModule.getArchiveUri());
            Archivist newArchivist = getPluggableArchivists().getArchivistForType(aModule.getModuleType());
            newArchivist.copyInto(subSource, subTarget, overwriteManifest);
            target.closeEntry(subTarget);
            String subModulePath = subSource.getArchiveUri();
            if (subModulePath.startsWith(source.getArchiveUri())) {
                subModulePath = subModulePath.substring(source.getArchiveUri().length()+File.separator.length());
View Full Code Here

    /**
     * creates a new module descriptor for this archivist
     * @return the new module descriptor
     */
    public ModuleDescriptor createModuleDescriptor(BundleDescriptor descriptor) {
        ModuleDescriptor newModule = new ModuleDescriptor();
        newModule.setModuleType(getModuleType());
        newModule.setDescriptor(descriptor);
        setDescriptor(descriptor);       
        return newModule;
    }
View Full Code Here

        }
        archiveToBeAdded.close();
       
        // Create a new module descriptor for this new module
        if (descriptor instanceof BundleDescriptor) {
            ModuleDescriptor newModule = new ModuleDescriptor();
            newModule.setArchiveUri(archiveName);
            newModule.setModuleType(getModuleType());
            newModule.setDescriptor((BundleDescriptor) descriptor);
            newModule.setManifest(getManifest());
            if (externalDD != null && !"".equals(externalDD)) {
                newModule.setAlternateDescriptor(externalDD);
            }       
            return newModule;
        } else {
            return null;
        }
View Full Code Here

     * @param external deployment descriptor path
     */
    protected ModuleDescriptor addToArchive(ApplicationArchivist appArch, String externalDD)
        throws IOException, SAXParseException {   
           
        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) {
View Full Code Here

                    "enterprise.deployment.cannotreadDDs",
                    "Cannot read the Deployment Descriptors for module {0}",
                    new Object[] { in.getArchiveUri() }));
                return null;       
            }
            ModuleDescriptor newModule = archivist.createModuleDescriptor(aBundle);
            newModule.setArchiveUri(in.getArchiveUri());
            application = Application.createApplication(appName, newModule);
        }
       
        // now read the runtime deployment descriptor
        if (handleRuntimeInfo) {
View Full Code Here

            SAXParseException {
        if(!application.isVirtual()) {
            ApplicationArchivist appArchivist = new ApplicationArchivist();
            appArchivist.readPersistenceDeploymentDescriptors(archive, application);
            for(Iterator modules = application.getModules(); modules.hasNext();) {
                final ModuleDescriptor moduleDescriptor =
                        ModuleDescriptor.class.cast(modules.next());
                Archivist moduleArchivist = ArchivistFactory.
                        getArchivistForType(moduleDescriptor.getModuleType());
                AbstractArchive moduleArchive = archive.getEmbeddedArchive(
                        moduleDescriptor.getArchiveUri());
                try{
                    moduleArchivist.readPersistenceDeploymentDescriptors(
                            moduleArchive, moduleDescriptor.getDescriptor());
                } finally {
                    moduleArchive.close();
                }
            }
        } else {
            // it's a standalone war/jar/rar etc.
            final ModuleDescriptor module =
                    ModuleDescriptor.class.cast(application.getModules().next());
            Archivist archivist =
                    ArchivistFactory.getArchivistForType(module.getModuleType());
            archivist.readPersistenceDeploymentDescriptors(
                    archive, module.getDescriptor());
        }
    }
View Full Code Here

        throws IOException, SAXParseException {
           
        // read the standard deployment descriptors
        BundleDescriptor descriptor = (BundleDescriptor)readStandardDeploymentDescriptor(abstractArchive);

        ModuleDescriptor newModule = createModuleDescriptor(descriptor);
        newModule.setArchiveUri(abstractArchive.getArchiveUri());
       
        readWebServicesDescriptor(abstractArchive, descriptor);

        // Now that we have parsed the standard DD, let's read all the
        // PersistenceUnits defined in this archive as well.
View Full Code Here

                    Application application = (Application) rootDD.read(null, in);

                    // all web modules in the J2EE application
                    for (Iterator modules = application.getModules();
                            modules.hasNext();) {
                        ModuleDescriptor aModule = (ModuleDescriptor) modules.next();

                        if (!((aModule.getModuleType()).equals(ModuleType.WAR))) {
                            _logger.fine("Skipping non web module descriptor: " +
                                aModule.getModuleType());

                            continue;
                        }

                        // alt dd
                        if (aModule.getAlternateDescriptor() != null) {
                            File f = new File(aModule.getAlternateDescriptor());

                            // Get the path of the parent of alt dd file.
                            // add this path to total path, if this is not
                            // null.
                            String parent = f.getParent();

                            if (parent == null) {
                                parent = "";
                            }

                            // path to the sun-xxx.xml file
                            String instanceRoot = System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY);
                            File generated = new File(instanceRoot,
                                    PEFileLayout.GENERATED_DIR);
                            File xml = new File(generated, PEFileLayout.XML_DIR);
                            File j2eeApps = new File(xml,
                                    PEFileLayout.J2EE_APPS_DIR);
                            File generatedAppRoot = new File(j2eeApps,
                                    applicationName);
                            String generatedAppPath = generatedAppRoot.getAbsolutePath();

                            File altWebapp = new File(generatedAppPath,
                                    parent + File.separator + SUN_PREFIX +
                                    f.getName());

                            if (altWebapp.exists()) {
                                _logger.fine("Adding alt-web-app path " +
                                    altWebapp.getAbsolutePath());

                                // adding to the list
                                list.add(altWebapp.getAbsolutePath());
                            } else {
                                _logger.fine("Invalid path: " +
                                    altWebapp.getAbsolutePath());
                            }
                        } else { // no alt dd

                            String aUri = aModule.getArchiveUri();

                            if (aUri != null) {
                                String instanceRoot = System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY);
                                File generated = new File(instanceRoot,
                                        PEFileLayout.GENERATED_DIR);
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.util.ModuleDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.