Package com.sun.enterprise.deployment.deploy.shared

Examples of com.sun.enterprise.deployment.deploy.shared.FileArchive


      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()) {
View Full Code Here


        }      
        try {
           
            JarArchiveFactory jaf = new JarArchiveFactory();
            FileArchiveFactory faf = new FileArchiveFactory();
            FileArchive farc = (FileArchive)faf.openArchive(new File(new File(new File(sourceDir, appDir), earDirName), moduleDirName).getAbsolutePath());
            String suffix = ".jar"; //default to .jar
            //File temp;
            Enumeration e = farc.entries();
            //figure out what type of module this is by the existance of the standard dd's
            while(e.hasMoreElements()) {
                String entry = (String)e.nextElement();
                if (entry.equalsIgnoreCase("WEB-INF/web.xml")) {
                    suffix = ".war";
                } else if (entry.equalsIgnoreCase("META-INF/ra.xml")) {
                    suffix = ".rar";
                }
            }
            //temp = File.createTempFile(moduleName, suffix);
            File tempJar = new File(targetDir, moduleName + suffix);
            String path = tempJar.getAbsolutePath();
            //temp.delete();
            OutputJarArchive targetModule = (OutputJarArchive)jaf.createArchive(path);
            logger.fine(stringManager.getString("upgrade.deployment.addingInfoMsg") + targetModule.getArchiveUri());
            e = farc.entries();
            while(e.hasMoreElements()) {
                String entry = (String)e.nextElement();
                InputStream in = farc.getEntry(entry);
                if (entry.equals("WEB-INF/web.xml")) {
                    InputStream fixedDescriptor = fixWebServiceDescriptor(farc);
                    if(fixedDescriptor != null) {
                        in = fixedDescriptor;
                    }
                }
            //start RFE 6389864
                if(entry.equals("WEB-INF/sun-web.xml")) {
                    checkDescriptors(farc, "sun-web.xml", "WEB-INF");
                        }
                if(entry.equals("META-INF/sun-ejb-jar.xml")) {
                    checkDescriptors(farc, "sun-ejb-jar.xml", "META-INF");
                }
    //end RFE 6389864
                OutputStream out = null;
                try {
                    out = targetModule.putNextEntry(entry);
                    int i = in.read();
                    while (i > -1) {
                        out.write(i);
                        i = in.read();
                    }
                } catch(java.util.zip.ZipException z) {
                    logger.warning(stringManager.getString("upgrade.deployment.zipExceptionMsg")+z.getMessage());
                }catch (IOException ioe) {
                    logger.severe(stringManager.getString("upgrade.deployment.ioExceptionMsg")+ioe.getMessage());
                }
                finally {
                    targetModule.closeEntry();
                    if (in != null) in.close();
                    //if (out != null) out.close();
                }

            }
            InputStream in = farc.getEntry(JarFile.MANIFEST_NAME);
            OutputStream out = null;
            try {
                  if(in != null){
                    out = targetModule.putNextEntry(JarFile.MANIFEST_NAME);
                    int i = in.read();
View Full Code Here

                descriptor = request.getDescriptor().getStandaloneBundleDescriptor();
            } else {
                descriptor = request.getDescriptor();
            }
           
            AbstractArchive source = new FileArchive();
            ((FileArchive) source).open(request.getDeployedDirectory().getAbsolutePath());
            PEDeploymentFactoryImpl pe = new PEDeploymentFactoryImpl();
            Properties props = getPropertiesForClientJarMaker(
                CLIENT_JAR_CHOICES.getClientJarChoice(clientJarChoice),
                request, descriptor);
            ClientJarMaker jarMaker = pe.getClientJarMaker(props);

            // copy xml files from generated directory archive to original
            // directory archive so the created client jar contain
            // processed xml files.
            if (FileUtils.safeIsDirectory(
                request.getGeneratedXMLDirectory())) {
                AbstractArchive source2 = new FileArchive();
                ((FileArchive) source2).open(
                    request.getGeneratedXMLDirectory().getAbsolutePath());
                jarMaker.create(descriptor, source, source2, target, clientStubs,
                    null);
                source2.close();
            } else {
                jarMaker.create(descriptor, source, target, clientStubs,null);
            }
            source.close();
            target.close();
View Full Code Here

                getStubsDir().mkdirs();

                // construct the standard application.xml if omitted
                ApplicationArchivist appArchivist = new ApplicationArchivist();
            String dir = request.getDeployedDirectory().getAbsolutePath();
                FileArchive appArchive = new FileArchive();
                appArchive.open(dir);
                if (!appArchivist.hasStandardDeploymentDescriptor(appArchive)) {
                    Application appDesc =
                        Application.createApplication(appArchive,true,true);
                    request.setDescriptor(appDesc);
                }
View Full Code Here

                getStubsDir().mkdirs();

                // construct the standard application.xml if omitted
                ApplicationArchivist appArchivist = new ApplicationArchivist();
            String dir = request.getDeployedDirectory().getAbsolutePath();
                FileArchive appArchive = new FileArchive();
                appArchive.open(dir);
                if (!appArchivist.hasStandardDeploymentDescriptor(appArchive)) {
                    Application appDesc =
                        Application.createApplication(appArchive,true,true);
                    request.setDescriptor(appDesc);
                }
View Full Code Here

    public JaxRpcRICodegen() {
        rpcFactory = JaxRpcObjectFactory.newInstance();
    }
   
    public void run(EjbcContext context) throws Exception {
        rootLocation_ = new FileArchive();
        rootLocation_.open(context.getSrcDir().getAbsolutePath());
        this.context = context;
        Application application = context.getDescriptor();
        application.visit((ApplicationVisitor) this);
    }
View Full Code Here

     */
    static Application getAppDescriptor(String appDir, boolean annotationProcessing)
            throws IASDeploymentException
    {
    try {
            FileArchive archive = new FileArchive();
            archive.open(appDir);

            ApplicationArchivist archivist = new ApplicationArchivist();
            archivist.setAnnotationProcessingRequested(annotationProcessing);
            archivist.setXMLValidation(false);

View Full Code Here

    static Application getModuleDescriptor(String appDir, boolean annotationProcessing)
            throws IASDeploymentException
    {
        try {
            FileArchive archive = new FileArchive();
            archive.open(appDir);

            Archivist archivist =
                ArchivistFactory.getArchivistForArchive(archive);

            archivist.setAnnotationProcessingRequested(annotationProcessing);
View Full Code Here

                return application;
            }
        }

        //Now, load from disk
        FileArchive in = new FileArchive();
        try {
            String appDir = manager.getLocation(appId);
            // if is system predeployed app, load from original app dir
            // else load from generated/xml dir
            // print a warning if generated/xml dir is not there
            // and load from original dir (upgrade scenario)
            if (manager.isSystemAdmin(appId)) {
                in.open(appDir);
            } else {
                String xmlDir = manager.getGeneratedXMLLocation(appId);
                if (FileUtils.safeIsDirectory(xmlDir)) {
                    /*
                     * If default-web.xml is more recent than the generated
                     * directory, then the generated descriptor does not reflect
                     * the current contents of default-web.xml.
                     */
                    File xmlDirFile = new File(xmlDir);
                    if (xmlDirFile.lastModified() < DOLLoadingContext.defaultWebXMLLastModified()) {
                        _logger.log(Level.INFO, "enterprise.deployment.backend.default_web_xml_more_recent",
                                new Object[] {appId, appDir});
                        in.open(appDir);
                    } else {
                        in.open(xmlDir);
                    }
                } else {
                    // log a warning message in the server log
                    _logger.log(Level.WARNING,
                        "enterprise.deployment.backend.no_generated_xmldir",
                        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;
        } catch (Exception ex) {
            _logger.log(Level.SEVERE,
                        "enterprise.deployment.backend.get_descriptor_failed",
                        new Object[]{appId});
            IASDeploymentException de = new IASDeploymentException(ex.getMessage());
            de.initCause(ex);
            throw de;
        } finally {
            try {
                in.close();
            } catch (Exception ex) {}
        }
    }
View Full Code Here

        archivist.processAnnotations(appClient, archive);
    }
   
    protected AbstractArchive expand(File file)
        throws IOException, Exception {
        FileArchive appArchive = new FileArchive();
        appArchive.open(file.getAbsolutePath());
        return appArchive;
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.deployment.deploy.shared.FileArchive

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.