Skip to content

Commit

Permalink
Revert changes to ServletContainerInitializer
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Feb 21, 2021
1 parent 7760d04 commit ed86361
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 39 deletions.
Expand Up @@ -747,33 +747,6 @@ else if (handler instanceof ServletHandler)
relinkHandlers();
}

/**
* Utility Method to allow for manual execution of {@link javax.servlet.ServletContainerInitializer} when using Embedded Jetty.
* @param containerInitializer the ServletContainerInitializer to register.
* @see Initializer
*/
public void addServletContainerInitializer(ServletContainerInitializer containerInitializer)
{
if (!isStopped())
throw new IllegalStateException("ServletContainerInitializers should be added before starting");

addServletContainerInitializer(containerInitializer, Collections.emptySet());
}

/**
* Utility Method to allow for manual execution of {@link javax.servlet.ServletContainerInitializer} when using Embedded Jetty.
* @param containerInitializer the ServletContainerInitializer to register.
* @param classes the Set of application classes.
* @see Initializer
*/
public void addServletContainerInitializer(ServletContainerInitializer containerInitializer, Set<Class<?>> classes)
{
if (!isStopped())
throw new IllegalStateException("ServletContainerInitializers should be added before starting");

addManaged(new Initializer(this, containerInitializer, classes));
}

/**
* The DecoratedObjectFactory for use by IoC containers (weld / spring / etc)
*
Expand Down
Expand Up @@ -25,9 +25,7 @@
/**
* Utility Methods for manual execution of {@link javax.servlet.ServletContainerInitializer} when
* using Embedded Jetty.
* @deprecated use {@link org.eclipse.jetty.servlet.ServletContextHandler#addServletContainerInitializer(ServletContainerInitializer)}.
*/
@Deprecated
public final class ContainerInitializer
{
/**
Expand Down
@@ -1,6 +1,6 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
Expand Down
@@ -1,6 +1,6 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// Copyright (c) 1995-2021 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
Expand Down
Expand Up @@ -103,29 +103,29 @@ public static Server createServerWithServletContext(String mode)

case "CdiServletContainerInitializer+Listener":
// Expect:INFO: WELD-ENV-001213: Jetty CDI SPI support detected, CDI injection will be available in Listeners, Servlets and Filters.
context.addServletContainerInitializer(new CdiServletContainerInitializer());
context.addBean(new ServletContextHandler.Initializer(context, new CdiServletContainerInitializer()));
context.addEventListener(new org.jboss.weld.environment.servlet.Listener());
break;

case "CdiServletContainerInitializer(CdiDecoratingListener)+Listener":
// Expect:INFO: WELD-ENV-001212: Jetty CdiDecoratingListener support detected, CDI injection will be available in Listeners, Servlets and Filters
context.setInitParameter(CdiServletContainerInitializer.CDI_INTEGRATION_ATTRIBUTE, CdiDecoratingListener.MODE);
context.addServletContainerInitializer(new CdiServletContainerInitializer());
context.addBean(new ServletContextHandler.Initializer(context, new CdiServletContainerInitializer()));
context.addEventListener(new org.jboss.weld.environment.servlet.Listener());
break;

case "CdiServletContainerInitializer+EnhancedListener":
// Expect:INFO: WELD-ENV-001213: Jetty CDI SPI support detected, CDI injection will be available in Listeners, Servlets and Filters.
context.addServletContainerInitializer(new CdiServletContainerInitializer());
context.addServletContainerInitializer(new org.jboss.weld.environment.servlet.EnhancedListener());
context.addBean(new ServletContextHandler.Initializer(context, new CdiServletContainerInitializer()));
context.addBean(new ServletContextHandler.Initializer(context, new org.jboss.weld.environment.servlet.EnhancedListener()));
break;

// NOTE: This is the preferred mode from the Weld team.
case "CdiServletContainerInitializer(CdiDecoratingListener)+EnhancedListener":
// Expect:INFO: WELD-ENV-001212: Jetty CdiDecoratingListener support detected, CDI injection will be available in Listeners, Servlets and Filters
context.setInitParameter(CdiServletContainerInitializer.CDI_INTEGRATION_ATTRIBUTE, CdiDecoratingListener.MODE);
context.addServletContainerInitializer(new CdiServletContainerInitializer());
context.addServletContainerInitializer(new org.jboss.weld.environment.servlet.EnhancedListener());
context.addBean(new ServletContextHandler.Initializer(context, new CdiServletContainerInitializer()));
context.addBean(new ServletContextHandler.Initializer(context, new org.jboss.weld.environment.servlet.EnhancedListener()));
break;
}

Expand Down Expand Up @@ -190,8 +190,8 @@ public void testWebappContext() throws Exception
server.setHandler(webapp);

webapp.setInitParameter(CdiServletContainerInitializer.CDI_INTEGRATION_ATTRIBUTE, CdiDecoratingListener.MODE);
webapp.addServletContainerInitializer(new CdiServletContainerInitializer());
webapp.addServletContainerInitializer(new org.jboss.weld.environment.servlet.EnhancedListener());
webapp.addBean(new ServletContextHandler.Initializer(webapp, new CdiServletContainerInitializer()));
webapp.addBean(new ServletContextHandler.Initializer(webapp, new org.jboss.weld.environment.servlet.EnhancedListener()));

String pkg = EmbeddedWeldTest.class.getPackage().getName();
webapp.getServerClassMatcher().add("-" + pkg + ".");
Expand Down

0 comments on commit ed86361

Please sign in to comment.