Package com.sun.enterprise.deployment.archivist

Examples of com.sun.enterprise.deployment.archivist.Archivist


        File destFile = new File(dest);
        if(destFile.exists()) {
            DeploymentContext.deleteDirectory(destFile);
            destFile.mkdir();
        }
        Archivist archivist = ArchivistFactory.getArchivistForArchive(srcFile);
        try {
            ModuleType moduleType = archivist.getModuleType();
            if(ModuleType.EAR.equals(moduleType)) {
                J2EEModuleExploder.explodeEar(srcFile, destFile);
            } else if ( ModuleType.EJB.equals(moduleType) ||
                    ModuleType.CAR.equals(moduleType) ||
                    ModuleType.RAR.equals(moduleType) ||
View Full Code Here


            factory = new JarArchiveFactory();
        }
        AbstractArchive source = factory.openArchive(archive.getAbsolutePath());
       
        // now copy the archive, let the archivist do the job...
        Archivist archivist = null;
        try {
            archivist = ArchivistFactory.getArchivistForArchive(source);
            if (archivist == null) {
                String msg = localStrings.getString
                        ("enterprise.deployment.backend.no_archivist_recognized_arch",
                        archive.getAbsolutePath()
                        );
                throw new IASDeploymentException(msg);
            }
        } catch (IOException ioe) {
            String msg = localStrings.getString
                    ("enterprise.deployment.backend.error_getting_archivist",
                    archive.getAbsolutePath()
                    );
            throw new IASDeploymentException(msg, ioe);
        }
        if (!archivist.getModuleType().equals(ModuleType.EAR)) {
            explodeModule(archivist, source, directory, moduleName, preserveManifest);
        }
    }
View Full Code Here

    protected void setRuntimeDDPresent(String uri) {
        InputStream is = null;
        try {
            AbstractArchive abstractArchive = new FileArchiveFactory().openArchive(
                    uri);
            Archivist archivist = ArchivistFactory.getArchivistForArchive(
                    abstractArchive);
            if(archivist != null) {
                String ddFileEntryName = archivist.getRuntimeDeploymentDescriptorPath();
                is = abstractArchive.getEntry(ddFileEntryName);
                if (is != null) {
                    isDDPresent = true;
                }
            }
View Full Code Here

       
        if (descriptor.isApplication()) {
            Application app = (Application) descriptor;
            for (Iterator modules = app.getModules();modules.hasNext();) {
                ModuleDescriptor md = (ModuleDescriptor) modules.next();
                Archivist moduleArchivist = ArchivistFactory.getArchivistForType(md.getModuleType());
               
                AbstractArchive subSource = source.getEmbeddedArchive(md.getArchiveUri());
                AbstractArchive subSource2 = source2.getEmbeddedArchive(md.getArchiveUri());
                moduleNames.add(md.getArchiveUri());
               
                // any file that needs to be kept in the sub module should be
                // calculated here
                Vector subEntries = new Vector();
                // manifest file always stay in embedded jar
                subEntries.add(JarFile.MANIFEST_NAME);
               
                // all mapping file stay within the embedded jar
                WebServicesDescriptor wsd = md.getDescriptor().getWebServices();
                if (wsd!=null) {
                    for (Iterator itr = wsd.getWebServices().iterator();itr.hasNext();) {
                        WebService ws = (WebService) itr.next();
                        subEntries.add(ws.getMappingFileUri());
                    }               
                }
               
                Set refs = md.getDescriptor().getServiceReferenceDescriptors();
                for (Iterator itr = refs.iterator();itr.hasNext();) {
                    ServiceReferenceDescriptor srd = (ServiceReferenceDescriptor) itr.next();
                    subEntries.add(srd.getMappingFileUri());
                }
               
                // first copy original module files in the root on the target
                // except for .rar files contents.
                // We need to do it first so we save the list of files to be saved in the
                // embedded archive (for proper deployment descriptor loading)
                List embeddedFiles = new ArrayList();
                for (Enumeration e = subSource.entries();e.hasMoreElements();) {
                   
                    String entryName = (String) e.nextElement();
                   
                    // Deployment Descriptors (and associated) go in the embedded files
                    if (entryName.endsWith(".xml"||
                        subEntries.contains(entryName) ||
                        entryName.startsWith(md.getDescriptor().getWsdlDir())) {
                       
                          embeddedFiles.add(entryName);
                    } else {
                        try {
                            copy(subSource, target, entryName);
                        } catch(IOException ioe) {
                            // dup, we ignore
                        }
                    }
                }
               
                // now we need to copy the files we saved inside the embedded
                // archive file
               
                AbstractArchive subTarget = target.getEmbeddedArchive(md.getArchiveUri());
               
                // and copy the list of identified files inside it

                // copy deployment descriptor files from generated xml directory
                for (Iterator itr = embeddedFiles.iterator();itr.hasNext();) {
                    String entryName = (String) itr.next();
                    copyWithOverride(subSource, subSource2, subTarget, entryName);
                }

                copy(subSource, subSource2, subTarget,
                    moduleArchivist.getStandardDDFile().getDeploymentDescriptorPath(),
                    embeddedFiles);

                // every module may not have a sun descriptor, e.g. par file does not have one.
                if(moduleArchivist.getConfigurationDDFile()!=null) {
                    copy(subSource, subSource2, subTarget,
                        moduleArchivist.getConfigurationDDFile().getDeploymentDescriptorPath(),
                        embeddedFiles);
                }

                // and the manifest file since it does not appear in the list of files...
                copy(subSource, subTarget, JarFile.MANIFEST_NAME);
               
                // we do not need to copy anything else from the source embedded module
                // since all .class files and resources have moved at the top level of the target
                // application client container jar, so we can close out both subarchives
                target.closeEntry(subTarget);
                source.closeEntry(subSource);
                source2.closeEntry(subSource2);
            }
        }
        // standalone modules and .ear file level entries fall back here, we
        // just need to copy the original archive file elements at the root level
        // of the target application client container jar file.
        Archivist archivist = ArchivistFactory.getArchivistForType(descriptor.getModuleType());

        // because of the backend layout, the appclient jar file appears in the list of files
        // in the source archive (which is the exploded directory where we started writing
        // the appclient file... this is also true when doing deploydir deployment
        String appClientFileName = target.getArchiveUri().substring(target.getArchiveUri().lastIndexOf(File.separatorChar)+1);

        // and the manifest file since it does not appear in the
        // list of files...
        copy(source, target, JarFile.MANIFEST_NAME);
       
        List xmlFiles = new ArrayList();
        String libDir = computeLibraryDirectory(descriptor);
        for (Enumeration e = source.entries(moduleNames.elements());e.hasMoreElements();) {
            String entryName = (String) e.nextElement();
           
            // if this is the appclient we are creating, we pass
            if (entryName.equals(appClientFileName)) {
                continue;
            }
           
            // now we need to write the elements in the target file and explode
            // if it is a utility jar file
            if (entryName.endsWith(".jar") && ! inLibDirSubdirectory(libDir, entryName)) {
                // explode
                AbstractArchive subSource = null;
                try {
                    subSource = source.getEmbeddedArchive(entryName);
                    for (Enumeration subEntries = subSource.entries();subEntries.hasMoreElements();) {
                        String subEntryName = (String) subEntries.nextElement();
                        if(DescriptorConstants.PERSISTENCE_DD_ENTRY.equals(subEntryName)){
                            // If we copy DescriptorConstants.PAR_DD_ENTRY into
                            // *Client.jar then during subsequent app loading time
                            // server will treat that jar as another PU Root and try to load it.
                            // so don't copy such a file.
                            continue;
                        }
                        copy(subSource, target, subEntryName);
                    }
                } finally {
                    if (subSource != null) {
                        source.closeEntry(subSource);
                    }
                }
            } else {
                if (entryName.endsWith(".xml")) {
                    xmlFiles.add(entryName);
                }
                copyWithOverride(source, source2, target, entryName);
            }
        }

        copy(source, source2, target,
            archivist.getStandardDDFile().getDeploymentDescriptorPath(),
            xmlFiles);
        copy(source, source2, target,
            archivist.getConfigurationDDFile().getDeploymentDescriptorPath(),
            xmlFiles);
    }
View Full Code Here

     
     
      boolean validateXml = true;
     
      try {
    Archivist archivist = ArchivistFactory.getArchivistForType(request.getType().getModuleType());
                archivist.setAnnotationProcessingRequested(true);

    String appDir = request.getDeployedDirectory().getAbsolutePath();
    FileArchive in = new FileArchive();
    in.open(appDir);

    if (request.isVerifying()) {
        archivist.setRuntimeXMLValidation(true);
        archivist.setRuntimeXMLValidationLevel("full");
    }
    if (validationLevel.equals("none")) {
        archivist.setXMLValidation(false);
    } else {
        archivist.setXMLValidation(true);
        archivist.setXMLValidationLevel(validationLevel);
    }   

                //Note in copying of deployment plan to the portable archive,
                //we should make sure the manifest in the deployment plan jar
                //file does not overwrite the one in the original archive
                //NOTE. We are not checking the size of the deploymentPlan file
                //here, since it looks like on windows the size of this tmp
                //file is always zero when we attempt to query its size. 
                //Instead, we are making sure the 0 length deployment plan is
                //not uploaded in DeploymentFacility implementation.
                if (request.getDeploymentPlan() != null) {
                    DeploymentPlanArchive dpa = new DeploymentPlanArchive();
                    dpa.open(request.getDeploymentPlan().getAbsolutePath());

                    if (request.isApplication()) {
                        ApplicationArchivist aa = (ApplicationArchivist)archivist;
                        aa.copyInto(request.getDescriptor(), dpa, in, false);
                    } else {
                        archivist.copyInto(dpa, in, false);
                    }
                }
   
    // now let's create a class loader for this module
   
    // parent class loader (from admin server)
        ClassLoader parent =
            (Boolean.getBoolean(com.sun.enterprise.server.PELaunch.USE_NEW_CLASSLOADER_PROPERTY))
                    ? com.sun.enterprise.server.PELaunch.getAppServerChain()
                    : ClassLoader.getSystemClassLoader();

    // sets the parent class loader and class paths in deployment req   
              DeploymentUtils.setParentClassLoader(parent, getManager(), request);
    // parent class paths for this deployment request
    List allClassPaths = request.getParentClasspath();

    // parent class loader for this deployment request
    ClassLoader sharedClassLoader = request.getParentClassLoader();

    List moduleClasspath = getModuleClasspath(archivist, in);

                // add the libraries from --libraries option to module classpath
                String libs = request.getLibraries();
                URL[] deployTimeLibraries =
                    ASClassLoaderUtil.getLibraries(libs);
                if (deployTimeLibraries != null) {
                    for (int i=0; i< deployTimeLibraries.length; i++) {
                        String libPath = new File(
                            deployTimeLibraries[i].toURI()).getPath();
                        moduleClasspath.add(libPath);
                    }
                }

          request.setModuleClasspath(moduleClasspath);
    allClassPaths.addAll(moduleClasspath);

    final ClassLoader ejbClassLoader = DeploymentUtils.getClassLoader(
                                        moduleClasspath, sharedClassLoader, null);

    // sets the ejb class loader & class paths - used during jspc
    request.setEjbClassLoader(ejbClassLoader);
    request.setCompleteClasspath(allClassPaths);

                // set classloader used for annotation processing
                archivist.setClassLoader(ejbClassLoader);
     
                // set the context classloader to ejbClassLoader for DD
                // processing
                ClassLoader origContextClassLoader =
                    Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(ejbClassLoader);

                Application application = request.getDescriptor();
                if (application!=null && ModuleType.EAR.equals(archivist.getModuleType())) {
                    archivist.readPersistenceDeploymentDescriptors(in, application);
                    // Now process standard DDs, do this before runtime DDs
                    archivist.setHandleRuntimeInfo(false);
                    boolean modulesReadSuccess = ((ApplicationArchivist) archivist).readModulesDescriptors(application, in);
                    if (modulesReadSuccess ) {
                        // now process runtime DDs
                        archivist.setHandleRuntimeInfo(true);
                        archivist.readRuntimeDeploymentDescriptor(in, application);
                    } else {
                        // it failed reading sub modules, I null our application which will trigger
                        // deployment failure handling
                        application=null;
                    }
                } else {
                    application = ApplicationArchivist.openArchive(archivist, in, true);
                }
                if (application==null) {
                    throw new IASDeploymentException(localStrings.getString(
                            "enterprise.deployment.backend.error_loading_dds",
                            new Object[] { request.getName(), " " }));
                }
    application.setRegistrationName(request.getName());
   
    application.setClassLoader(ejbClassLoader);
                archivist.setDescriptor(application);
 
                // let's check for optional dependencies
                if (!archivist.performOptionalPkgDependenciesCheck(in)) {
                    throw new IASDeploymentException(localStrings.getString("enterprise.deployment.backend.archive_opt_dep_not_satisfied", new Object[] {in.getArchiveUri()}));
                }
                               
    archivist.validate(ejbClassLoader);
   
    if (!application.getWebServiceDescriptors().isEmpty()) {
        ModuleContentLinker visitor = new ModuleContentLinker(in);
        application.visit((com.sun.enterprise.deployment.util.ApplicationVisitor) visitor);
    }     
View Full Code Here

    {
        try {
            FileArchive archive = new FileArchive();
            archive.open(appDir);

            Archivist archivist =
                ArchivistFactory.getArchivistForArchive(archive);

            archivist.setAnnotationProcessingRequested(annotationProcessing);
            archivist.setXMLValidation(false);

            return (Application) ApplicationArchivist.openArchive(archivist, archive, true);
        } catch(Throwable t) {
            throw new IASDeploymentException(t);
        }
View Full Code Here

                        new Object[]{appId, xmlDir, appDir});
                    in.open(appDir);
                }
            }

            Archivist archivist = null;
            if (manager instanceof AppsManager) {
                archivist = new ApplicationArchivist();
            } else if (manager instanceof EjbModulesManager) {
                archivist = new EjbArchivist();
            } else if (manager instanceof WebModulesManager) {
                archivist = new WebArchivist();
            } else if (manager instanceof AppclientModulesManager) {
                archivist = new AppClientArchivist();
            } else if (manager instanceof ConnectorModulesManager) {
                archivist = new ConnectorArchivist();
            }

            archivist.setAnnotationProcessingRequested(false);
            archivist.setXMLValidation(false);
            Application desc = ApplicationArchivist.openArchive(
                                        appId, archivist, in, true);

            //note: we are not reading back the persistence information here
            //we could, if ever the tools need it.
            if (!desc.isVirtual()) {
                archivist.setHandleRuntimeInfo(false);
                ((ApplicationArchivist)
                    archivist).readModulesDescriptors(desc, in);
                // now process runtime DDs
                archivist.setHandleRuntimeInfo(true);
                archivist.readRuntimeDeploymentDescriptor(in, desc);
            } else {
                return (BundleDescriptor)
                        desc.getBundleDescriptors().iterator().next();
            }
            return desc;
View Full Code Here

            /*
             *Yes, it's a .class file.  Use an app client archivist and, from
             *it, get the default app client descriptor.  Then create the
             *new app client info instance.
             */
            Archivist archivist = new AppClientArchivist();
            result = new ClassFileAppClientInfo(
                    isJWS,
                    logger,
                    locationFile,
                    archivist,
                    mainClassFromCommandLine,
                    classFileFromCommandLine);
        } else {
            /*
             *The user did not specify a .class file on the command line, so
             *the locationFile argument refers to a valid module.
             *Construct an Archivist for the location file.
             */
            Archivist archivist = prepareArchivist(locationFile);
           
            if (archivist != null) {
                /*
                 *Choose which type of concrete AppClientInfo class is
                 *suitable for this app client execution.
View Full Code Here

     *@param className
     *@return concrete Archivist of the correct type given the contents of the archive
     *@exeception IOException in case of error getting an archivist for the archive
     */
    private static Archivist prepareArchivist(File file) throws IOException {
        Archivist result = null;
        result = ArchivistFactory.getArchivistForArchive(file);
        if (result instanceof ApplicationArchivist) {
            return new GeneratedAppClientJarArchivist();
        }
        return result;
View Full Code Here

     * This is to be used for file publishing only. In case of wsdlImports and wsdlIncludes
     * we need to copy the nested wsdls from applications folder to the generated/xml folder
     *
     */
    private void copyExtraFilesToGeneratedFolder( DeploymentContext context) throws IOException{
        Archivist archivist = habitat.getService(Archivist.class);

        ReadableArchive archive = archiveFactory.openArchive(
                context.getSourceDir());

        WritableArchive archive2 = archiveFactory.createArchive(
                context.getScratchDir("xml"));

        // copy the additional webservice elements etc
        archivist.copyExtraElements(archive, archive2);
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.archivist.Archivist

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.