Skip to content

Commit

Permalink
WELD-2787 Remove legacy integration points for Jetty
Browse files Browse the repository at this point in the history
  • Loading branch information
manovotn committed Apr 26, 2024
1 parent aab0ff0 commit 2b92238
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@
/**
* Jetty Container.
* <p>
* This container requires that the jetty server register DecoratingListener
* This container requires that the jetty server register CdiDecoratingListener
* to dynamically register a decorator instance that wraps the {@link WeldDecorator}
* added as an attribute. The jetty <code>decorate</code> module does this and indicates it's
* availability by setting the "org.eclipse.jetty.webapp.DecoratingListener" to the
* availability by setting the "org.eclipse.jetty.ee10.webapp.DecoratingListener" to the
* name of the watched attribute.
* </p>
*
* <p>
* Jetty also provides the <code>cdi-spi</code> module that may directly invoke the
* CDI SPI. This module indicates it's availability by setting the "org.eclipse.jetty.cdi"
* context attribute to "CdiDecorator". If this module is used, then this JettyContainer
* context attribute to "CdiSpiDecorator". If this module is used, then this JettyContainer
* only logs a message and does no further integration.
* </p>
*
* @since Jetty 9.4.20
* @see JettyLegacyContainer
* @since Jetty 12+
* @author <a href="mailto:[email protected]">Greg Wilkins</a>
*/
public class JettyContainer extends AbstractJettyContainer {
Expand All @@ -51,8 +50,6 @@ public class JettyContainer extends AbstractJettyContainer {
public static final String CDI_SPI_DECORATOR_MODE = "CdiSpiDecorator";
public static final String CDI_DECORATING_LISTENER_MODE = "CdiDecoratingListener";
public static final String CDI_DECORATING_LISTENER_ATTRIBUTE = "org.eclipse.jetty.cdi.decorator";
public static final String DECORATING_LISTENER_MODE = "DecoratingListener";
public static final String DECORATING_LISTENER_ATTRIBUTE = "org.eclipse.jetty.webapp.DecoratingListener";

protected String classToCheck() {
// Never called because touch is overridden below.
Expand All @@ -62,25 +59,19 @@ protected String classToCheck() {
@Override
public boolean touch(ResourceLoader resourceLoader, ContainerContext context) throws Exception {
ServletContext servletContext = context.getServletContext();
// The jetty cdi modules from 9.4.20 sets JETTY_CDI_ATTRIBUTE to indicate that a
// DecoratingListener is registered. Weld-3.1.2.Final documented that the decorate module
// could be used directly, which sets DECORATING_LISTENER_ATTRIBUTE
return servletContext.getAttribute(JETTY_CDI_ATTRIBUTE) instanceof String ||
servletContext.getAttribute(DECORATING_LISTENER_ATTRIBUTE) instanceof String;
return servletContext.getAttribute(JETTY_CDI_ATTRIBUTE) instanceof String;
}

@Override
public void initialize(ContainerContext context) {
try {
ServletContext servletContext = context.getServletContext();
String mode = (String) servletContext.getAttribute(JETTY_CDI_ATTRIBUTE);
if (mode == null) {
mode = DECORATING_LISTENER_MODE;
}
switch (mode) {
case CDI_SPI_DECORATOR_MODE:
// For use with the cdi-spi module
// No further integration required
// For use with the cdi-spi module; no further integration required
// NOTE: this is an internal module/mode, and it's unexpected to be explicitly used
// We only keep track of it to be able to say it's not an error state
JettyLogger.LOG.jettyCdiSpiIsSupported();
break;

Expand All @@ -92,16 +83,6 @@ public void initialize(ContainerContext context) {
JettyLogger.LOG.jettyCdiDecorationIsSupported();
break;

case DECORATING_LISTENER_MODE:
// For use with the decorate module
// This mode is only needed to match the Weld-3.1.2 documentation.
// Initialize a JettyWeldInjector and create WeldDecorator for it
super.initialize(context);
String attribute = (String) servletContext.getAttribute(DECORATING_LISTENER_ATTRIBUTE);
servletContext.setAttribute(attribute, new WeldDecorator(servletContext));
JettyLogger.LOG.jettyDecorationIsSupported();
break;

default:
throw JettyLogger.LOG.unknownIntegrationMode(mode);
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
import org.jboss.weld.environment.deployment.discovery.DiscoveryStrategyFactory;
import org.jboss.weld.environment.deployment.discovery.jandex.Jandex;
import org.jboss.weld.environment.jetty.JettyContainer;
import org.jboss.weld.environment.jetty.JettyLegacyContainer;
import org.jboss.weld.environment.logging.CommonLogger;
import org.jboss.weld.environment.servlet.deployment.ServletContextBeanArchiveHandler;
import org.jboss.weld.environment.servlet.deployment.WebAppBeanArchiveScanner;
Expand Down Expand Up @@ -371,8 +370,7 @@ protected Container findContainer(ContainerContext ctx, StringBuilder dump) {
if (container == null) {
// 3. Built-in containers in predefined order
container = checkContainers(ctx, dump,
Arrays.asList(TomcatContainer.INSTANCE, JettyContainer.INSTANCE, JettyLegacyContainer.INSTANCE,
UndertowContainer.INSTANCE));
Arrays.asList(TomcatContainer.INSTANCE, JettyContainer.INSTANCE, UndertowContainer.INSTANCE));
}
}
return container;
Expand Down

0 comments on commit 2b92238

Please sign in to comment.