-
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
Jetty 10 Configuration abstraction #2983
Comments
Trying to strip down the problem. JPMS module When only But when also @nicolaiparlog do you have suggestions? |
I have an idea how to make that work, but it would of course be much easier if the jetty-webapp module would provide the service. Why doesn't it? |
@nicolaiparlog because providing that service is optional and enabled only when Think, for example, JMX. We want some webapp JMX things to be available, but only if also the The |
I would have to know more about the code to know whether what you describe is really the best approach, but let's assume it is and we need that service in A only when B is present. My general recommendation is to never use "the thing itself" as a service, but a factory for it, so the factory can make decisions like what you describe. What about this? interface ConfigurationFactory {
Optional<Configuration> create(...);
}
public class JmxConfigurationFactory {
public Optional<Configuration> create(...) {
// if JMX present, return JmxConfiguration, else return empty()
}
} |
@nicolaiparlog this should work in both module-path and class-path, so we'll review it and eventually take a stab at implementing "if JMX present" in a way that works for both module-path and class-path. |
All, just to explain a little bit about the why the JmxConfiguration is not in jetty-jmx. Jetty has a bunch of modules that build up the basics which a way below the level of know what a webapp is:
Together, those modules can run a HTTP server, which can optionally be instrumented with JMX - all with no knowledge of webapps or their classloader rules about hiding etc. The in the jetty-webapp module, we introduce the concept of webapps (and their classloader rules etc.) As part of this, we introduce the concept of a Configuration, which is a discovered service that tells the webapp what features are on the containers classpath and thus how the classloader rules should be configured. Modules that are developed with full knowledge of webapps will have their own FooBarConfiguration implementations. However, for features such as JMX, which can be used independently of webapps, the jetty-webapp module itself provides a JmxConfiguration implementation as it knows about both JMX and Configurations. Now just because the service loader discovers the JmxConfiguration from the jetty-webapp module, does not mean that: a) jmx has to be available; b) even if available that a webapp has to use it. I think it should probably be sufficient if we modify JmxConfiguration to have a required class, so that if during ServiceLoader discovery, the JmxConfiguration is unable to be loaded because the jetty-jmx module is not available, then the JmxConfiguration simply is not an available configuration. If jetty-jmx is on the module path, then it should be discover and loaded and available. What am I missing here? |
@sbordet isn't it sufficient just to make public class JmxConfiguration extends AbstractConfiguration
{
public JmxConfiguration()
{
addDependents(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class);
protectAndExpose(ObjectMBean.class.getPackage().getName()+".");
}
} if |
jetty-jmx has been an oddball (to me). currently, the dependencies look like this ...
IMO, the annotations should be 1 module, the bindings/implementation/configuration should be another/different module. |
I'm not following you?
Generally speaking, all modules provide their own MBeans, but these are optional so most modules optionally depend on I'm not following how |
@sbordet as @janbartel has just pointed out to me that the So as well as making |
Signed-off-by: Greg Wilkins <gregw@webtide.com>
I've created PR #2984 to show how I think this can be fixed. However, it is a little verbose giving and info saying JmxConfiguration can't be loaded if it is not able to be loaded. |
Issue #2983 JmxConfiguration JPMS ready
Signed-off-by: Greg Wilkins <gregw@webtide.com>
Updated all services whose implementation is in jetty-webapp. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
If this is an option, it is definitely the cleanest solution (at least as far as the JPMS is concerned). |
Fixed jetty-webapp dependencies. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This issue has been automatically marked as stale because it has been a full year without activit. It will be closed if no further activity occurs. Thank you for your contributions. |
@sbordet is this JPMS concern still true in Jetty 10? I thought we had a successful (and happy) JPMS on Jetty 10 now? |
I would need to review this. |
Closing as fixed. @sbordet open a more specific issue if there is one! |
In Jetty 10, a
o.e.j.webapp.Configuration
abstraction has been added, but unfortunately it does not play well with JPMS modules.The problem is that it relies on the
ServiceLoader
mechanism, but assuming classes are available in the class-path.For example the Jetty module
jetty-jmx
defines aConfiguration
serviceJmxConfiguration
that is actually present in thejetty-webapp
module.The same happens for Jetty module
apache-jsp
.In order for the service in
jetty-jmx
to be discovered by the JPMS module machinery, you would need to add it to thejetty-jmx
module-info.java
:Unfortunately this means that
jetty-jmx
now has a hard dependency onjetty-webapp
which is not good.With JPMS, the service implementation must be provided by the JPMS module itself, not by some other JPMS module.
The text was updated successfully, but these errors were encountered: