ro.isdc.wro.manager
Class WroManager

java.lang.Object
  extended by ro.isdc.wro.manager.WroManager
All Implemented Interfaces:
WroConfigurationChangeListener, CacheChangeCallbackAware

public class WroManager
extends Object
implements WroConfigurationChangeListener, CacheChangeCallbackAware

Contains all the factories used by optimizer in order to perform the logic.

Author:
Alex Objelean

Constructor Summary
WroManager()
           
 
Method Summary
 void destroy()
          Called when WroManager is being taken out of service.
 String encodeVersionIntoGroupPath(String groupName, ResourceType resourceType, boolean minimize)
          Encodes a fingerprint of the resource into the path.
protected  String formatVersionedResource(String hash, String resourcePath)
          Format the version of the resource in the path.
 CacheStrategy<CacheEntry,ContentHashEntry> getCacheStrategy()
           
 WroModelFactory getModelFactory()
           
 NamingStrategy getNamingStrategy()
           
 ProcessorsFactory getProcessorsFactory()
           
 UriLocatorFactory getUriLocatorFactory()
           
 void onCachePeriodChanged(long period)
          Invoked when the cachePeriod property is changed.
 void onModelPeriodChanged(long period)
          Invoked when the modelPeriod property is changed.
 void process()
          Perform processing of the uri.
 void registerCallback(PropertyChangeListener callback)
          
 WroManager setCacheStrategy(CacheStrategy<CacheEntry,ContentHashEntry> cacheStrategy)
           
 WroManager setGroupExtractor(GroupExtractor groupExtractor)
           
 WroManager setHashBuilder(HashBuilder contentDigester)
           
 WroManager setModelFactory(WroModelFactory modelFactory)
           
 WroManager setNamingStrategy(NamingStrategy namingStrategy)
           
 WroManager setProcessorsFactory(ProcessorsFactory processorsFactory)
           
 WroManager setUriLocatorFactory(UriLocatorFactory uriLocatorFactory)
           
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WroManager

public WroManager()
Method Detail

process

public final void process()
                   throws IOException
Perform processing of the uri.

Parameters:
request - HttpServletRequest to process.
response - HttpServletResponse where to write the result content.
Throws:
IOException - when any IO related problem occurs or if the request cannot be processed.

encodeVersionIntoGroupPath

public final String encodeVersionIntoGroupPath(String groupName,
                                               ResourceType resourceType,
                                               boolean minimize)
Encodes a fingerprint of the resource into the path. The result may look like this: ${fingerprint}/myGroup.js

Returns:
a path to the resource with the fingerprint encoded as a folder name.

formatVersionedResource

protected String formatVersionedResource(String hash,
                                         String resourcePath)
Format the version of the resource in the path. Default implementation use hash as a folder: /groupName.js. The implementation can be changed to follow a different versioning style, like version parameter: /groupName.js?version=

Parameters:
hash - Hash of the resource.
resourcePath - Path of the resource.
Returns:
formatted versioned path of the resource.

onCachePeriodChanged

public final void onCachePeriodChanged(long period)
Invoked when the cachePeriod property is changed.

Specified by:
onCachePeriodChanged in interface WroConfigurationChangeListener

onModelPeriodChanged

public final void onModelPeriodChanged(long period)
Invoked when the modelPeriod property is changed.

Specified by:
onModelPeriodChanged in interface WroConfigurationChangeListener

destroy

public final void destroy()
Called when WroManager is being taken out of service.


registerCallback

public final void registerCallback(PropertyChangeListener callback)

Specified by:
registerCallback in interface CacheChangeCallbackAware
Parameters:
callback - to invoke when the cache is changed.

setGroupExtractor

public final WroManager setGroupExtractor(GroupExtractor groupExtractor)
Parameters:
groupExtractor - the uriProcessor to set

setModelFactory

public final WroManager setModelFactory(WroModelFactory modelFactory)
Parameters:
modelFactory - the modelFactory to set

setCacheStrategy

public final WroManager setCacheStrategy(CacheStrategy<CacheEntry,ContentHashEntry> cacheStrategy)
Parameters:
cacheStrategy - the cache to set

setHashBuilder

public WroManager setHashBuilder(HashBuilder contentDigester)
Parameters:
contentDigester - the contentDigester to set

getModelFactory

public WroModelFactory getModelFactory()
Returns:
the modelFactory

getProcessorsFactory

public ProcessorsFactory getProcessorsFactory()
Returns:
the processorsFactory used by this WroManager.

setProcessorsFactory

public WroManager setProcessorsFactory(ProcessorsFactory processorsFactory)
Parameters:
processorsFactory - the processorsFactory to set

setUriLocatorFactory

public WroManager setUriLocatorFactory(UriLocatorFactory uriLocatorFactory)
Parameters:
uriLocatorFactory - the uriLocatorFactory to set

getCacheStrategy

public CacheStrategy<CacheEntry,ContentHashEntry> getCacheStrategy()
Returns:
the cacheStrategy

getUriLocatorFactory

public UriLocatorFactory getUriLocatorFactory()
Returns:
the uriLocatorFactory

getNamingStrategy

public final NamingStrategy getNamingStrategy()
Returns:
The strategy used to rename bundled resources.

setNamingStrategy

public final WroManager setNamingStrategy(NamingStrategy namingStrategy)
Parameters:
namingStrategy - the namingStrategy to set

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2008-2011. All Rights Reserved.