Merge pull request #3081 from eclipse/jetty-9.4.x-cleanup-webapp-context
Cleanup webapp context
This commit is contained in:
commit
871e05fd6a
|
@ -55,7 +55,7 @@ public class OneWebAppWithJsp
|
|||
WebAppContext webapp = new WebAppContext();
|
||||
webapp.setContextPath( "/" );
|
||||
File warFile = new File(
|
||||
"../../jetty-distribution/target/distribution/demo-base/webapps/test.war" );
|
||||
"jetty-distribution/target/distribution/demo-base/webapps/test.war" );
|
||||
if (!warFile.exists())
|
||||
{
|
||||
throw new RuntimeException( "Unable to find WAR File: "
|
||||
|
@ -96,7 +96,7 @@ public class OneWebAppWithJsp
|
|||
// itself.
|
||||
HashLoginService loginService = new HashLoginService();
|
||||
loginService.setName( "Test Realm" );
|
||||
loginService.setConfig( "src/test/resources/realm.properties" );
|
||||
loginService.setConfig( "examples/embedded/src/test/resources/realm.properties" );
|
||||
server.addBean( loginService );
|
||||
|
||||
// Start things up!
|
||||
|
|
|
@ -79,9 +79,9 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
public static final int DEFAULT_MAX_SCAN_WAIT = 60; /* time in sec */
|
||||
public static final boolean DEFAULT_MULTI_THREADED = true;
|
||||
|
||||
protected List<AbstractDiscoverableAnnotationHandler> _discoverableAnnotationHandlers = new ArrayList<AbstractDiscoverableAnnotationHandler>();
|
||||
protected final List<AbstractDiscoverableAnnotationHandler> _discoverableAnnotationHandlers = new ArrayList<>();
|
||||
protected ClassInheritanceHandler _classInheritanceHandler;
|
||||
protected List<ContainerInitializerAnnotationHandler> _containerInitializerAnnotationHandlers = new ArrayList<ContainerInitializerAnnotationHandler>();
|
||||
protected final List<ContainerInitializerAnnotationHandler> _containerInitializerAnnotationHandlers = new ArrayList<>();
|
||||
|
||||
protected List<ParserTask> _parserTasks;
|
||||
|
||||
|
@ -319,28 +319,11 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
_sciExcludePattern = (tmp==null?null:Pattern.compile(tmp));
|
||||
}
|
||||
|
||||
|
||||
public void addDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler)
|
||||
{
|
||||
_discoverableAnnotationHandlers.add(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deconfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
context.removeAttribute(CLASS_INHERITANCE_MAP);
|
||||
context.removeAttribute(CONTAINER_INITIALIZERS);
|
||||
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER);
|
||||
if (starter != null)
|
||||
{
|
||||
context.removeBean(starter);
|
||||
context.removeAttribute(CONTAINER_INITIALIZER_STARTER);
|
||||
}
|
||||
|
||||
if (_loadedInitializers != null)
|
||||
_loadedInitializers.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.webapp.AbstractConfiguration#configure(org.eclipse.jetty.webapp.WebAppContext)
|
||||
*/
|
||||
|
@ -386,15 +369,14 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
public void postConfigure(WebAppContext context) throws Exception
|
||||
{
|
||||
Map<String, Set<String>> classMap = (ClassInheritanceMap)context.getAttribute(CLASS_INHERITANCE_MAP);
|
||||
List<ContainerInitializer> initializers = (List<ContainerInitializer>)context.getAttribute(CONTAINER_INITIALIZERS);
|
||||
|
||||
context.removeAttribute(CLASS_INHERITANCE_MAP);
|
||||
if (classMap != null)
|
||||
classMap.clear();
|
||||
context.removeAttribute(CLASS_INHERITANCE_MAP);
|
||||
|
||||
context.removeAttribute(CONTAINER_INITIALIZERS);
|
||||
List<ContainerInitializer> initializers = (List<ContainerInitializer>)context.getAttribute(CONTAINER_INITIALIZERS);
|
||||
if (initializers != null)
|
||||
initializers.clear();
|
||||
context.removeAttribute(CONTAINER_INITIALIZERS);
|
||||
|
||||
if (_discoverableAnnotationHandlers != null)
|
||||
_discoverableAnnotationHandlers.clear();
|
||||
|
@ -409,6 +391,16 @@ public class AnnotationConfiguration extends AbstractConfiguration
|
|||
_parserTasks = null;
|
||||
}
|
||||
|
||||
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter)context.getAttribute(CONTAINER_INITIALIZER_STARTER);
|
||||
if (starter != null)
|
||||
{
|
||||
context.removeBean(starter);
|
||||
context.removeAttribute(CONTAINER_INITIALIZER_STARTER);
|
||||
}
|
||||
|
||||
if (_loadedInitializers != null)
|
||||
_loadedInitializers.reload();
|
||||
|
||||
super.postConfigure(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,6 +287,7 @@ public class ServletContextHandler extends ContextHandler
|
|||
{
|
||||
super.doStop();
|
||||
_objFactory.clear();
|
||||
getServletContext().removeAttribute(DecoratedObjectFactory.ATTR);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
Loading…
Reference in New Issue