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);
}
}
}
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);
}
}
}
}
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));
}
}
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;
}
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();
}
}
Aggregations