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

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

public final class LazyProcessorDecorator
extends AbstractDecorator<LazyInitializer<ResourcePreProcessor>>
implements ResourcePreProcessor, ResourcePostProcessor, SupportedResourceTypeAware, MinimizeAware, SupportAware, ImportAware

Decorates a LazyInitializer which creates a processor. Allows defer the initialization of the decorated processor, making it unnecessary dependency unless it is really used.

Since:
1.4.6
Author:
Alex Objelean

Constructor Summary
LazyProcessorDecorator(LazyInitializer<ResourcePreProcessor> processor)
           
 
Method Summary
 SupportedResourceType getSupportedResourceType()
          
 boolean isImportAware()
          
 boolean isMinimize()
          
 boolean isSupported()
          
 void process(Reader reader, Writer writer)
          Perform actual resource processing.
 void process(Resource resource, Reader reader, Writer writer)
          Process a content supplied by a reader and perform some sort of processing.
 String toString()
          
 
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

LazyProcessorDecorator

public LazyProcessorDecorator(LazyInitializer<ResourcePreProcessor> processor)
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
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.

process

public void process(Reader reader,
                    Writer writer)
             throws IOException
Perform actual resource processing. The content to be processed is read from source Reader and is written to destination Writer. It is the client responsibility to close both: Reader and writer.

Specified by:
process in interface ResourcePostProcessor
Parameters:
reader - source stream.
writer - destination stream.
Throws:
IOException

getSupportedResourceType

public SupportedResourceType getSupportedResourceType()

Specified by:
getSupportedResourceType in interface SupportedResourceTypeAware
Returns:
SupportedResourceType to be used by processor.

isMinimize

public boolean isMinimize()

Specified by:
isMinimize in interface MinimizeAware
Returns:
true if the processor implementing this method performs some kind of minification.

isSupported

public boolean isSupported()

Specified by:
isSupported in interface SupportAware
Returns:
true if the implementor of this interface is supported.

isImportAware

public boolean isImportAware()

Specified by:
isImportAware in interface ImportAware
Returns:
flag indicating if the implementor of this interface should process also imported (referred by @import directive) resources.

toString

public String toString()
Description copied from class: AbstractDecorator

Overrides:
toString in class AbstractDecorator<LazyInitializer<ResourcePreProcessor>>


Copyright © 2008-2013. All Rights Reserved.