ro.isdc.wro.model.resource.processor.decorator
Class DefaultProcessorDecorator

java.lang.Object
  extended by ro.isdc.wro.util.AbstractDecorator<T>
      extended by ro.isdc.wro.model.resource.processor.decorator.AbstractProcessorDecoratorSupport<ResourcePreProcessor>
          extended by ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator
              extended by ro.isdc.wro.model.resource.processor.decorator.DefaultProcessorDecorator
All Implemented Interfaces:
ImportAware, MinimizeAware, ResourcePostProcessor, ResourcePreProcessor, SupportAware, SupportedResourceTypeAware, ObjectDecorator<ResourcePreProcessor>

public class DefaultProcessorDecorator
extends ProcessorDecorator

Decorates the processor with a set of common useful decorators during each processing.

Since:
1.6.0
Author:
Alex Objelean

Constructor Summary
DefaultProcessorDecorator(Object processor, boolean minimize)
           
DefaultProcessorDecorator(Object processor, ProcessingCriteria criteria)
           
 
Method Summary
protected  boolean isEnabled(Resource resource)
          
 void process(Resource resource, Reader reader, Writer writer)
          Process a content supplied by a reader and perform some sort of processing.
 
Methods inherited from class ro.isdc.wro.model.resource.processor.decorator.ProcessorDecorator
isEligible, toString
 
Methods inherited from class ro.isdc.wro.model.resource.processor.decorator.AbstractProcessorDecoratorSupport
getSupportedResourceType, getSupportedResourceTypeInternal, getSupportedResourceTypes, isImportAware, isMinimize, isMinimizeInternal, isSupported, process
 
Methods inherited from class ro.isdc.wro.util.AbstractDecorator
getDecoratedObject, getOriginalDecoratedObject, getOriginalDecoratedObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultProcessorDecorator

public DefaultProcessorDecorator(Object processor,
                                 boolean minimize)

DefaultProcessorDecorator

public DefaultProcessorDecorator(Object processor,
                                 ProcessingCriteria criteria)
Method Detail

process

public void process(Resource resource,
                    Reader reader,
                    Writer writer)
             throws IOException
Process a content supplied by a reader and perform some sort of processing. It is important to know that you should use reader for processing instead of trying to access the resource original content using Resource, because this way you can ignore the other preProcessors from the chain.
It is not require to explicitly handle exception. When the processing fails, the following can happen:
It is not required to close the reader and writers, because these will be closed for you.

Specified by:
process in interface ResourcePreProcessor
Overrides:
process in class ProcessorDecorator
Parameters:
resource - the original resource as it found in the model.
reader - Reader used to read processed resource content.
writer - Writer where used to write processed results.
Throws:
IOException - when an exception occurs. The future version will change the exception type to Exception, because any exception may occur during processing. The processing failure will be handled based on value of WroConfiguration.isIgnoreFailingProcessor() configuration flag.

isEnabled

protected boolean isEnabled(Resource resource)

Overrides:
isEnabled in class ProcessorDecorator
Parameters:
resource - ResourcePreProcessor for which enabled flag should be checked.
Returns:
a flag indicating if this processor is enabled. When false, the processing will be skipped and the content will be left unchanged. This value is true by default.


Copyright © 2008-2013. All Rights Reserved.