-
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 #10437 - Unify Deployer ContextProvider #12583
base: jetty-12.1.x
Are you sure you want to change the base?
Conversation
...-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
Show resolved
Hide resolved
@@ -641,4 580,308 @@ protected void pathChanged(Path path) throws Exception | |||
if (isDeployable(path)) | |||
super.pathChanged(path); | |||
} | |||
|
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.
For the isDeployable
method, as you're doing a lot of rewriting, it may be worth looking into #12543. The problem here is that on a hot redeploy via touching just the war (rather than the associated xml file), line 562 will cause the redeploy not to happen. That line works fine on initial deployment, but not on a redeploy.
jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
Outdated
Show resolved
Hide resolved
<Ref refid="DeploymentManager"> | ||
<Call name="addAppProvider"> | ||
<Arg> | ||
<Ref refid="contextProvider" /> |
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.
Should it be an error to configure more than one ContextProvider
that is scanning the same directory?
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 wouldn't consider that an error.
Sure, it is a weird configuration.
Plus, I don't want to implement directory scanning lock files to prevent that kind of configuration.
jetty.addConfiguration(MavenPaths.projectBase().resolve("src/main/config/etc/jetty-deployment-manager.xml")); | ||
jetty.addConfiguration(MavenPaths.projectBase().resolve("src/main/config/etc/jetty-deploy.xml")); |
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.
Why these need to be referenced by the source, and the others don't?
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.
These should be there for the test to function.
But instead of doing the 12.0.x technique of duplicating these into src/test/resources
and having to keep them in sync, it just made more sense to reference the actual XML files directly instead.
jetty.addConfiguration(MavenPaths.projectBase().resolve("src/main/config/etc/jetty-deployment-manager.xml")); | ||
jetty.addConfiguration(MavenPaths.projectBase().resolve("src/main/config/etc/jetty-deploy.xml")); |
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.
Ditto.
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.
These should be there for the test to function.
But instead of doing the 12.0.x technique of duplicating these into src/test/resources
and having to keep them in sync, it just made more sense to reference the actual XML files directly instead.
jetty.addConfiguration(MavenPaths.projectBase().resolve("src/main/config/etc/jetty-deployment-manager.xml")); | ||
jetty.addConfiguration(MavenPaths.projectBase().resolve("src/main/config/etc/jetty-deploy.xml")); |
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.
Ditto.
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.
These should be there for the test to function.
But instead of doing the 12.0.x technique of duplicating these into src/test/resources
and having to keep them in sync, it just made more sense to reference the actual XML files directly instead.
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/Deployable.java
Outdated
Show resolved
Hide resolved
jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/WebAppContext.java
Outdated
Show resolved
Hide resolved
tmp.stringPropertyNames().forEach(k -> properties.put(k, tmp.getProperty(k))); | ||
} | ||
} | ||
context = contextClass.getDeclaredConstructor().newInstance(); |
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.
Constructor should be public
, so use:
context = contextClass.getDeclaredConstructor().newInstance(); | |
context = contextClass.getConstructor().newInstance(); |
I'd also simplify this if/else
by removing the else
:
if (contextClass == null)
throw ...;
context = contextClass.getConstructor().newInstance();
// check if there is a specific ContextHandler type to create set in the | ||
// properties associated with the webapp. If there is, we create it _before_ | ||
// applying the environment xml file. | ||
String contextHandlerClassName = (String)appAttributes.getAttribute(Deployable.CONTEXT_HANDLER_CLASS); |
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.
It is strange that the ContextHandler
is created here, but also down below with the default class.
However, for the default case, the webapp properties are not associated -- does not feel right.
Feels more it should have been:
String contextHandlerClassName = (String)appAttributes.getAttribute(Deployable.CONTEXT_HANDLER_CLASS);
if (contextHandlerClassName == null)
contextHandlerClassName = (String)appAttributes.getAttribute(Deployable.CONTEXT_HANDLER_CLASS_DEFAULT);
...
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.
Let me try to explain why this code is the way it is on jetty-12.0.x
first ...
There is an order of events that we have to deal with.
An App can have a custom ContextHandlerClass.
The XML is then applied to this instance.
If there is no app specific custom ContextHandlerClass, then the XML declared one is used.
The other custom context load below is for when there is no XML deployable, which uses the one from the environment.
Now, with this PR, I think this distinction is no longer relevant.
As the call earlier to Attributes appAttributes = initAttributes(environment, app);
will already handle the app specified custom defined property overriding the environment defined property.
By the time the first Load class/new Instance occurs, the app vs environment property decision is already made.
The only thing relevant is that the instance is created before the XMLs are applied (if there are XMLs).
I'm not sure the second Load class / new instance is relevant any longer.
I'll dig into this.
jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-deploy/src/main/config/etc/jetty-deployment-manager.xml
Show resolved
Hide resolved
I'd like to see:
|
* @param name the name of the environment. | ||
* @return the deployment configuration for the {@link Environment}. | ||
*/ | ||
public EnvironmentConfig configureEnvironment(String name) |
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.
This is strange, as calling this method returns a different object every time, so calling it twice make unclear whether the previous configuration was retained or not.
Since EnvironmentConfig
is just a wrapper around Environment
properties (to give compile-time checks), it should be stored as a property itself in the Environment
.
This method should be renamed getDeploymentConfiguration(String name)
, and it is not really an EnvironmentConfig
, it is the DeploymentConfiguration
for that specific environment.
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.
Since all it does is set/get Environment attributes, having multiple objects isn't going to change anything on the behavior.
In the future, we can change this to be the same EnvironmentConfig object if needed, but this level of change is not required for success in this PR.
One thing to point out in this solution is that it relies on the This means it won't be possible to have 2 Not really a problem of this PR, because the real issue would is the |
@sbordet said:
Can you explain? The |
@sbordet said:
@joakime I think this is an important feature to add at this stage as it will probably need some restructuring. Two approaches that I can see:
|
...-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ScanningAppProvider.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/providers/ContextProvider.java
Show resolved
Hide resolved
I implemented this with the BulkListener approach in commit 5f6d504 |
List<Path> sortedPaths = paths.stream() | ||
.sorted(PathCollators.byName(true)) | ||
.toList(); | ||
|
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 was thinking that at this stage it would be best to resolve xml vs war paths, as you can see all the paths at once.
If there is a foo.xml and/or a foo.war in the original list, then the end result should just be foo.xml to be deployed
A single scanner for all Environments.
Environment attributes are how the environment specific deployment configuration is controlled.
Existing properties behaviors maintained.
Currently a WIP (needs more testing and documentation)