Search in sources :

Example 6 with WebResourceRoot

use of org.apache.catalina.WebResourceRoot in project tomee by apache.

the class TomcatWebAppBuilder method destroy.

/**
     * {@inheritDoc}
     */
@Override
public void destroy(final StandardContext standardContext) {
    final Loader standardContextLoader = standardContext.getLoader();
    if (LazyStopLoader.class.isInstance(standardContextLoader)) {
        final Loader delegate = LazyStopLoader.class.cast(standardContextLoader).getDelegateLoader();
        if (TomEEWebappLoader.class.isInstance(delegate)) {
            final TomEEWebappLoader webappLoader = TomEEWebappLoader.class.cast(delegate);
            final ClassLoader loader = webappLoader.internalLoader();
            webappLoader.clearLoader();
            if (TomEEWebappClassLoader.class.isInstance(loader)) {
                TomEEWebappClassLoader.class.cast(loader).internalDestroy();
            }
        }
    }
    final WebResourceRoot root = standardContext.getResources();
    if (LazyStopStandardRoot.class.isInstance(root)) {
        try {
            LazyStopStandardRoot.class.cast(root).internalDestroy();
        } catch (final LifecycleException e) {
            throw new IllegalStateException(e);
        }
    }
}
Also used : LifecycleException(org.apache.catalina.LifecycleException) WebappLoader(org.apache.catalina.loader.WebappLoader) Loader(org.apache.catalina.Loader) DeploymentLoader(org.apache.openejb.config.DeploymentLoader) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Example 7 with WebResourceRoot

use of org.apache.catalina.WebResourceRoot in project tomcat by apache.

the class WebResourceRootSF method storeChildren.

/**
     * Store the specified Resources children.
     *
     * @param aWriter
     *            PrintWriter to which we are storing
     * @param indent
     *            Number of spaces to indent this element
     *
     * @exception Exception
     *                if an exception occurs while storing
     */
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aResourceRoot, StoreDescription parentDesc) throws Exception {
    if (aResourceRoot instanceof WebResourceRoot) {
        WebResourceRoot resourceRoot = (WebResourceRoot) aResourceRoot;
        // Store nested <PreResources> elements
        WebResourceSet[] preResourcesArray = resourceRoot.getPreResources();
        StoreDescription preResourcesElementDesc = getRegistry().findDescription(WebResourceSet.class.getName() + ".[PreResources]");
        if (preResourcesElementDesc != null) {
            for (WebResourceSet preResources : preResourcesArray) {
                preResourcesElementDesc.getStoreFactory().store(aWriter, indent, preResources);
            }
        }
        // Store nested <JarResources> elements
        WebResourceSet[] jarResourcesArray = resourceRoot.getJarResources();
        StoreDescription jarResourcesElementDesc = getRegistry().findDescription(WebResourceSet.class.getName() + ".[JarResources]");
        if (jarResourcesElementDesc != null) {
            for (WebResourceSet jarResources : jarResourcesArray) {
                jarResourcesElementDesc.getStoreFactory().store(aWriter, indent, jarResources);
            }
        }
        // Store nested <PostResources> elements
        WebResourceSet[] postResourcesArray = resourceRoot.getPostResources();
        StoreDescription postResourcesElementDesc = getRegistry().findDescription(WebResourceSet.class.getName() + ".[PostResources]");
        if (postResourcesElementDesc != null) {
            for (WebResourceSet postResources : postResourcesArray) {
                postResourcesElementDesc.getStoreFactory().store(aWriter, indent, postResources);
            }
        }
    }
}
Also used : WebResourceSet(org.apache.catalina.WebResourceSet) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Example 8 with WebResourceRoot

use of org.apache.catalina.WebResourceRoot in project tomcat by apache.

the class MapperListener method registerContext.

/**
     * Register context.
     */
private void registerContext(Context context) {
    String contextPath = context.getPath();
    if ("/".equals(contextPath)) {
        contextPath = "";
    }
    Host host = (Host) context.getParent();
    WebResourceRoot resources = context.getResources();
    String[] welcomeFiles = context.findWelcomeFiles();
    List<WrapperMappingInfo> wrappers = new ArrayList<>();
    for (Container container : context.findChildren()) {
        prepareWrapperMappingInfo(context, (Wrapper) container, wrappers);
        if (log.isDebugEnabled()) {
            log.debug(sm.getString("mapperListener.registerWrapper", container.getName(), contextPath, service));
        }
    }
    mapper.addContextVersion(host.getName(), host, contextPath, context.getWebappVersion(), context, welcomeFiles, resources, wrappers);
    if (log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.registerContext", contextPath, service));
    }
}
Also used : Container(org.apache.catalina.Container) ArrayList(java.util.ArrayList) Host(org.apache.catalina.Host) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Example 9 with WebResourceRoot

use of org.apache.catalina.WebResourceRoot in project tomcat by apache.

the class ApplicationContext method getResource.

@Override
public URL getResource(String path) throws MalformedURLException {
    String validatedPath = validateResourcePath(path, false);
    if (validatedPath == null) {
        throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
    }
    WebResourceRoot resources = context.getResources();
    if (resources != null) {
        return resources.getResource(validatedPath).getURL();
    }
    return null;
}
Also used : MalformedURLException(java.net.MalformedURLException) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Example 10 with WebResourceRoot

use of org.apache.catalina.WebResourceRoot in project tomcat by apache.

the class StandardContext method setResources.

@Override
public void setResources(WebResourceRoot resources) {
    Lock writeLock = resourcesLock.writeLock();
    writeLock.lock();
    WebResourceRoot oldResources = null;
    try {
        if (getState().isAvailable()) {
            throw new IllegalStateException(sm.getString("standardContext.resourcesStart"));
        }
        oldResources = this.resources;
        if (oldResources == resources)
            return;
        this.resources = resources;
        if (oldResources != null) {
            oldResources.setContext(null);
        }
        if (resources != null) {
            resources.setContext(this);
        }
        support.firePropertyChange("resources", oldResources, resources);
    } finally {
        writeLock.unlock();
    }
}
Also used : ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) Lock(java.util.concurrent.locks.Lock) WebResourceRoot(org.apache.catalina.WebResourceRoot)

Aggregations

WebResourceRoot (org.apache.catalina.WebResourceRoot)15 File (java.io.File)6 Loader (org.apache.catalina.Loader)4 JarFile (java.util.jar.JarFile)3 WebappLoader (org.apache.catalina.loader.WebappLoader)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 LifecycleException (org.apache.catalina.LifecycleException)2 Manager (org.apache.catalina.Manager)2 WebResource (org.apache.catalina.WebResource)2 WebResourceSet (org.apache.catalina.WebResourceSet)2 StandardContext (org.apache.catalina.core.StandardContext)2 DeploymentLoader (org.apache.openejb.config.DeploymentLoader)2 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 Lock (java.util.concurrent.locks.Lock)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 JarEntry (java.util.jar.JarEntry)1