workspace master and agent : avoid scan of classes at runtime in order to find DynaModules #6922
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Today, ws-che-master and ws-che-agent are deployed using war files. In order to have extensibility, we can apply a
@DynaModule
annotation on guice class modules. Then, at runtime, Servlet container(Tomcat) is scanning the jar files to find the@DynaModule
classes and then call theorg.eclipse.che.inject.ModuleScanner
class by callingonStartup
methodWhen Che is initialized, it calls
CheBootStrap
class that ask the modules found by the scanner by callingmodules.addAll(ModuleScanner.findModules());
The issue is that we've a lot of scanning operations (performed by SCI (ServletContainerInitializer) .
Following https://wiki.apache.org/tomcat/HowTo/FasterStartUp if we disable all JAR scanning operations we lost the ability to use
DynaModule
which is not good.The idea is then to still disable scanning at runtime but keep using DynaModule.
By writing a plugin that could scan all
@DynaModule
when generating the war file, we could avoid the scan at runtime and then keep the ability to use `@DynaModule``This PR introduces this plugin and the use of this plugin inside ws-master and ws-agent.
On the agent, we should also add
<absolute-ordering />
element but it will break archetypes/custom assemblies.How is it working ?
The DynaModule plugin scan all the classes (there is a way to skip some jars that we're sure doesn't contain any
@DynaModule
annotations) and generate a class that provides agetModules()
method returning all DynaModule modules.This class is then loaded at runtime and CheBootstrap can load these modules, avoiding the use of scanning classes at runtime.
Details
process-classes
lifecycle (based on maven lifecycle : process-classes | post-process the generated files from compilation, for example to do bytecode enhancement on Java classes)then CheBootStrap is able to find all DynaModule modules.
the flow being:
CheBootStrap --> ModuleScanner.getModules() --> ServiceLoader --> GeneratedClass.getModules()
What issues does this PR fix or reference?
#6169
Changelog
workspace master and agent : avoid scan of classes at runtime in order to find DynaModules
Release Notes
N/A
Docs PR
N/A