Package org.glassfish.api.deployment.archive

Examples of org.glassfish.api.deployment.archive.ReadableArchive


            classpath.append(File.pathSeparator);

            // add the ear lib libraries if it's ear
            Application app = ctx.getModuleMetaData(Application.class);
            if (!app.isVirtual()) {
                ReadableArchive parentArchive =
                    ctx.getSource().getParentArchive();

                String compatProp = ctx.getAppProps().getProperty(
                    DeploymentProperties.COMPATIBILITY);

                List<URL> earLibURLs =
                    ASClassLoaderUtil.getAppLibDirLibrariesAsList(new File(
                        parentArchive.getURI()), app.getLibraryDirectory(),
                        compatProp)

                for (URL url : earLibURLs) {
                    classpath.append(url.toURI().getPath());
                    classpath.append(File.pathSeparator);
View Full Code Here


                if (moduleContext != null) {
                    return moduleContext;
                }


                final ReadableArchive subArchive;
                try {
                    subArchive = context.getSource().getSubArchive(moduleUri);
                    subArchive.setParentArchive(context.getSource());
                } catch(IOException ioe) {
                    deplLogger.log(Level.WARNING,
                                   ERROR_OCCURRED,
                                   ioe)
                    return null;
View Full Code Here

    public MetaData getMetaData() {
        return new MetaData(false, new Class[] { Application.class }, null);
    }

    private Application processDOL(DeploymentContext dc) throws IOException {
        ReadableArchive sourceArchive = dc.getSource();

        sourceArchive.setExtraData(Types.class, dc.getTransientAppMetaData(Types.class.getName(), Types.class));
        sourceArchive.setExtraData(Parser.class, dc.getTransientAppMetaData(Parser.class.getName(), Parser.class));

        ClassLoader cl = dc.getClassLoader();
        DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);

        String name = params.name();
        String archiveType = dc.getArchiveHandler().getArchiveType();
        Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
        if (archivist == null) {
            // if no JavaEE medata was found in the archive, we return
            // an empty Application object
            return Application.createApplication();
        }
        archivist.setAnnotationProcessingRequested(true);
        String xmlValidationLevel = dasConfig.getDeployXmlValidation();
        archivist.setXMLValidationLevel(xmlValidationLevel);
        if (xmlValidationLevel.equals("none")) {
          archivist.setXMLValidation(false);
        }
        archivist.setRuntimeXMLValidationLevel(xmlValidationLevel);
        if (xmlValidationLevel.equals("none")) {
          archivist.setRuntimeXMLValidation(false);
        }
        Collection<Sniffer> sniffers = dc.getTransientAppMetaData(DeploymentProperties.SNIFFERS, Collection.class);
        archivist.setExtensionArchivists(archivistFactory.getExtensionsArchivists(sniffers, archivist.getModuleType()));
       
        ApplicationHolder holder = dc.getModuleMetaData(ApplicationHolder.class);
        File deploymentPlan = params.deploymentplan;
        handleDeploymentPlan(deploymentPlan, archivist, sourceArchive, holder);
       
        long start = System.currentTimeMillis();
        Application application=null;
        if (holder!=null) {
            application = holder.app;

            application.setAppName(name);
            application.setClassLoader(cl);

            if (application.isVirtual()) {
                ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
                md.setModuleName(name);
            }

            try {
                applicationFactory.openWith(application, sourceArchive,
                    archivist);
            } catch(SAXParseException e) {
                throw new IOException(e);
            }
        }
        else {
            // for case where user specified --name
            // and it's a standalone module
            try {
                application = applicationFactory.openArchive(
                    name, archivist, sourceArchive, true);

                application.setAppName(name);

                ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor();
                md.setModuleName(name);
            } catch(SAXParseException e) {
                throw new IOException(e);
            }
        }

        application.setRegistrationName(name);

        sourceArchive.removeExtraData(Types.class);
        sourceArchive.removeExtraData(Parser.class);

        Logger.getAnonymousLogger().log(Level.FINE, "DOL Loading time" + (System.currentTimeMillis() - start));

        return application;
    }
View Full Code Here

    }   

    protected void saveAppDescriptor(Application application,
        DeploymentContext context) throws IOException {
        if (application != null) {
            ReadableArchive archive = archiveFactory.openArchive(
                context.getSourceDir());
            boolean isMkdirs = context.getScratchDir("xml").mkdirs();
            if (isMkdirs) {
                WritableArchive archive2 = archiveFactory.createArchive(
                    context.getScratchDir("xml"));
View Full Code Here

     * @param parentCl parent classloader
     *
     * @return the parsed DOL object
     */
    public ResultHolder createApplicationDescriptor(File archiveFile, File destRootDir, ClassLoader parentCl) throws IOException {
        ReadableArchive archive = null;
        Application application = null;
        try {
            Descriptor.setBoundsChecking(false);
            archive = archiveFactory.openArchive(archiveFile);
            ArchiveHandler archiveHandler = deployment.getArchiveHandler(archive);
            ActionReport dummyReport = new HTMLActionReporter();

            String appName = DeploymentUtils.getDefaultEEName(archiveFile.getName());

            DeployCommandParameters params = new DeployCommandParameters();
            params.name = appName;

            ExtendedDeploymentContext context = new DeploymentContextImpl(dummyReport, archive, params, env);
            context.setArchiveHandler(archiveHandler);

            if (!archiveFile.isDirectory()) {
                // expand archive
                File destDir = new File(destRootDir, appName);
                if (destDir.exists()) {
                    FileUtils.whack(destDir);
                }
                destDir.mkdirs();
                archiveHandler.expand(archive, archiveFactory.createArchive(destDir), context);
                archive.close();
                archive = archiveFactory.openArchive(destDir);
                context.setSource(archive);
            }

            context.addTransientAppMetaData(ExtendedDeploymentContext.IS_TEMP_CLASSLOADER, Boolean.TRUE); // issue 14564
            String archiveType = context.getArchiveHandler().getArchiveType();
            ClassLoader cl = archiveHandler.getClassLoader(parentCl, context);
            Archivist archivist = archivistFactory.getArchivist(archiveType, cl);
            if (archivist == null) {
                throw new IOException("Cannot determine the Java EE module type for " + archive.getURI());
            }
            archivist.setAnnotationProcessingRequested(true);
            String xmlValidationLevel = dasConfig.getDeployXmlValidation();
            archivist.setXMLValidationLevel(xmlValidationLevel);
            if (xmlValidationLevel.equals("none")) {
                archivist.setXMLValidation(false);
            }
            archivist.setRuntimeXMLValidation(false);
            try {
                application = applicationFactory.openArchive(
                        appName, archivist, archive, true);
            } catch(SAXParseException e) {
                throw new IOException(e);
            }
            if (application != null) {
                application.setClassLoader(cl);
                application.visit((ApplicationVisitor) new ApplicationValidator());
            }
        } finally {
            if (archive != null) {
                archive.close();
            }
            // We need to reset it after descriptor building
            Descriptor.setBoundsChecking(true);
        }

View Full Code Here

        String subEntryName = getFileSubArchivePath(name);
        File subEntry = new File(subEntryName);
        if (subEntry.exists() && isEntryValid(subEntry)) {
            logger.log(DEBUG_LEVEL, "FileArchive.getSubArchive for {0} found that it is valid",
                    subEntry.getAbsolutePath());
            ReadableArchive result = archiveFactory.openArchive(subEntry);
            if (result instanceof AbstractReadableArchive) {
                ((AbstractReadableArchive) result).setParentArchive(this);
            }
            return result;
        } else if (subEntry.exists()) {
View Full Code Here

    private boolean isEntryValid(final File entry, final boolean isLogging, final Logger logger) {
        return staleFileManager().isEntryValid(entry, isLogging, logger);
    }

    private StaleFileManager staleFileManager() {
        ReadableArchive parent = getParentArchive();
        if (parent == null) {
            return staleFileManager;
        }
        if (parent instanceof FileArchive) {
            return ((FileArchive) parent).staleFileManager();
View Full Code Here

        } catch (URISyntaxException e) {
            return null;
        }
        for (ReadableArchiveFactory fac : habitat.getAllByContract(ReadableArchiveFactory.class)) {
            //get the first ReadableArchive and move
            ReadableArchive archive=null;
            try{
                archive = fac.open(uri, properties);
            }catch(Exception e){
                //ignore?
            }
View Full Code Here

            if (f.isFile()) {
                provider = "jar";
            }
        }
        try {
            ReadableArchive archive = habitat.getComponent(ReadableArchive.class, provider);
            if (archive==null) {
                logger.log(Level.SEVERE, "Cannot find an archive implementation for " + provider);
                throw new MalformedURLException("Protocol not supported : " + provider);
            }
            archive.open(path);
            return archive;
        } catch (ComponentException e) {
            logger.log(Level.SEVERE, "Cannot find an archive implementation for " + provider, e);
            throw new MalformedURLException("Protocol not supported : " + provider);
        }
View Full Code Here

    }
   
    private void processArchive(DeploymentContext dc) {

        try {
            ReadableArchive archive = dc.getSource();

            if (ResourceUtil.hasResourcesXML(archive, locator)) {

                Map<String,Map<String, List>> appScopedResources = new HashMap<String,Map<String,List>>();
                Map<String, String> fileNames = new HashMap<String, String>();
View Full Code Here

TOP

Related Classes of org.glassfish.api.deployment.archive.ReadableArchive

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.