diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java index 99054e58b39..ace3450fa5a 100644 --- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java +++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/OneWebAppWithJsp.java @@ -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! diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java index bc2da221fe6..9d1cc3661bc 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationConfiguration.java @@ -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 _discoverableAnnotationHandlers = new ArrayList(); + protected final List _discoverableAnnotationHandlers = new ArrayList<>(); protected ClassInheritanceHandler _classInheritanceHandler; - protected List _containerInitializerAnnotationHandlers = new ArrayList(); + protected final List _containerInitializerAnnotationHandlers = new ArrayList<>(); protected List _parserTasks; @@ -318,29 +318,12 @@ public class AnnotationConfiguration extends AbstractConfiguration String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN); _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> classMap = (ClassInheritanceMap)context.getAttribute(CLASS_INHERITANCE_MAP); - List initializers = (List)context.getAttribute(CONTAINER_INITIALIZERS); - - context.removeAttribute(CLASS_INHERITANCE_MAP); if (classMap != null) classMap.clear(); - - context.removeAttribute(CONTAINER_INITIALIZERS); + context.removeAttribute(CLASS_INHERITANCE_MAP); + + List initializers = (List)context.getAttribute(CONTAINER_INITIALIZERS); if (initializers != null) initializers.clear(); + context.removeAttribute(CONTAINER_INITIALIZERS); if (_discoverableAnnotationHandlers != null) _discoverableAnnotationHandlers.clear(); @@ -408,7 +390,17 @@ public class AnnotationConfiguration extends AbstractConfiguration _parserTasks.clear(); _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); } diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java index 92d811c405f..b4196f3197f 100644 --- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java +++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java @@ -287,6 +287,7 @@ public class ServletContextHandler extends ContextHandler { super.doStop(); _objFactory.clear(); + getServletContext().removeAttribute(DecoratedObjectFactory.ATTR); } /* ------------------------------------------------------------ */