public class PlumberImpl extends Object implements Plumber, org.apache.sling.event.jobs.consumer.JobConsumer, PlumberMXBean
Modifier and Type | Class and Description |
---|---|
static interface |
PlumberImpl.Configuration |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
protected org.apache.sling.distribution.Distributor |
distributor |
protected static String |
MBEAN_NAME_FORMAT |
protected static String |
MONITORED_PIPES_QUERY |
protected static String |
PN_MONITORED |
static String |
SLING_EVENT_TOPIC |
RESOURCE_TYPE
Constructor and Description |
---|
PlumberImpl() |
Modifier and Type | Method and Description |
---|---|
void |
activate(PlumberImpl.Configuration configuration) |
protected void |
checkError(Pipe pipe,
ExecutionResult result)
check if current state contains error, and record it
|
void |
deactivate() |
ExecutionResult |
execute(org.apache.sling.api.resource.ResourceResolver resolver,
Pipe pipe,
Map additionalBindings,
OutputWriter writer,
boolean save)
Executes a given pipe
|
ExecutionResult |
execute(org.apache.sling.api.resource.ResourceResolver resolver,
String path,
Map additionalBindings,
OutputWriter writer,
boolean save)
Executes a pipe at a certain path
|
org.apache.sling.event.jobs.Job |
executeAsync(org.apache.sling.api.resource.ResourceResolver resolver,
String path,
Map bindings)
executes in a background thread
|
org.apache.sling.event.jobs.Job |
executeAsync(String path,
Map bindings)
executes in a background thread
|
protected Collection<PipeMonitor> |
getMonitoredPipes() |
Pipe |
getPipe(org.apache.sling.api.resource.Resource resource)
Instantiate a pipe from the given resource and returns it
|
Pipe |
getPipe(org.apache.sling.api.resource.Resource resource,
PipeBindings upperBindings)
Instantiate a pipe from the given resource and returns it
|
Map |
getServiceUser() |
String |
getStatus(org.apache.sling.api.resource.Resource pipeResource)
status of the pipe
|
boolean |
isRunning(org.apache.sling.api.resource.Resource pipeResource)
returns true if the pipe is considered to be running
|
boolean |
isTypeRegistered(String type)
returns wether or not a pipe type is registered
|
PipeBuilder |
newPipe(org.apache.sling.api.resource.ResourceResolver resolver)
Provides a builder helping quickly build and execute a pipe
|
protected void |
persist(org.apache.sling.api.resource.ResourceResolver resolver,
Pipe pipe,
ExecutionResult result,
org.apache.sling.api.resource.Resource currentResource)
Persists pipe change if big enough, or ended, and eventually distribute changes
|
org.apache.sling.event.jobs.consumer.JobConsumer.JobResult |
process(org.apache.sling.event.jobs.Job job) |
void |
refreshMonitoredPipes() |
void |
registerPipe(String type,
Class<? extends BasePipe> pipeClass)
Registers
|
protected void |
registerPipes()
Register all pipes declared in pipe builder
|
protected void |
writeStatus(Pipe pipe,
String status)
writes the status of the pipe, also update
PN_STATUS_MODIFIED date |
public static final int DEFAULT_BUFFER_SIZE
protected static final String PN_MONITORED
protected static final String MONITORED_PIPES_QUERY
protected static final String MBEAN_NAME_FORMAT
public static final String SLING_EVENT_TOPIC
protected volatile org.apache.sling.distribution.Distributor distributor
public void activate(PlumberImpl.Configuration configuration)
protected void registerPipes()
public Map getServiceUser()
getServiceUser
in interface Plumber
public void deactivate()
public Pipe getPipe(org.apache.sling.api.resource.Resource resource)
Plumber
public Pipe getPipe(org.apache.sling.api.resource.Resource resource, PipeBindings upperBindings)
Plumber
public org.apache.sling.event.jobs.Job executeAsync(org.apache.sling.api.resource.ResourceResolver resolver, String path, Map bindings)
Plumber
executeAsync
in interface Plumber
resolver
- resolver used for registering the execution (id will be checked against the configuration)path
- path of the pipe to executebindings
- additional bindings to use when executingpublic org.apache.sling.event.jobs.Job executeAsync(String path, Map bindings)
Plumber
executeAsync
in interface Plumber
path
- path of the pipe to executebindings
- additional bindings to use when executingpublic ExecutionResult execute(org.apache.sling.api.resource.ResourceResolver resolver, String path, Map additionalBindings, OutputWriter writer, boolean save) throws Exception
Plumber
execute
in interface Plumber
resolver
- resource resolver with which pipe will be executedpath
- path of a valid pipe configurationadditionalBindings
- bindings to add to the execution of the pipe, can be nullwriter
- output of the pipesave
- in case that pipe writes anything, wether the plumber should save changes or notExecutionResult
Exception
- in case execution failspublic ExecutionResult execute(org.apache.sling.api.resource.ResourceResolver resolver, Pipe pipe, Map additionalBindings, OutputWriter writer, boolean save) throws Exception
Plumber
execute
in interface Plumber
resolver
- resource resolver with which pipe will be executedpipe
- pipe to executeadditionalBindings
- bindings to add to the execution of the pipe, can be nullwriter
- output of the pipesave
- in case that pipe writes anything, wether the plumber should save changes or notExecutionResult
Exception
- in case execution failsprotected void checkError(Pipe pipe, ExecutionResult result)
pipe
- current piperesult
- current resultprotected void persist(org.apache.sling.api.resource.ResourceResolver resolver, Pipe pipe, ExecutionResult result, org.apache.sling.api.resource.Resource currentResource) throws Exception
resolver
- resolver to usepipe
- pipe at the origin of the changes,result
- execution result object,currentResource
- if running, null if endedorg.apache.sling.api.resource.PersistenceException
- in case save failsException
public void registerPipe(String type, Class<? extends BasePipe> pipeClass)
Plumber
registerPipe
in interface Plumber
type
- resource type of the pipe to registerpipeClass
- class of the pipe to registerpublic boolean isTypeRegistered(String type)
Plumber
isTypeRegistered
in interface Plumber
type
- resource type testedprotected void writeStatus(Pipe pipe, String status) throws javax.jcr.RepositoryException
PN_STATUS_MODIFIED
datepipe
- target pipestatus
- status to writejavax.jcr.RepositoryException
- in case write goes wrongpublic String getStatus(org.apache.sling.api.resource.Resource pipeResource)
Plumber
public PipeBuilder newPipe(org.apache.sling.api.resource.ResourceResolver resolver)
Plumber
public boolean isRunning(org.apache.sling.api.resource.Resource pipeResource)
Plumber
public org.apache.sling.event.jobs.consumer.JobConsumer.JobResult process(org.apache.sling.event.jobs.Job job)
process
in interface org.apache.sling.event.jobs.consumer.JobConsumer
public void refreshMonitoredPipes()
refreshMonitoredPipes
in interface PlumberMXBean
protected Collection<PipeMonitor> getMonitoredPipes()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.