-
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
Weld/CDI XML backwards compat? #3804
Comments
Signed-off-by: Joakim Erdfelt <[email protected]>
@joakime firstly, can't we do this kind of classpath modification in CdiConfiguration class? That way we hide the details from any XML, plus we can use the convenience methods that read better than adding a negative! Updating the handling of server/system classes is exactly the kind of thing that should be looked at in a migration for 9.4 to 10, so I'm not keen on making things "just work", when they really should be reviewed. Also, while this is not really the subject of this issue, do we REALLY have to expose Or is this because weld comes with a jetty specific class that needs to access these APIs and is beyond our control? Hmmmmm I still think we can do better. Perhaps we have a WeldSpecific Configuration that provides backwards compatible APIs that at least warn if an old jetty-web.xml is uses and that invokes the Weld mechanisms in a way that does need the general API exposure.... eg if they are initially invoked from a listener, then we can wrap their listener in something that turns on the expose server classes switch and then calls Weld. We are going to have to get the weld folks to change their integration, so let's do it in a way that will be more correct and portable in the future. |
See also #3803 |
Looking at the weld integration, ultimately it comes down to installing a public <T> T decorate(T o) {
getInjector().inject(o);
return o;
}
public void destroy(Object o) {
getInjector().destroy(o);
} We must be able to come up with a way to do this without exposing key APIs to the webapp nor binding to specific jetty APIs... even if it is to optionally give special treatment to a nominated class and to use MethodHandles to match the inject/destroy signatures (why javax.inject doesn't have a standard API for this I don't know???). So the challenge is, how to let a webapp add a decorator without container nor webapp having API dependencies on each other? |
Oh and whatever we do, we should back port to 9.4, so the next release of Weld would work on both. Let's say that we came up with a jetty specific attribute name, so in order to install a decorator, the SCI just did: getServletContext().setAttribute("org.eclipse.jetty.webapp.decorator", MyDecorator); Jetty could then use method handles to look for an appropriate signatures for a |
I have created https://issues.jboss.org/browse/WELD-2587 to solicit input from Weld developers |
In order for weld to add the decorator to the servlet context it needs access to both I like the servlet attribute approach. |
Never mind, the method discovery approach seems more reasonable. |
I agree with your change of heart about exposing an API. Once you start down that road, it is long and twisty and never ends. We have mostly avoided exposing special API - at least not code APIs. We have used the context attribute trick a few times to avoid the hard dependencies that are at the root of the difficulties. We can handle multiple decorators by making the set attribute have add semantics, so setting a single attribute just adds to the list. Doing a get returns null. Also this need only be active during the execution of a SCI. |
FWIW I really don't like the semantic of making "set" mean "add" - this is not the normal meaning of set and is confusing. |
The other way to go is to have a |
So here are some of the ways that I can think of to do the loose coupling between a webapp and decorators:
I actually like the last one, as the SCI is already adding a SCL, which can just be-a Decorator rather than add-a Decorator. |
Looks like Weld 3.0.0 already updated to use the new non-deprecated Decorator. |
@joakime That's good, but doesn't really help much. It is the APIs that they need to call to expose the API they need to register their Decorator instance that is a problem. Better to find an API-free way. After discussion with Jan, she suggested that we just look for a SCI that has the right signature and use that as a decorator. |
We have to notify https://openwebbeans.apache.org/ too. (as they do the same thing with their Decorators and Jetty ContextHandler) Have we considered a |
Signed-off-by: Greg Wilkins <[email protected]>
added file headers Signed-off-by: Greg Wilkins <[email protected]>
@joakime ServiceLoader doesn't help, as it still requires a webapp to have a hard dependency on a jetty class. The approach my PR is working on is that the we need to externally to the webapp configure a context listener, then the webapp just needs to set it's decorator as an attribute. I'm pretty sure that will work.... the question is what is the best more portable way with least disruption to get the listener registered? Configuration? jetty-web.xml? |
Used a listener only approach that now passes a manual test when deploying the jetty-test-webapp Signed-off-by: Greg Wilkins <[email protected]>
@joakime Have a look at the PR now. This is working for a manual test in jetty-test-webapp, where you see the steps needed are:
|
Handle already set attribute Signed-off-by: Greg Wilkins <[email protected]>
I think that the DecoratingListener approach is the correct way to go. However, I'm not so sure how we get there from the current state of affairs as the recent CDI releases will just break unless we continue to expose our implementation in the webapp classpath. So I propose that we use the fact we have |
Support CDI integration: + cdi2 module exposes jetty APIs + cdi module uses DecorationListener Signed-off-by: Greg Wilkins <[email protected]>
Remove DecoratingListener tests from test-jetty-webapp Signed-off-by: Greg Wilkins <[email protected]>
Reverted test to use released CDI and cdi2 module for now. To test new mechanism, you need to build the weld snapshot locally, rebuild and switch to cdi module Signed-off-by: Greg Wilkins <[email protected]>
I have also created https://issues.apache.org/jira/browse/OWB-1293 for OpenWebBeans integration |
@stephenc webapp.addConfiguration(new OwbConfiguration()); Note that Configuration has thus changed a bit, so you will not be able to have a single OwbConfiguration class that works for jetty9 and jetty10 - So a helper function may be good... or just good doco? Although if you follow the same pattern as mode 3, you could use just our CdiConfiguration and that will enable the DecoratingListener mechanism without the need for an OWB specific configuration. With regards to mode 2, that is precisely what the updated Configuration mechanism is designed for, so you probably want to have a special OwbModuleConfiguration that can be discovered and will do all the class path conditioning and decorator registering for every webapp. Mode 3 should move to the CDI module that uses the DecoratingListener mechanism. Note that will a bit of care, you can arrange for the one webapp to work with old jetty-web.xml approach or the new mechanism (see the Legacy integration in Weld). I'm off for the rest of the week, but will read your doco in more detail and comment more next week. |
+ SPARSE hint only applies to real os file systems or default file systems, not for all file systems. Signed-off-by: Joakim Erdfelt <[email protected]>
dispose and release context in destroy Signed-off-by: Greg Wilkins <[email protected]>
reverted HttpMethod fromString Signed-off-by: Greg Wilkins <[email protected]>
reverted unnecessary changes Signed-off-by: Greg Wilkins <[email protected]>
…tions (#3838) * Jetty Issue #3804 WELD-2587 Support CDI integration: + cdi2 module exposes jetty APIs + cdi module uses DecorationListener Signed-off-by: Greg Wilkins <[email protected]> * Jetty Issue #3804 WELD-2587 Remove DecoratingListener tests from test-jetty-webapp Signed-off-by: Greg Wilkins <[email protected]> * improve CDI test Signed-off-by: Greg Wilkins <[email protected]> * Jetty Issue #3804 WELD-2587 Reverted test to use released CDI and cdi2 module for now. To test new mechanism, you need to build the weld snapshot locally, rebuild and switch to cdi module Signed-off-by: Greg Wilkins <[email protected]> * remove cdi2 webapp references Signed-off-by: Greg Wilkins <[email protected]> * document attribute Signed-off-by: Greg Wilkins <[email protected]> * improved documentation Signed-off-by: Greg Wilkins <[email protected]> * logging Signed-off-by: Greg Wilkins <[email protected]> * improved javadoc Signed-off-by: Greg Wilkins <[email protected]> * Fixed version Signed-off-by: Greg Wilkins <[email protected]> * Reverted to also provide the DecoratingListener in the decorate module. Renamed cdi-demo to weld-cdi-demo Signed-off-by: Greg Wilkins <[email protected]> * revert from Weld SNAPSHOT Signed-off-by: Greg Wilkins <[email protected]> * test all 3 weld integrations Signed-off-by: Greg Wilkins <[email protected]> * updated destory implementation to release creationalcontext Signed-off-by: Greg Wilkins <[email protected]> * reverted to released Weld version Signed-off-by: Greg Wilkins <[email protected]> * Issue #3804 CDI integration dispose and release context in destroy Signed-off-by: Greg Wilkins <[email protected]> * Improved CDI module documentation Signed-off-by: Greg Wilkins <[email protected]> * WIP on OWB Signed-off-by: Greg Wilkins <[email protected]> * Updates from review Parameterised CDITests Signed-off-by: Greg Wilkins <[email protected]> * share webapp resources for cdi webapp test Signed-off-by: olivier lamy <[email protected]> * Initialize OWB with a SCI so that listeners can be decorated Signed-off-by: Greg Wilkins <[email protected]> * Added OwbDecorator so that cdi2 module can be tested with OWB Signed-off-by: Greg Wilkins <[email protected]> * Lookup attribute name Signed-off-by: Greg Wilkins <[email protected]> * Cleanups Signed-off-by: Greg Wilkins <[email protected]> * Cleanup from Review Don't do lazy bindings Signed-off-by: Greg Wilkins <[email protected]> * Cleanup from Review Treat partial CDI same as no CDI Signed-off-by: Greg Wilkins <[email protected]> * fix maven it test no more need of weld-servlet Signed-off-by: olivier lamy <[email protected]> * cleanup it parent pom removing non needed weld servlet Signed-off-by: olivier lamy <[email protected]> * upgraded to Weld 3.1.2.Final Signed-off-by: Greg Wilkins <[email protected]> * Cleanup from Review Signed-off-by: Greg Wilkins <[email protected]> * Cleanup from Review Signed-off-by: Greg Wilkins <[email protected]>
Rename attributes and classes to have a more regular pattern. The DecoratingListener is now extened by the CdiDecoratingListener which is used by the cdi-decorate module Signed-off-by: Greg Wilkins <[email protected]>
Rename attributes and classes to have a more regular pattern. The DecoratingListener is now extened by the CdiDecoratingListener which is used by the cdi-decorate module Signed-off-by: Greg Wilkins <[email protected]>
Rename attributes and classes to have a more regular pattern. The DecoratingListener is now extened by the CdiDecoratingListener which is used by the cdi-decorate module Signed-off-by: Greg Wilkins <[email protected]>
improved javadoc Signed-off-by: Greg Wilkins <[email protected]>
more review changes Signed-off-by: Greg Wilkins <[email protected]>
Signed-off-by: Joakim Erdfelt <[email protected]>
more review changes Signed-off-by: Greg Wilkins <[email protected]>
more review changes Signed-off-by: Greg Wilkins <[email protected]>
Fixed javadocs. Signed-off-by: Simone Bordet <[email protected]>
Merged into |
Removed cdi2 module from #3946 for Issue #3804 in jetty-10 Signed-off-by: Greg Wilkins <[email protected]>
Fixed bad names in OWB webapp. Don't have the owb jetty-web.xml on by default. Signed-off-by: Greg Wilkins <[email protected]>
We have a backwards compat XML breakage for weld/cdi users starting in Jetty 10.0.x
The documented format ...
https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_class_loading
The new format, starting in Jetty 10.0.x is ...
The changes are ...
WebAppContext.prependServerClass()
method has been removed.org.eclipse.jetty.server.handler.ContextHandler.
(note the extra trailing ".") has been removed.It should be noted that
WebAppContext.prependServerClass()
is a deprecated method in Jetty 9.4.x.https://github.com/eclipse/jetty.project/blob/b9fc1f736241036162ecfed8ea5cde22337b0f0d/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebAppContext.java#L718-L725
The suggested alternative of using
.getServerClasspathPattern()
has been renamed in Jetty 10.0.x togetServerClassMatcher()
Do we want to rename this back to
.getServerClasspathPattern()
in Jetty 10.0.x?Or do we want to bring
.getServerClassMatcher()
back to Jetty 9.4.x?Either approach will minimize the version hassles that weld/cdi will have to deal with.
The text was updated successfully, but these errors were encountered: