Package org.glassfish.api.deployment.archive

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


     *
     */
    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"));

View Full Code Here


     *
     */
    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"));

View Full Code Here

                String entryName = entries.nextElement();
                // if a jar in lib dir and not WEB-INF/lib/foo/bar.jar
                if (entryName.endsWith(WeldUtils.JAR_SUFFIX) &&
                    entryName.indexOf(WeldUtils.SEPARATOR_CHAR, libLocation.length() + 1 ) == -1 ) {
                    try {
                        ReadableArchive jarInLib = archive.getSubArchive(entryName);
                        entryPresent = isEntryPresent(jarInLib, WeldUtils.META_INF_BEANS_XML);
                        jarInLib.close();
                    } catch (IOException e) {
                    }
                }
            }
        }
View Full Code Here

            return false;
        }

        boolean isWeldApplication = false;
        ApplicationHolder holder = context.getModuleMetaData(ApplicationHolder.class);
        ReadableArchive appRoot = context.getSource();
        if ((holder != null) && (holder.app != null)) {
            isWeldApplication = scanLibDir(appRoot, holder.app.getLibraryDirectory(), context);
        }

        return isWeldApplication;
View Full Code Here

                String entryName = entries.nextElement();
                // if a jar in lib dir and not WEB-INF/lib/foo/bar.jar
                if (entryName.endsWith(WeldUtils.JAR_SUFFIX) &&
                    entryName.indexOf(WeldUtils.SEPARATOR_CHAR, libLocation.length() + 1 ) == -1 ) {
                    try {
                        ReadableArchive jarInLib = archive.getSubArchive(entryName);
                        entryPresent = isEntryPresent(jarInLib, WeldUtils.META_INF_BEANS_XML);
                        if (!entryPresent) {
                            entryPresent = WeldUtils.isImplicitBeanArchive(context, jarInLib);
                        }
                        jarInLib.close();
                        if (entryPresent) break;
                    } catch (IOException e) {
                    }
                }
            }
View Full Code Here

     */
    private boolean isJaxwsRIDeployment(AnnotationInfo annInfo) {
        boolean riDeployment = false;
        AnnotatedElementHandler annCtx = annInfo.getProcessingContext().getHandler();
        try {
            ReadableArchive moduleArchive = annInfo.getProcessingContext().getArchive();
            if (moduleArchive != null && moduleArchive.exists("WEB-INF/sun-jaxws.xml")
                    && !((Class)annInfo.getAnnotatedElement()).isInterface()
                    && ( (annCtx instanceof WebBundleContext) || (annCtx instanceof WebComponentContext))) {
                riDeployment = true;
            }
        } catch (Exception e) {
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) {
                    logger.log(Level.WARNING, "Error occurred", ioe)
                    return null;
                }
               
View Full Code Here

    @Override
    public void expand(ReadableArchive source, WritableArchive target, DeploymentContext context) throws IOException {
        // expand the top level first so we could read application.xml
        super.expand(source, target, context);

        ReadableArchive source2 = null;
        try {
            /*
             * We know that the expansion is into a directory, so we should know
             * that target is a FileArchive which is also readable as-is.
             */
            source2 = (FileArchive) target;

            ApplicationHolder holder =
                getApplicationHolder(source2, context, false);

            // now start to expand the sub modules
            for (ModuleDescriptor md : holder.app.getModules()) {
                String moduleUri = md.getArchiveUri();
                ReadableArchive subArchive = null;
                WritableArchive subTarget = null;
                ReadableArchive subArchiveToExpand = null;
                try {
                    subArchive = source2.getSubArchive(moduleUri);
                    if (subArchive == null) {
                        _logger.log(Level.WARNING,
                            "Exception while locating sub archive: " +
                            moduleUri);
                        continue;
                    }
                    // optimize performance by retrieving the archive handler
                    // based on module type first
                    ArchiveHandler subHandler = getArchiveHandlerFromModuleType(md.getModuleType());
                    if (subHandler == null) {
                        subHandler = deployment.getArchiveHandler(subArchive);
                    }
                    context.getModuleArchiveHandlers().put(
                        moduleUri, subHandler);
                    if (subHandler!=null) {
                        subTarget = target.createSubArchive(
                            FileUtils.makeFriendlyFilenameExtension(moduleUri));
                        /*
                         * A subarchive might be packaged as a subdirectory
                         * (instead of a nested JAR) in an EAR.  If so and if it
                         * has the same name as the directory into which we'll
                         * expand the submodule, make sure it is also of the
                         * correct archive type (i.e., directory and not JAR)
                         * in which case we don't need to expand it because the developer
                         * already did so before packaging.
                         */
                        subArchiveToExpand = chooseSubArchiveToExpand(moduleUri, subTarget, subArchive, source2);
                        if (subArchiveToExpand != null) {
                            subHandler.expand(subArchiveToExpand, subTarget, context);
                        } else {
                            /*
                             * The target for expansion is the same URI as the
                             * subarchive.  Make sure they are the same type;
                             * if so, we just skip the expansion.  Otherwise,
                             * we would leave a JAR where the rest of
                             * deployment expects a subdirectory so throw an
                             * exception in that case.
                             */
                            if ( ! areSameStorageType(subTarget, subArchive)) {
                                final String msg = MessageFormat.format(
                                        _logger.getResourceBundle().getString("enterprise.deployment.backend.badSubModPackaging"),
                                        subArchive.getURI().toASCIIString(),
                                        subArchive.getClass().getName());
                                throw new RuntimeException(msg);
                            }
                        }
// Keep the original submodule file because the app client deployer needs it.
/*
                        // delete the original module file
                        File origSubArchiveFile = new File(
                            target.getURI().getSchemeSpecificPart(), moduleUri);
                        origSubArchiveFile.delete();
*/
                    }
                } catch(IOException ioe) {
                    _logger.log(Level.FINE, "Exception while processing " +
                        moduleUri, ioe);
                } finally {
                    try {
                        if (subArchive != null) {
                            subArchive.close();
                        }
                        if (subTarget != null) {
                            subTarget.close();
                        }
                        if (subArchiveToExpand != null) {
                            subArchiveToExpand.close();
                        }
                    } catch (IOException ioe) {
                        // ignore
                    }
                }
View Full Code Here

        return (   (arch1 instanceof FileArchive && arch2 instanceof FileArchive)
                || (arch1 instanceof JarArchive && arch2 instanceof JarArchive));
    }

    public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) {
        final ReadableArchive archive  = context.getSource();

        ApplicationHolder holder =
            getApplicationHolder(archive, context, true);

        // the ear classloader hierachy will be
        // ear lib classloader -> embedded rar classloader ->
        // ear classloader -> various module classloaders
        final DelegatingClassLoader embeddedConnCl;
        final EarClassLoader cl;
        // add the libraries packaged in the application library directory
        try {
            String compatProp = context.getAppProps().getProperty(
                DeploymentProperties.COMPATIBILITY);
            // if user does not specify the compatibility property
            // let's see if it's defined in glassfish-application.xml
            if (compatProp == null) {
                GFApplicationXmlParser gfApplicationXmlParser =
                    new GFApplicationXmlParser(context.getSourceDir());
                compatProp = gfApplicationXmlParser.getCompatibilityValue();
                if (compatProp != null) {
                    context.getAppProps().put(
                        DeploymentProperties.COMPATIBILITY, compatProp);
                }
            }
            // if user does not specify the compatibility property
            // let's see if it's defined in sun-application.xml
            if (compatProp == null) {
                SunApplicationXmlParser sunApplicationXmlParser =
                    new SunApplicationXmlParser(context.getSourceDir());
                compatProp = sunApplicationXmlParser.getCompatibilityValue();
                if (compatProp != null) {
                    context.getAppProps().put(
                        DeploymentProperties.COMPATIBILITY, compatProp);
                }
            }
            final URL[] earLibURLs = ASClassLoaderUtil.getAppLibDirLibraries(context.getSourceDir(), holder.app.getLibraryDirectory(), compatProp);
            final EarLibClassLoader earLibCl = AccessController.doPrivileged(new PrivilegedAction<EarLibClassLoader>() {
                @Override
                public EarLibClassLoader run() {
                    return new EarLibClassLoader(earLibURLs, parent);
                }
            });

            embeddedConnCl =  AccessController.doPrivileged(new PrivilegedAction<DelegatingClassLoader>() {
                @Override
                public DelegatingClassLoader run() {
                    return new DelegatingClassLoader(earLibCl);
                }
            });

            cl =  AccessController.doPrivileged(new PrivilegedAction<EarClassLoader>() {
                @Override
                public EarClassLoader run() {
                    return new EarClassLoader(embeddedConnCl);
                }
            });

            // add ear lib to module classloader list so we can
            // clean it up later
            cl.addModuleClassLoader(EAR_LIB, earLibCl);
        } catch (Exception e) {
            _logger.log(Level.SEVERE, strings.get("errAddLibs") ,e);
            throw new RuntimeException(e);
        }



        for (ModuleDescriptor md : holder.app.getModules()) {
            ReadableArchive sub = null;
            String moduleUri = md.getArchiveUri();
            try {
                sub = archive.getSubArchive(moduleUri);
                if (sub instanceof InputJarArchive) {
                    throw new IllegalArgumentException(strings.get("wrongArchType", moduleUri));
                }
            } catch (IOException e) {
                _logger.log(Level.FINE, "Sub archive " + moduleUri + " seems unreadable" ,e);
            }
            if (sub!=null) {
                try {
                    ArchiveHandler handler =
                        context.getModuleArchiveHandlers().get(moduleUri);
                    if (handler == null) {
                        handler = getArchiveHandlerFromModuleType(md.getModuleType());
                        if (handler == null) {
                            handler = deployment.getArchiveHandler(sub);
                        }
                        context.getModuleArchiveHandlers().put(
                            moduleUri, handler);
                    }

                    if (handler!=null) {
                        ActionReport subReport =
                            context.getActionReport().addSubActionsReport();
                        // todo : this is a hack, once again,
                        // the handler is assuming a file:// url
                        ExtendedDeploymentContext subContext =
                            new DeploymentContextImpl(subReport,
                            context.getLogger(),
                            sub,
                            context.getCommandParameters(
                                DeployCommandParameters.class), env) {

                            @Override
                            public File getScratchDir(String subDirName) {
                                String modulePortion = Util.getURIName(
                                    getSource().getURI());
                                return (new File(super.getScratchDir(
                                    subDirName), modulePortion));
                            }
                        };

                        // sub context will store the root archive handler also
                        // so we can figure out the enclosing archive type
                        subContext.setArchiveHandler
                            (context.getArchiveHandler());

                        sub.setParentArchive(context.getSource());

                        ClassLoader subCl = handler.getClassLoader(cl, subContext);
                        if (md.getModuleType().equals(XModuleType.EJB)) {
                            // for ejb module, we just add the ejb urls
                            // to EarClassLoader and use that to load
View Full Code Here

     */
    private boolean isJaxwsRIDeployment(AnnotationInfo annInfo) {
        boolean riDeployment = false;
        AnnotatedElementHandler annCtx = annInfo.getProcessingContext().getHandler();
        try {
            ReadableArchive moduleArchive = annInfo.getProcessingContext().getArchive();
            if (moduleArchive != null && moduleArchive.exists("WEB-INF/sun-jaxws.xml")
                    && !((Class)annInfo.getAnnotatedElement()).isInterface()
                    && ( (annCtx instanceof WebBundleContext) || (annCtx instanceof WebComponentContext))) {
                riDeployment = true;
            }
        } catch (Exception e) {
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.