Fix (Core): Changed job manager initialization to the InitServlet and processors discovery using CDI #30898
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.
This pull request introduces several changes to improve the discovery and registration of
JobProcessor
implementations using CDI (Contexts and Dependency Injection).The key changes include the addition of a new class for discovering job processors, modifications to the job processor factory to utilize CDI, and updates to the job queue manager to register discovered processors automatically also, the initialization of the Job Manager it is now done in the InitServlet.
Improvements to Job Processor Discovery and Registration:
dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorDiscovery.java
: Introduced a new classJobProcessorDiscovery
to discover all classes implementing theJobProcessor
interface using CDI. This class includes methods to validate the scope of beans and handle errors during discovery.dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorFactory.java
: Modified theJobProcessorFactory
to first attempt to get the processor from the CDI context and fall back to direct instantiation if that fails. This change ensures that job processors are created using CDI when possible.dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java
: Updated theJobQueueManagerAPIImpl
class to include aJobProcessorDiscovery
instance and register discovered processors automatically during initialization. Added methods to register job processors with and without specifying a queue name. [1] [2] [3] [4]Removal of Deprecated Scanner:
dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorScanner.java
: Removed theJobProcessorScanner
class, which used Jandex to scan for job processors. This functionality is now replaced by the newJobProcessorDiscovery
class.Updates to Job Processor Implementations:
@Dependent
scope to various job processor implementations to ensure they are correctly managed by CDI:FailSuccessJob
ImportContentletsProcessor
[1] [2]LargeFileReader
These changes enhance the flexibility and reliability of job processor discovery and instantiation in the system, leveraging CDI to manage dependencies and lifecycle.
This PR fixes: #30545