Package org.glassfish.web.loader

Examples of org.glassfish.web.loader.WebappClassLoader


                classLoader = (WebappClassLoader) cl;
            } else {
                classLoader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                    @Override
                    public WebappClassLoader run() {
                        return new WebappClassLoader(cl);
                    }
                });
            }
            classLoader.setResources(container.getResources());
            classLoader.setDebug(this.debug);
View Full Code Here


     */
    protected ClassLoader createClassLoader()
        throws Exception {

        Class<?> clazz = Class.forName(loaderClass);
        WebappClassLoader classLoader = null;

        if (parentClassLoader == null) {
            parentClassLoader = Thread.currentThread().getContextClassLoader();
        }
        Class<?>[] argTypes = { ClassLoader.class };
        Object[] args = { parentClassLoader };
        Constructor<?> constr = clazz.getConstructor(argTypes);
        classLoader = (WebappClassLoader) constr.newInstance(args);

        classLoader.setUseMyFaces(useMyFaces);

        /*
         * Start the WebappClassLoader here as opposed to in the course of
         * WebappLoader#start, in order to prevent it from being started
         * twice (during normal deployment, the WebappClassLoader is created
         * by the deployment backend without calling
         * WebappLoader#createClassLoader, and will have been started
         * by the time WebappLoader#start is called)
         */
        try {
            classLoader.start();
        } catch (Exception e) {
            throw new LifecycleException(e);
        }

        return classLoader;
View Full Code Here

            // Try looking up resource in
            // WEB-INF/lib/[*.jar]/META-INF/resources
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            String metaInfResPath = Globals.META_INF_RESOURCES + path;
            if (cl instanceof WebappClassLoader) {
                WebappClassLoader wcl = (WebappClassLoader)cl;
                final URL resourceUrl = wcl.getResourceFromJars(metaInfResPath);
                if (resourceUrl != null) {
                    // XXX Remove dependency on WebappClassLoader
                    ConcurrentHashMap<String, ResourceEntry> resourceEntries =
                        wcl.getResourceEntries();
                    ResourceEntry resourceEntry = resourceEntries.get(metaInfResPath);
                    if (resourceEntry != null) {
                        // create a CacheEntry to continue the processing
                        cacheEntry = new CacheEntry();
                        try {
View Full Code Here

            ClassLoader cl = createClassLoader();
            if (cl instanceof WebappClassLoader) {
                classLoader = (WebappClassLoader) cl;
            } else {
                classLoader = new WebappClassLoader(cl);
            }
            classLoader.setResources(container.getResources());
            classLoader.setDebug(this.debug);
            classLoader.setDelegate(this.delegate);
View Full Code Here

     */
    protected ClassLoader createClassLoader()
        throws Exception {

        Class<?> clazz = Class.forName(loaderClass);
        WebappClassLoader classLoader = null;

        if (parentClassLoader == null) {
            parentClassLoader = Thread.currentThread().getContextClassLoader();
        }
        Class<?>[] argTypes = { ClassLoader.class };
        Object[] args = { parentClassLoader };
        Constructor<?> constr = clazz.getConstructor(argTypes);
        classLoader = (WebappClassLoader) constr.newInstance(args);

        classLoader.setUseMyFaces(useMyFaces);

        /*
         * Start the WebappClassLoader here as opposed to in the course of
         * WebappLoader#start, in order to prevent it from being started
         * twice (during normal deployment, the WebappClassLoader is created
         * by the deployment backend without calling
         * WebappLoader#createClassLoader, and will have been started
         * by the time WebappLoader#start is called)
         */
        try {
            classLoader.start();
        } catch (Exception e) {
            throw new LifecycleException(e);
        }

        return classLoader;
View Full Code Here

                    wbd.setName(Constants.DEFAULT_WEB_MODULE_NAME);
                    wbd.setContextRoot(contextRoot);
                    wmInfo.setLocation(docroot);
                    wmInfo.setDescriptor(wbd);
                    wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                    wmInfo.setAppClassLoader(new WebappClassLoader(wmInfo.getParentLoader()));
                }
            }

            if (wmInfo == null) {
                _logger.log(Level.SEVERE, "vs.defaultWebModuleNotFound",
View Full Code Here

            wbd.setContextRoot("");
            wmInfo.setLocation(new File(docroot));
            wmInfo.setDescriptor(wbd);
            wmInfo.setParentLoader(
                serverContext.getCommonClassLoader());
            WebappClassLoader loader = new WebappClassLoader(
                wmInfo.getParentLoader());
            loader.start();           
            wmInfo.setAppClassLoader(loader);
            if ( wbd.getApplication() == null ) {
                Application application = new Application(Globals.getDefaultHabitat());
                application.setVirtual(true);
                application.setName(Constants.DEFAULT_WEB_MODULE_NAME);
View Full Code Here

                    wbd.setName(moduleID);
                    wbd.setContextRoot(contextRoot);
                    wmInfo.setDescriptor(wbd);
                    wmInfo.setLocation(docroot);
                    wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                    wmInfo.setAppClassLoader(new WebappClassLoader(wmInfo.getParentLoader()));
                }
            } else {
                Object[] params = { id, getID() };
                _logger.log(Level.SEVERE, "vs.defaultWebModuleDisabled",
                            params);
View Full Code Here

        return detector.handles(archive);
    }

    @Override
    public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) {
        WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
            @Override
            public WebappClassLoader run() {
                return new WebappClassLoader(parent);
            }
        });
        try {
            WebDirContext r = new WebDirContext();
            File base = new File(context.getSource().getURI());
            r.setDocBase(base.getAbsolutePath());

            cloader.setResources(r);
            cloader.addRepository("WEB-INF/classes/", new File(base, "WEB-INF/classes/"));
            if (context.getScratchDir("ejb") != null) {
                cloader.addRepository(context.getScratchDir("ejb").toURI().toURL().toString().concat("/"));
            }
            if (context.getScratchDir("jsp") != null) {
                cloader.setWorkDir(context.getScratchDir("jsp"));
            }

             // add libraries referenced from manifest
            for (URL url : getManifestLibraries(context)) {
                cloader.addRepository(url.toString());
            }

            WebXmlParser webXmlParser = getWebXmlParser(context.getSource());
            configureLoaderAttributes(cloader, webXmlParser, base);
            configureLoaderProperties(cloader, webXmlParser, base);
           
            configureContextXmlAttribute(cloader, base, context);
           
            try {
                final DeploymentContext dc = context;
                final ClassLoader cl = cloader;
               
                AccessController.doPrivileged(
                        new PermsArchiveDelegate.SetPermissionsAction(
                                SMGlobalPolicyUtil.CommponentType.war, dc, cl));
            } catch (PrivilegedActionException e) {
                throw (SecurityException)e.getException();
            }

        } catch(XMLStreamException xse) {
            logger.log(Level.SEVERE, xse.getMessage());
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, xse.getMessage(), xse);
            }
            xse.printStackTrace();
        } catch(IOException ioe) {
            logger.log(Level.SEVERE, ioe.getMessage());
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, ioe.getMessage(), ioe);
            }
            ioe.printStackTrace();
        }

        cloader.start();

        return cloader;
    }
View Full Code Here

            // Try looking up resource in
            // WEB-INF/lib/[*.jar]/META-INF/resources
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            String metaInfResPath = Globals.META_INF_RESOURCES + path;
            if (cl instanceof WebappClassLoader) {
                WebappClassLoader wcl = (WebappClassLoader)cl;
                final URL resourceUrl = wcl.getResourceFromJars(metaInfResPath);
                if (resourceUrl != null) {
                    // XXX Remove dependency on WebappClassLoader
                    ConcurrentHashMap<String, ResourceEntry> resourceEntries =
                        wcl.getResourceEntries();
                    ResourceEntry resourceEntry = resourceEntries.get(metaInfResPath);
                    if (resourceEntry != null) {
                        // create a CacheEntry to continue the processing
                        cacheEntry = new CacheEntry();
                        try {
View Full Code Here

TOP

Related Classes of org.glassfish.web.loader.WebappClassLoader

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.