-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81172fc
commit 149c9ef
Showing
7 changed files
with
284 additions
and
187 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
dotCMS/src/main/java/com/dotcms/jobs/business/api/JobProcessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.dotcms.jobs.business.api; | ||
|
||
import com.dotcms.jobs.business.error.JobProcessorInstantiationException; | ||
import com.dotcms.jobs.business.processor.JobProcessor; | ||
import com.dotmarketing.util.Logger; | ||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
@ApplicationScoped | ||
public class JobProcessorFactory { | ||
|
||
public JobProcessorFactory() { | ||
// Default constructor for CDI | ||
} | ||
|
||
/** | ||
* Creates a new instance of the specified job processor class. | ||
* | ||
* @param processorClass The class of the job processor to create. | ||
* @return An optional containing the new job processor instance, or an empty optional if the | ||
* processor could not be created. | ||
*/ | ||
JobProcessor newInstance( | ||
Class<? extends JobProcessor> processorClass) { | ||
try { | ||
return processorClass.getDeclaredConstructor().newInstance(); | ||
} catch (Exception e) { | ||
Logger.error(this, "Error creating job processor", e); | ||
throw new JobProcessorInstantiationException(processorClass, e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.