use of org.apache.sling.rewriter.Processor in project sling by apache.
the class RewriterResponse method getProcessor.
/**
* Search the first matching processor
*/
private Processor getProcessor() {
final ProcessingContext processorContext = new ServletProcessingContext(this.request, this, this.getSlingResponse(), this.contentType);
Processor found = null;
final List<ProcessorConfiguration> processorConfigs = this.processorManager.getProcessorConfigurations();
final Iterator<ProcessorConfiguration> i = processorConfigs.iterator();
while (found == null && i.hasNext()) {
final ProcessorConfiguration config = i.next();
if (config.match(processorContext)) {
try {
found = this.processorManager.getProcessor(config, processorContext);
this.request.getRequestProgressTracker().log("Found processor for post processing {0}", config);
} catch (final SlingException se) {
// already processing an error, we ignore this!
if (processorContext.getRequest().getAttribute("javax.servlet.error.status_code") != null) {
this.request.getRequestProgressTracker().log("Ignoring found processor for post processing {0}" + " as an error occured ({1}) during setup while processing another error.", config, se);
} else {
throw se;
}
}
}
}
return found;
}
use of org.apache.sling.rewriter.Processor in project sling by apache.
the class ProcessorManagerImpl method getProcessor.
/**
* @see org.apache.sling.rewriter.ProcessorManager#getProcessor(org.apache.sling.rewriter.ProcessorConfiguration, org.apache.sling.rewriter.ProcessingContext)
*/
@Override
public Processor getProcessor(ProcessorConfiguration configuration, ProcessingContext context) {
if (configuration == null) {
throw new IllegalArgumentException("Processor configuration is missing.");
}
if (context == null) {
throw new IllegalArgumentException("Processor context is missing.");
}
boolean isPipeline = false;
if (configuration instanceof ProcessorConfigurationImpl) {
isPipeline = ((ProcessorConfigurationImpl) configuration).isPipeline();
} else {
isPipeline = configuration instanceof PipelineConfiguration;
}
try {
if (isPipeline) {
final PipelineImpl pipeline = new PipelineImpl(this.factoryCache);
pipeline.init(context, configuration);
return pipeline;
}
final Processor processor = new ProcessorWrapper(configuration, this.factoryCache);
processor.init(context, configuration);
return processor;
} catch (final IOException ioe) {
throw new SlingException("Unable to setup processor: " + ioe.getMessage(), ioe);
}
}
Aggregations