org.apache.wicket.settings.def
Class ResourceSettings

java.lang.Object
  extended by org.apache.wicket.settings.def.ResourceSettings
All Implemented Interfaces:
IPropertiesFactoryContext, IResourceSettings

public class ResourceSettings
extends java.lang.Object
implements IResourceSettings

Author:
Jonathan Locke, Chris Turner, Eelco Hillenius, Juergen Donnerstag, Johan Compagner, Igor Vaynberg (ivaynberg), Martijn Dashorst, James Carman

Constructor Summary
ResourceSettings(Application application)
          Construct
 
Method Summary
 void addResourceFactory(java.lang.String name, IResourceFactory resourceFactory)
          Adds a resource factory to the list of factories to consult when generating resources automatically
 void addResourceFolder(java.lang.String resourceFolder)
          Convenience method that sets the resource search path to a single folder.
 IResourceCachingStrategy getCachingStrategy()
          gets the resource caching strategy
 ICssCompressor getCssCompressor()
          Get the CSS compressor to remove comments and whitespace characters from css resources
 Duration getDefaultCacheDuration()
          Get the the default cache duration for resources.
 IFileCleaner getFileCleaner()
           
 IJavaScriptCompressor getJavaScriptCompressor()
          Get the javascript compressor to remove comments and whitespace characters from javascripts
 Localizer getLocalizer()
          Get the application's localizer.
 IPackageResourceGuard getPackageResourceGuard()
          Gets the package resource guard.
 java.lang.String getParentFolderPlaceholder()
          Placeholder string for '..' within resource urls (which will be crippled by the browser and not work anymore).
 IPropertiesFactory getPropertiesFactory()
          Get the property factory which will be used to load property files
 IResourceFactory getResourceFactory(java.lang.String name)
           
 IResourceFinder getResourceFinder()
          Gets the resource finder to use when searching for resources.
 Duration getResourcePollFrequency()
           
 IResourceStreamLocator getResourceStreamLocator()
           
 IModificationWatcher getResourceWatcher(boolean start)
           
 java.util.List<IStringResourceLoader> getStringResourceLoaders()
           
 boolean getThrowExceptionOnMissingResource()
           
 boolean getUseDefaultOnMissingResource()
           
 void setCachingStrategy(IResourceCachingStrategy strategy)
          sets the resource caching strategy
 ICssCompressor setCssCompressor(ICssCompressor compressor)
          Set the CSS compressor implemententation use e.g.
 void setDefaultCacheDuration(Duration duration)
          Set the the default cache duration for resources.
 void setFileCleaner(IFileCleaner fileUploadCleaner)
          Sets a cleaner that can be used to remove files asynchronously.
 IJavaScriptCompressor setJavaScriptCompressor(IJavaScriptCompressor compressor)
          Set the javascript compressor implemententation use e.g.
 void setLocalizer(Localizer localizer)
          Sets the localizer which will be used to find property values.
 void setPackageResourceGuard(IPackageResourceGuard packageResourceGuard)
          Sets the package resource guard.
 void setParentFolderPlaceholder(java.lang.String sequence)
          Placeholder string for '..' within resource urls (which will be crippled by the browser and not work anymore).
 void setPropertiesFactory(IPropertiesFactory factory)
          Set the property factory which will be used to load property files
 void setResourceFinder(IResourceFinder resourceFinder)
          Sets the finder to use when searching for resources.
 void setResourcePollFrequency(Duration resourcePollFrequency)
          Sets the resource polling frequency.
 void setResourceStreamLocator(IResourceStreamLocator resourceStreamLocator)
          Sets the resource stream locator for this application
 void setResourceWatcher(IModificationWatcher watcher)
          Sets the resource watcher
 void setThrowExceptionOnMissingResource(boolean throwExceptionOnMissingResource)
           
 void setUseDefaultOnMissingResource(boolean useDefaultOnMissingResource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceSettings

public ResourceSettings(Application application)
Construct

Parameters:
application -
Method Detail

addResourceFactory

public void addResourceFactory(java.lang.String name,
                               IResourceFactory resourceFactory)
Description copied from interface: IResourceSettings
Adds a resource factory to the list of factories to consult when generating resources automatically

Specified by:
addResourceFactory in interface IResourceSettings
Parameters:
name - The name to give to the factory
resourceFactory - The resource factory to add
See Also:
IResourceSettings.addResourceFactory(java.lang.String, org.apache.wicket.IResourceFactory)

addResourceFolder

public void addResourceFolder(java.lang.String resourceFolder)
Description copied from interface: IResourceSettings
Convenience method that sets the resource search path to a single folder. use when searching for resources. By default, the resources are located on the classpath. If you want to configure other, additional, search paths, you can use this method

Specified by:
addResourceFolder in interface IResourceSettings
Parameters:
resourceFolder - The resourceFolder to set
See Also:
IResourceSettings.addResourceFolder(java.lang.String)

getLocalizer

public Localizer getLocalizer()
Description copied from interface: IPropertiesFactoryContext
Get the application's localizer. to modify the way Wicket resolves keys to localized messages you can add custom resource loaders to the list returned by IResourceSettings.getStringResourceLoaders().

Specified by:
getLocalizer in interface IPropertiesFactoryContext
Returns:
The application wide localizer instance
See Also:
IPropertiesFactoryContext.getLocalizer()

getPackageResourceGuard

public IPackageResourceGuard getPackageResourceGuard()
Description copied from interface: IResourceSettings
Gets the package resource guard.

Specified by:
getPackageResourceGuard in interface IResourceSettings
Returns:
The package resource guard
See Also:
IResourceSettings.getPackageResourceGuard()

getPropertiesFactory

public IPropertiesFactory getPropertiesFactory()
Description copied from interface: IResourceSettings
Get the property factory which will be used to load property files

Specified by:
getPropertiesFactory in interface IResourceSettings
Returns:
PropertiesFactory
See Also:
IResourceSettings.getPropertiesFactory()

getResourceFactory

public IResourceFactory getResourceFactory(java.lang.String name)
Specified by:
getResourceFactory in interface IResourceSettings
Parameters:
name - Name of the factory to get
Returns:
The IResourceFactory with the given name.
See Also:
IResourceSettings.getResourceFactory(java.lang.String)

getResourceFinder

public IResourceFinder getResourceFinder()
Description copied from interface: IResourceSettings
Gets the resource finder to use when searching for resources.

Specified by:
getResourceFinder in interface IResourceSettings
Returns:
Returns the resourceFinder.
See Also:
IResourceSettings.getResourceFinder()

getResourcePollFrequency

public Duration getResourcePollFrequency()
Specified by:
getResourcePollFrequency in interface IResourceSettings
Returns:
Returns the resourcePollFrequency.
See Also:
IResourceSettings.getResourcePollFrequency()

getResourceStreamLocator

public IResourceStreamLocator getResourceStreamLocator()
Specified by:
getResourceStreamLocator in interface IPropertiesFactoryContext
Returns:
Resource locator for this application
See Also:
IPropertiesFactoryContext.getResourceStreamLocator()

getResourceWatcher

public IModificationWatcher getResourceWatcher(boolean start)
Specified by:
getResourceWatcher in interface IPropertiesFactoryContext
Parameters:
start - boolean if the resource watcher should be started if not already started.
Returns:
Resource watcher with polling frequency determined by setting, or null if no polling frequency has been set.
See Also:
IPropertiesFactoryContext.getResourceWatcher(boolean)

setResourceWatcher

public void setResourceWatcher(IModificationWatcher watcher)
Description copied from interface: IResourceSettings
Sets the resource watcher

Specified by:
setResourceWatcher in interface IResourceSettings
See Also:
IResourceSettings.setResourceWatcher(org.apache.wicket.util.watch.IModificationWatcher)

getFileCleaner

public IFileCleaner getFileCleaner()
Specified by:
getFileCleaner in interface IResourceSettings
Returns:
the a cleaner which can be used to remove files asynchronously.

setFileCleaner

public void setFileCleaner(IFileCleaner fileUploadCleaner)
Description copied from interface: IResourceSettings
Sets a cleaner that can be used to remove files asynchronously.

Used internally to delete the temporary files created by FileUpload functionality

Specified by:
setFileCleaner in interface IResourceSettings
Parameters:
fileUploadCleaner - the actual cleaner implementation. Can be null

getStringResourceLoaders

public java.util.List<IStringResourceLoader> getStringResourceLoaders()
Specified by:
getStringResourceLoaders in interface IResourceSettings
Returns:
mutable list of all available string resource loaders
See Also:
IResourceSettings.getStringResourceLoaders()

getThrowExceptionOnMissingResource

public boolean getThrowExceptionOnMissingResource()
Specified by:
getThrowExceptionOnMissingResource in interface IResourceSettings
Returns:
boolean
See Also:
IResourceSettings.getThrowExceptionOnMissingResource()

getUseDefaultOnMissingResource

public boolean getUseDefaultOnMissingResource()
Specified by:
getUseDefaultOnMissingResource in interface IResourceSettings
Returns:
Whether to use a default value (if available) when a missing resource is requested
See Also:
IResourceSettings.getUseDefaultOnMissingResource()

setLocalizer

public void setLocalizer(Localizer localizer)
Description copied from interface: IResourceSettings
Sets the localizer which will be used to find property values.

Specified by:
setLocalizer in interface IResourceSettings
See Also:
IResourceSettings.setLocalizer(org.apache.wicket.Localizer)

setPackageResourceGuard

public void setPackageResourceGuard(IPackageResourceGuard packageResourceGuard)
Description copied from interface: IResourceSettings
Sets the package resource guard.

Specified by:
setPackageResourceGuard in interface IResourceSettings
Parameters:
packageResourceGuard - The package resource guard
See Also:
IResourceSettings.setPackageResourceGuard(org.apache.wicket.markup.html.IPackageResourceGuard)

setPropertiesFactory

public void setPropertiesFactory(IPropertiesFactory factory)
Description copied from interface: IResourceSettings
Set the property factory which will be used to load property files

Specified by:
setPropertiesFactory in interface IResourceSettings
See Also:
IResourceSettings.setPropertiesFactory(org.apache.wicket.resource.IPropertiesFactory)

setResourceFinder

public void setResourceFinder(IResourceFinder resourceFinder)
Description copied from interface: IResourceSettings
Sets the finder to use when searching for resources. By default, the resources are located on the classpath. If you want to configure other, additional, search paths, you can use this method.

Specified by:
setResourceFinder in interface IResourceSettings
Parameters:
resourceFinder - The resourceFinder to set
See Also:
IResourceSettings.setResourceFinder(org.apache.wicket.util.file.IResourceFinder)

setResourcePollFrequency

public void setResourcePollFrequency(Duration resourcePollFrequency)
Description copied from interface: IResourceSettings
Sets the resource polling frequency. This is the duration of time between checks of resource modification times. If a resource, such as an HTML file, has changed, it will be reloaded. The default is one second in 'development' mode and 'never' in deployment mode.

Specified by:
setResourcePollFrequency in interface IResourceSettings
Parameters:
resourcePollFrequency - Frequency at which to poll resources or null if polling should be disabled
See Also:
IResourceSettings.setResourcePollFrequency(org.apache.wicket.util.time.Duration)

setResourceStreamLocator

public void setResourceStreamLocator(IResourceStreamLocator resourceStreamLocator)
Sets the resource stream locator for this application Consider wrapping resourceStreamLocator in CachingResourceStreamLocator. This way the locator will not be asked more than once for IResourceStreams which do not exist.

Specified by:
setResourceStreamLocator in interface IResourceSettings
Parameters:
resourceStreamLocator - new resource stream locator
See Also:
getResourceStreamLocator()

setThrowExceptionOnMissingResource

public void setThrowExceptionOnMissingResource(boolean throwExceptionOnMissingResource)
Specified by:
setThrowExceptionOnMissingResource in interface IResourceSettings
See Also:
IResourceSettings.setThrowExceptionOnMissingResource(boolean)

setUseDefaultOnMissingResource

public void setUseDefaultOnMissingResource(boolean useDefaultOnMissingResource)
Specified by:
setUseDefaultOnMissingResource in interface IResourceSettings
Parameters:
useDefaultOnMissingResource - Whether to use a default value (if available) when a missing resource is requested
See Also:
IResourceSettings.setUseDefaultOnMissingResource(boolean)

getDefaultCacheDuration

public final Duration getDefaultCacheDuration()
Description copied from interface: IResourceSettings
Get the the default cache duration for resources.

Specified by:
getDefaultCacheDuration in interface IResourceSettings
Returns:
cache duration (Duration.NONE will be returned if caching is disabled)
See Also:
IResourceSettings.getDefaultCacheDuration()

setDefaultCacheDuration

public final void setDefaultCacheDuration(Duration duration)
Description copied from interface: IResourceSettings
Set the the default cache duration for resources.

Based on RFC-2616 this should not exceed one year. If you set Duration.NONE caching will be disabled.

Specified by:
setDefaultCacheDuration in interface IResourceSettings
Parameters:
duration - default cache duration in seconds
See Also:
IResourceSettings.setDefaultCacheDuration(org.apache.wicket.util.time.Duration)

getJavaScriptCompressor

public IJavaScriptCompressor getJavaScriptCompressor()
Description copied from interface: IResourceSettings
Get the javascript compressor to remove comments and whitespace characters from javascripts

Specified by:
getJavaScriptCompressor in interface IResourceSettings
Returns:
whether the comments and whitespace characters will be stripped from resources served through JavaScriptPackageResource. Null is a valid value.

setJavaScriptCompressor

public IJavaScriptCompressor setJavaScriptCompressor(IJavaScriptCompressor compressor)
Description copied from interface: IResourceSettings
Set the javascript compressor implemententation use e.g. by JavaScriptPackageResource. A typical implementation will remove comments and whitespace. But a no-op implementation is available as well.

Specified by:
setJavaScriptCompressor in interface IResourceSettings
Parameters:
compressor - The implementation to be used
Returns:
The old value

getCssCompressor

public ICssCompressor getCssCompressor()
Description copied from interface: IResourceSettings
Get the CSS compressor to remove comments and whitespace characters from css resources

Specified by:
getCssCompressor in interface IResourceSettings
Returns:
whether the comments and whitespace characters will be stripped from resources served through CssPackageResource. Null is a valid value.

setCssCompressor

public ICssCompressor setCssCompressor(ICssCompressor compressor)
Description copied from interface: IResourceSettings
Set the CSS compressor implemententation use e.g. by CssPackageResource. A typical implementation will remove comments and whitespace. But a no-op implementation is available as well.

Specified by:
setCssCompressor in interface IResourceSettings
Parameters:
compressor - The implementation to be used
Returns:
The old value

getParentFolderPlaceholder

public java.lang.String getParentFolderPlaceholder()
Description copied from interface: IResourceSettings
Placeholder string for '..' within resource urls (which will be crippled by the browser and not work anymore). Note that by default the placeholder string is null and thus will not allow to access parent folders. That is by purpose and for security reasons (see Wicket-1992). In case you really need it, a good value for placeholder would e.g. be "$up$". Resources additionally are protected by a IPackageResourceGuard implementation such as PackageResourceGuard which you may use or extend based on your needs.

Specified by:
getParentFolderPlaceholder in interface IResourceSettings
Returns:
placeholder
See Also:
IResourceSettings.getParentFolderPlaceholder()

setParentFolderPlaceholder

public void setParentFolderPlaceholder(java.lang.String sequence)
Description copied from interface: IResourceSettings
Placeholder string for '..' within resource urls (which will be crippled by the browser and not work anymore). Note that by default the placeholder string is null and thus will not allow to access parent folders. That is by purpose and for security reasons (see Wicket-1992). In case you really need it, a good value for placeholder would e.g. be "$up$". Resources additionally are protected by a IPackageResourceGuard implementation such as PackageResourceGuard which you may use or extend based on your needs.

Specified by:
setParentFolderPlaceholder in interface IResourceSettings
Parameters:
sequence - character sequence which must not be ambiguous within urls
See Also:
IResourceSettings.setParentFolderPlaceholder(String)

getCachingStrategy

public IResourceCachingStrategy getCachingStrategy()
Description copied from interface: IResourceSettings
gets the resource caching strategy

Specified by:
getCachingStrategy in interface IResourceSettings
Returns:
strategy
See Also:
IResourceSettings.getCachingStrategy()

setCachingStrategy

public void setCachingStrategy(IResourceCachingStrategy strategy)
Description copied from interface: IResourceSettings
sets the resource caching strategy

Specified by:
setCachingStrategy in interface IResourceSettings
Parameters:
strategy - instance of resource caching strategy
See Also:
IResourceSettings.setCachingStrategy(org.apache.wicket.request.resource.caching.IResourceCachingStrategy)


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.