Class AbstractJobExecutor<Result>
- java.lang.Object
-
- com.composum.sling.core.concurrent.AbstractJobExecutor<Result>
-
- All Implemented Interfaces:
org.apache.sling.event.jobs.consumer.JobExecutor
,org.osgi.service.event.EventHandler
- Direct Known Subclasses:
GroovyJobExecutor
,PackageJobExecutor
public abstract class AbstractJobExecutor<Result> extends Object implements org.apache.sling.event.jobs.consumer.JobExecutor, org.osgi.service.event.EventHandler
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractJobExecutor.UserContextCallable
-
Field Summary
Fields Modifier and Type Field Description static String
AUDIT_ROOT_PATH
static Map<String,Object>
CRUD_AUDIT_FOLDER_PROPS
static String
JOB_OUTFILE_PROPERTY
static String
JOB_REFRENCE_PROPERTY
static String
JOB_USERID_PROPERTY
-
Constructor Summary
Constructors Constructor Description AbstractJobExecutor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
buildAuditPathIntern(String reference, Calendar eventJobStartedTime)
protected abstract Callable<Result>
createCallable(org.apache.sling.event.jobs.Job job, org.apache.sling.event.jobs.consumer.JobExecutionContext context, org.apache.sling.api.resource.ResourceResolver adminResolver, PrintWriter out)
The Callable does the job which is prepared by the executor.protected abstract String
getAuditBasePath()
protected abstract @NotNull org.apache.sling.commons.classloader.DynamicClassLoaderManager
getDynamicClassLoaderManager()
protected abstract String
getJobTopic()
protected <T> T
getProperty(org.apache.sling.event.jobs.Job job, String name, T defaultValue)
protected abstract @NotNull org.apache.sling.api.resource.ResourceResolverFactory
getResolverFactory()
protected abstract @NotNull SequencerService<SequencerService.Token>
getSequencer()
void
handleEvent(org.osgi.service.event.Event event)
protected abstract boolean
jobExecutionEnabled(org.apache.sling.event.jobs.Job job)
protected void
jobExecutionFinished(org.apache.sling.event.jobs.Job job, org.apache.sling.event.jobs.consumer.JobExecutionContext context, org.apache.sling.api.resource.Resource auditResource)
Can be overwritten to handle some cleanup or logging when job is finished.org.apache.sling.event.jobs.consumer.JobExecutionResult
process(org.apache.sling.event.jobs.Job job, org.apache.sling.event.jobs.consumer.JobExecutionContext context)
-
-
-
Field Detail
-
JOB_REFRENCE_PROPERTY
public static final String JOB_REFRENCE_PROPERTY
- See Also:
- Constant Field Values
-
JOB_OUTFILE_PROPERTY
public static final String JOB_OUTFILE_PROPERTY
- See Also:
- Constant Field Values
-
JOB_USERID_PROPERTY
public static final String JOB_USERID_PROPERTY
- See Also:
- Constant Field Values
-
AUDIT_ROOT_PATH
public static final String AUDIT_ROOT_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getResolverFactory
@NotNull protected abstract @NotNull org.apache.sling.api.resource.ResourceResolverFactory getResolverFactory()
-
getSequencer
@NotNull protected abstract @NotNull SequencerService<SequencerService.Token> getSequencer()
-
getDynamicClassLoaderManager
@NotNull protected abstract @NotNull org.apache.sling.commons.classloader.DynamicClassLoaderManager getDynamicClassLoaderManager()
-
getJobTopic
protected abstract String getJobTopic()
-
getAuditBasePath
protected abstract String getAuditBasePath()
-
jobExecutionEnabled
protected abstract boolean jobExecutionEnabled(org.apache.sling.event.jobs.Job job)
-
createCallable
protected abstract Callable<Result> createCallable(org.apache.sling.event.jobs.Job job, org.apache.sling.event.jobs.consumer.JobExecutionContext context, org.apache.sling.api.resource.ResourceResolver adminResolver, PrintWriter out) throws Exception
The Callable does the job which is prepared by the executor.- Throws:
Exception
-
process
public final org.apache.sling.event.jobs.consumer.JobExecutionResult process(org.apache.sling.event.jobs.Job job, org.apache.sling.event.jobs.consumer.JobExecutionContext context)
- Specified by:
process
in interfaceorg.apache.sling.event.jobs.consumer.JobExecutor
-
jobExecutionFinished
protected void jobExecutionFinished(org.apache.sling.event.jobs.Job job, org.apache.sling.event.jobs.consumer.JobExecutionContext context, org.apache.sling.api.resource.Resource auditResource) throws IOException
Can be overwritten to handle some cleanup or logging when job is finished.- Throws:
IOException
-
buildAuditPathIntern
protected String buildAuditPathIntern(String reference, Calendar eventJobStartedTime)
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event)
- Specified by:
handleEvent
in interfaceorg.osgi.service.event.EventHandler
-
getProperty
protected <T> T getProperty(org.apache.sling.event.jobs.Job job, String name, T defaultValue)
-
-