Package com.sun.enterprise.deployment.util

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


      this.componentName = ejbDsc.getName();
    }

    // this takes care of all bundle descriptors.
    public ComponentNameConstructor(BundleDescriptor bundleDesc) {
        ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
        if(!moduleDesc.isStandalone()){ // print app name only for embedded ones
            this.appName = bundleDesc.getApplication().getRegistrationName();
        }
      this.jarName = moduleDesc.getArchiveUri();
        // there is no point in printing comp name since it is bundle desc.
    }
View Full Code Here


        this.componentName = componentName;
    }

    public ComponentNameConstructor(WebServiceEndpoint wse) {
        BundleDescriptor bundleDesc = wse.getBundleDescriptor();
        ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
        if(!moduleDesc.isStandalone()){ // print app name only for embedded ones
            this.appName = bundleDesc.getApplication().getRegistrationName();
        }
        this.jarName = moduleDesc.getArchiveUri();
        // WebServiceEndpoint path is WebServices->WebService->WebServiceEndpoint
        this.componentName = wse.getWebService().getName()+"#"+wse.getEndpointName(); // NOI18N
    }
View Full Code Here

        this.componentName = wse.getWebService().getName()+"#"+wse.getEndpointName(); // NOI18N
    }

    public ComponentNameConstructor(ServiceReferenceDescriptor srd) {
        BundleDescriptor bundleDesc = srd.getBundleDescriptor();
        ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
        if(!moduleDesc.isStandalone()){ // print app name only for embedded ones
            this.appName = bundleDesc.getApplication().getRegistrationName();
        }
        this.jarName = moduleDesc.getArchiveUri();
        this.componentName = srd.getName();
    }
View Full Code Here

        this.componentName = srd.getName();
    }

    public ComponentNameConstructor(WebService wsDsc) {
        BundleDescriptor bundleDesc = wsDsc.getBundleDescriptor();
        ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
        if(!moduleDesc.isStandalone()){ // print app name only for embedded ones
            this.appName = bundleDesc.getApplication().getRegistrationName();
        }
        this.jarName = moduleDesc.getArchiveUri();
        this.componentName = wsDsc.getName();
    }
View Full Code Here

            this.appName = Application.class.cast(container).getRegistrationName();
            this.componentName = persistenceUnitsDescriptor.getPuRoot() +
                    "#"+descriptor.getName(); // NOI18N
        } else { // this PU is bundled inside a module
            BundleDescriptor bundleDesc = BundleDescriptor.class.cast(container);
            ModuleDescriptor moduleDesc = bundleDesc.getModuleDescriptor();
            if(!moduleDesc.isStandalone()){ // print app name only for embedded ones
                this.appName = bundleDesc.getApplication().getRegistrationName();
            }
            this.jarName = moduleDesc.getArchiveUri();
            String puRoot = persistenceUnitsDescriptor.getPuRoot();
            // for EJB module, PURoot is empty, so to avoid ## in report, this check is needed.
            this.componentName = ("".equals(puRoot) ? "" : puRoot + "#") + descriptor.getName(); // NOI18N
        }
    }
View Full Code Here

            filesToSkip.add(elementName);
        }
               
        // write this application .ear file contents...
        for (Iterator modules  = application.getModules();modules.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) modules.next();
            Archivist subArchivist = getPluggableArchivists().getArchivistForType(aModule.getModuleType());
            subArchivist.initializeContext(this);
            subArchivist.setModuleDescriptor(aModule);
            if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
                DOLUtils.getDefaultLogger().info("Write " + aModule.getArchiveUri() + " with " + subArchivist);
            }
           
            if (aModule.getAlternateDescriptor()!=null) {
                // no need to rewrite the original bundle since
                // the deployment descriptors are saved at the application level
                // so I don't put it in the list of files to be skipped and it will
                // be copied as a library.
               
                // but I need to save the deployment descriptor for this bundle
                OutputStream os = out.putNextEntry(aModule.getAlternateDescriptor());
                subArchivist.writeStandardDeploymentDescriptors(os);
                out.closeEntry();
   
    // now write runtime descriptors
                if (isHandlingRuntimeInfo()) {
                    os = out.putNextEntry("sun-" + aModule.getAlternateDescriptor());
                    subArchivist.writeRuntimeDeploymentDescriptors(os);
                    out.closeEntry();
                }
               
            } else {
                // Create a new jar file inside the application .ear
                AbstractArchive internalJar = out.getEmbeddedArchive(aModule.getArchiveUri());
               
                // we need to copy the old archive to a temp file so
                // the save method can copy its original contents from
                InputStream is = in.getEntry(aModule.getArchiveUri());
                File tmpFile=null;
                try {
                    if (in.supportsElementsOverwriting()) {
                        subArchivist.setArchiveUri(internalJar.getArchiveUri());
                    } else {
                        tmpFile = getTempFile(path);
                        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tmpFile));
                        ArchivistUtils.copy(is, bos);
                       
                        // configure archivist
                        subArchivist.setArchiveUri(tmpFile.getAbsolutePath());
                    }
                    subArchivist.writeContents(internalJar);
                    out.closeEntry(internalJar);
                   
                } catch(IOException ioe) {
                    throw ioe;
                } finally {
                    if (tmpFile!=null)
                        tmpFile.delete();
                }
               
                // no need to copy the bundle from the original jar file
                filesToSkip.add(aModule.getArchiveUri());
            }
        }
       
        // now write the old contents and new descriptors
        super.writeContents(in, out, filesToSkip);
View Full Code Here

     */
    public boolean readModulesDescriptors(Application app, AbstractArchive appArchive)
        throws IOException, SAXParseException {
       
        for (Iterator modules  = app.getModules();modules.hasNext();) {
            ModuleDescriptor aModule = (ModuleDescriptor) modules.next();
            if(DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
                DOLUtils.getDefaultLogger().fine("Opening sub-module " + aModule);
            }
            Descriptor descriptor = null;
            ArchiveDescriptor archiveDesc = null;
            Archivist newArchivist = null;
            AbstractArchive embeddedArchive =
                    appArchive.getEmbeddedArchive(aModule.getArchiveUri());
            if(ModuleType.WAR.equals(aModule.getModuleType())){
                // Check if this is an extension module.If there is an IOException
                // thrown then this means that we cannot determine the archivist
                // using the archive, and also that this is not an extension
                // module.
                try {
                    newArchivist =
                                getPluggableArchivists().getArchivistForArchive(
                                                               embeddedArchive);
                } catch (IOException ioe) {                                         
                    // This has to be a Web Module now.
                    newArchivist = getPluggableArchivists().getArchivistForType(
                                                       aModule.getModuleType());
                }
            } else {
                newArchivist = getPluggableArchivists().getArchivistForType(
                                                       aModule.getModuleType());
            }
           
            newArchivist.initializeContext(this);
            newArchivist.setRuntimeXMLValidation(this.getRuntimeXMLValidation());
            newArchivist.setRuntimeXMLValidationLevel(
                this.getRuntimeXMLValidationLevel());

            //AbstractArchive embeddedArchive = appArchive.getEmbeddedArchive(aModule.getArchiveUri());               
            if (aModule.getAlternateDescriptor()!=null) {
                // the module use alternate deployement descriptor, ignore the
                // DDs in the archive.
                InputStream is = appArchive.getEntry(aModule.getAlternateDescriptor());
                DeploymentDescriptorFile ddFile = newArchivist.getStandardDDFile();
                ddFile.setXMLValidation(newArchivist.getXMLValidation());
                ddFile.setXMLValidationLevel(newArchivist.getXMLValidationLevel());
                if (appArchive.getArchiveUri()!=null) {
                    ddFile.setErrorReportingString(appArchive.getArchiveUri());
                }

                descriptor = ddFile.read(is);
                is.close();
                newArchivist.readWebServicesDescriptor(embeddedArchive, descriptor);
                newArchivist.readPersistenceDeploymentDescriptors(embeddedArchive, descriptor);
                newArchivist.postStandardDDsRead((RootDeploymentDescriptor) descriptor, embeddedArchive);
                newArchivist.readAnnotations(embeddedArchive, (BundleDescriptor)descriptor);
                newArchivist.postAnnotationProcess((BundleDescriptor)descriptor, embeddedArchive);
                newArchivist.postOpen((RootDeploymentDescriptor) descriptor, embeddedArchive);
                // now reads the runtime deployment descriptor...
                if (isHandlingRuntimeInfo()) {
                    is = appArchive.getEntry("sun-" + aModule.getAlternateDescriptor());
                    if (is!=null) {
                        DeploymentDescriptorFile confDD =
                            newArchivist.getConfigurationDDFile();
                        confDD.setXMLValidation(
                            newArchivist.getRuntimeXMLValidation());
                        confDD.setXMLValidationLevel(
                            newArchivist.getRuntimeXMLValidationLevel());
                        if (appArchive.getArchiveUri()!=null) {
                            confDD.setErrorReportingString(
                                appArchive.getArchiveUri());
                        }

                        confDD.read(descriptor, is);
                        is.close();
                        newArchivist.postRuntimeDDsRead((RootDeploymentDescriptor)descriptor, embeddedArchive);
                    } else {
                        if (embeddedArchive!=null) {
                            newArchivist.readRuntimeDeploymentDescriptor(embeddedArchive,descriptor);
                        }
                    }
                }
            } else {
                // open the subarchive to get the deployment descriptor...
                if (embeddedArchive!=null) {
                    if(newArchivist instanceof ExtensionModuleArchivist) {
                        try{
                            ((ExtensionModuleArchivist)newArchivist).
                                    setJ2eeApplication(true);
                            archiveDesc =
                                  ((ExtensionModuleArchivist)newArchivist).openArchive(
                                            embeddedArchive.getArchiveUri(),
                                                null,
                                                    this.classLoader,
                                                        false);
                        } catch (Exception ex) {
                            //log this message
                            DOLUtils.getDefaultLogger().severe(
                                "Exception thrown while processing module "
                                + aModule.getDescriptor().getModuleID()
                                + ex.getMessage());
                            ex.printStackTrace();
                                       
                        }
                    } else {
                        descriptor = newArchivist.open(embeddedArchive);
                    }
                } else {
                    DOLUtils.getDefaultLogger().info(localStrings.getLocalString(
                        "enterprise.deployment.cannotfindmodule",
                        "Cannot find module {0} in application bundle",
                        new Object[] {aModule.getArchiveUri()}));
                    return false;
                }
            }
            if (embeddedArchive!=null) {
                embeddedArchive.close();
            }
            if (descriptor != null && descriptor instanceof BundleDescriptor) {
                aModule.setDescriptor((BundleDescriptor) descriptor);
                ((BundleDescriptor) descriptor).setApplication(app);
                aModule.setManifest(newArchivist.getManifest());
            } else if(archiveDesc != null &&
                            archiveDesc instanceof BundleDescriptor) {
                 aModule.setDescriptor((BundleDescriptor) archiveDesc);
                ((BundleDescriptor) archiveDesc).setApplication(app);
                aModule.setManifest(newArchivist.getManifest());
            } else {
                // display a message only if we had a handle on the sub archive
                if (embeddedArchive!=null) {
                    DOLUtils.getDefaultLogger().info(localStrings.getLocalString(
                        "enterprise.deployment.cannotreadDDs",
                        "Cannot read the Deployment Descriptors for module {0}",
                        new Object[] {aModule.getArchiveUri()}));
                }
                return false;
            }
        }       
        return true;
View Full Code Here

        if (descriptor instanceof Application) {
            Application application = (Application) descriptor;
           
            // each modules first...
            for (Iterator itr=application.getModules();itr.hasNext();) {
                ModuleDescriptor md = (ModuleDescriptor) itr.next();
                Archivist archivist = getPluggableArchivists().getArchivistForType(md.getModuleType());
                archivist.initializeContext(this);
                archivist.setRuntimeXMLValidation(
                    this.getRuntimeXMLValidation());
                archivist.setRuntimeXMLValidationLevel(
                    this.getRuntimeXMLValidationLevel());
                InputStream is = null;
               
                if (md.getAlternateDescriptor()!=null) {
                    // we are using alternate deployment descriptors
                    is = archive.getEntry("sun-" + md.getAlternateDescriptor());
                    if (is!=null) {
                        DeploymentDescriptorFile confDD =
                            archivist.getConfigurationDDFile();
                        confDD.setXMLValidation(
                            archivist.getRuntimeXMLValidation());
                        confDD.setXMLValidationLevel(
                            archivist.getRuntimeXMLValidationLevel());
                        if (archive.getArchiveUri()!=null) {
                            confDD.setErrorReportingString(
                                archive.getArchiveUri());
                        }
                        confDD.read(md.getDescriptor(), is);
                        is.close();
                    }                   
                }
                // if is variable is null, it means that we are either
                // not using alternate deployment descriptors or we could
                // not find the appropriate sun-???.xml alternate DD.
                if (is==null) {
                    AbstractArchive subArchive = archive.getEmbeddedArchive(md.getArchiveUri());
                    archivist.readRuntimeDeploymentDescriptor(subArchive,  md.getDescriptor());
                }
            }
        }
        // for the application
        super.readRuntimeDeploymentDescriptor(archive,  descriptor);
View Full Code Here

        if (descriptor instanceof Application) {
            Application application = (Application) descriptor;
           
            //runtime deployment descriptor for the sub modules
            for (Iterator itr = application.getModules(); itr.hasNext();) {
                ModuleDescriptor moduleDesc = (ModuleDescriptor) itr.next();
                Archivist subArchivist = ArchivistFactory.getArchivistForType(moduleDesc.getModuleType());
                String archiveUri = moduleDesc.getArchiveUri();
                String runtimeDDPath = subArchivist.getRuntimeDeploymentDescriptorPath();

                if (runtimeDDPath!=null) {
                    String mangledName;
                    // the runtime deployment descriptor from the deployment file
                    mangledName = archiveUri + "."
                        + runtimeDDPath.substring(runtimeDDPath.lastIndexOf('/')+1);
                    DOLUtils.getDefaultLogger().fine("mangledName is " + mangledName);

                    if (dpEntries.contains(mangledName)) {
                        subArchivist.readRuntimeDDFromDeploymentPlan(
                            mangledName, planArchive, moduleDesc.getDescriptor());
                    }
                }
            }
        }
View Full Code Here

    public ModuleDescriptor addArchive(AbstractArchive newArchive, Set libraryJars, String externalDD)
        throws SAXParseException, IOException {       
           
        // let's create a tmp file to store the new application .ear
        File outputFile=null;
        ModuleDescriptor newModule = null;
        try {
            outputFile = getTempFile(path);
            AbstractArchive out = abstractArchiveFactory.createArchive(outputFile.getAbsolutePath());
       
            // let's create a new module descriptor for this module
            newModule = getModuleFor(out, newArchive, libraryJars, externalDD);
            application.addModule(newModule);
                   
            // this should take care of writing the sub modules with the right
            // manifests and deployment descriptors settings...
            AbstractArchive in = abstractArchiveFactory.openArchive(path);       
            Vector filesToSkip = new Vector();
            filesToSkip.add(newModule.getArchiveUri());
            writeContents(in, out, filesToSkip);
            in.close();

            out.close();
       
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.