-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #5162 CDI embedded integration improvements #5177
Issue #5162 CDI embedded integration improvements #5177
Conversation
Clean up CDI integration and documentation to better support embedded usage. + made listener public + added utility class for SCIs
@janbartel @joakime can I get some feedback on this draft. |
jetty-cdi/src/main/java/org/eclipse/jetty/cdi/CdiDecoratingListener.java
Show resolved
Hide resolved
jetty-cdi/src/main/java/org/eclipse/jetty/cdi/CdiDecoratingListener.java
Show resolved
Hide resolved
jetty-cdi/src/main/java/org/eclipse/jetty/cdi/CdiSpiDecorator.java
Outdated
Show resolved
Hide resolved
jetty-plus/src/main/java/org/eclipse/jetty/plus/annotation/ContainerInitializer.java
Show resolved
Hide resolved
jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
Show resolved
Hide resolved
jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
Show resolved
Hide resolved
tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/CDITests.java
Show resolved
Hide resolved
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
||
public class EmbeddedWeldTest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this unit test to test similar features as the webapp, but from embedded
context.addFilter(ServerIDFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); | ||
|
||
// Setup Jetty weld integration | ||
switch (mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think all these modes are recommended, but all variations are probably used somewhere so best to test to know if we break any usages.
Configuration.ClassList.setServerDefault(server).addBefore(JettyWebXmlConfiguration.class.getName(), | ||
AnnotationConfiguration.class.getName()); | ||
|
||
// Need to expose our SCI. This is ugly could be made better in jetty-10 with a CdiConfiguration | ||
webapp.getServerClasspathPattern().add("-" + CdiServletContainerInitializer.class.getName()); | ||
webapp.getSystemClasspathPattern().add(CdiServletContainerInitializer.class.getName()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add a CdiConfiguration to do this in 10.
Hmm test harness approach doesn't work without IDE... refactoring... |
@WalkerWatch can you check the doco changes in this PR |
Clean up CDI integration and documentation to better support embedded usage. + moved EmbeddedWeldTest to jetty-embedded
…62-Improve-Decorating-Listener-Examples
Signed-off-by: Greg Wilkins <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation is fine with one caveat. We try to make use of ventilated prose in asciidoc as it makes maintenance and upkeep easier.
ventilated text
…of github.com:eclipse/jetty.project into jetty-9.4.x-5162-Improve-Decorating-Listener-Examples
…62-Improve-Decorating-Listener-Examples
Signed-off-by: Greg Wilkins <[email protected]>
…of github.com:eclipse/jetty.project into jetty-9.4.x-5162-Improve-Decorating-Listener-Examples
…62-Improve-Decorating-Listener-Examples
Moved tests to jetty-cdi to avoid consequences to other tests in embedded
jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
Show resolved
Hide resolved
jetty-util/src/main/java/org/eclipse/jetty/util/component/ContainerLifeCycle.java
Show resolved
Hide resolved
jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletContextHandler.java
Show resolved
Hide resolved
Signed-off-by: Greg Wilkins <[email protected]>
@janbartel What are the show stoppers for you in this PR? |
@janbartel @joakime nudge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I don't have any showstoppers, but I would like you to take a look at my suggestion for the isKnownDecoratable() method.
{ | ||
if (Object.class == clazz) | ||
return true; | ||
if (isKnownUndecoratable(clazz.getName())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at all fond of the name isKnownDecoratable(). How about instead you remove isKnownDecoratable() and add a field list of _undecoratables, a setter for them, and in isDecoratable() you just check the list? This might also be a good idea in case CDI adds some other classes that can't be decorated?
|
||
However, depending on the exact configuration of the embedded server, either or both steps may not be required as Servlet Container Initializers may be discovered. | ||
|
||
The details for embedding CDI will be explain in the Embedded Jetty with Weld section, but can be adapted to other CDI frameworks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a link here?
Signed-off-by: Greg Wilkins <[email protected]>
* @param undecorated The set of class names that will not be decorated. | ||
* @see #isDecoratable(Class) | ||
*/ | ||
public void setUndecoratedClasses(Set<String> undecorated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant "setUndecoratableClasses". Undecorated makes it sound like they haven't been decorated yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janb I saw that, but I think Undecorated also works, is less of a mouthful and eitherway you need to check with the javadoc to really know what it means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Clean up CDI integration and documentation to better support embedded usage.