org.apache.wicket.settings
Interface IResourceSettings

All Known Implementing Classes:
ResourceSettings

public interface IResourceSettings

Interface for resource related settings

resourcePollFrequency (defaults to no polling frequency) - Frequency at which resources should be polled for changes.

resourceFinder (classpath) - Set this to alter the search path for resources.

useDefaultOnMissingResource (defaults to true) - Set to true to return a default value if available when a required string resource is not found. If set to false then the throwExceptionOnMissingResource flag is used to determine how to behave. If no default is available then this is the same as if this flag were false

A ResourceStreamLocator - An Application's ResourceStreamLocator is used to find resources such as images or markup files. You can supply your own ResourceStreamLocator if your prefer to store your application's resources in a non-standard location (such as a different filesystem location, a particular JAR file or even a database) by overriding the getResourceLocator() method.

Resource Factories - Resource factories can be used to create resources dynamically from specially formatted HTML tag attribute values. For more details, see IResourceFactory, DefaultButtonImageResourceFactory and especially LocalizedImageResource.

A Localizer The getLocalizer() method returns an object encapsulating all of the functionality required to access localized resources. For many localization problems, even this will not be required, as there are convenience methods available to all components: Component.getString(String key) and Component.getString(String key, IModel model).

stringResourceLoaders - A chain of IStringResourceLoader instances that are searched in order to obtain string resources used during localization. By default the chain is set up to first search for resources against a particular component (e.g. page etc.) and then against the application.

Author:
Igor Vaynberg (ivaynberg)

Method Summary
 void addResourceFactory(String name, IResourceFactory resourceFactory)
          Adds a resource factory to the list of factories to consult when generating resources automatically
 void addResourceFolder(String resourceFolder)
          Convenience method that sets the resource search path to a single folder.
 Duration getDefaultCacheDuration()
          Get the the default cache duration for resources.
 boolean getDisableGZipCompression()
          Whether to disable gzip compression for resources.
 IFileUploadCleaner getFileUploadCleaner()
           
 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.
 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(String name)
           
 IResourceFinder getResourceFinder()
          Gets the resource finder to use when searching for resources.
 Duration getResourcePollFrequency()
           
 IResourceStreamLocator getResourceStreamLocator()
           
 IModificationWatcher getResourceWatcher(boolean start)
           
 List<IStringResourceLoader> getStringResourceLoaders()
           
 boolean getThrowExceptionOnMissingResource()
           
 boolean getUseDefaultOnMissingResource()
           
 boolean getUseTimestampOnResources()
          Control the usage of timestamps on resources

Normally the resource names won't change when the resource ifself changes, for example when you add a new style to your CSS sheet.

 void setDefaultCacheDuration(Duration defaultDuration)
          Set the the default cache duration for resources.
 void setDisableGZipCompression(boolean disableGZipCompression)
          Sets whether to disable gzip compression for resources.
 void setFileUploadCleaner(IFileUploadCleaner fileUploadCleaner)
          Sets a cleaner for the temporary files created by FileUpload functionality
 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(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)
           
 void setUseTimestampOnResources(boolean enable)
          Control the usage of timestamps on resources

Normally the resource names won't change when the resource ifself changes, for example when you add a new style to your CSS sheet.

 

Method Detail

addResourceFactory

void addResourceFactory(String name,
                        IResourceFactory resourceFactory)
Adds a resource factory to the list of factories to consult when generating resources automatically

Parameters:
name - The name to give to the factory
resourceFactory - The resource factory to add

addResourceFolder

void addResourceFolder(String resourceFolder)
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

Parameters:
resourceFolder - The resourceFolder to set

getDefaultCacheDuration

Duration getDefaultCacheDuration()
Get the the default cache duration for resources.

Returns:
cache duration (Duration.NONE will be returned if caching is disabled)
See Also:
Duration.NONE

getDisableGZipCompression

boolean getDisableGZipCompression()
Whether to disable gzip compression for resources. You need this on SAP, which gzips things twice.

Returns:
True if we should disable gzip compression
Since:
1.3.0

getLocalizer

Localizer getLocalizer()
Get the application's localizer.

Returns:
The application wide localizer instance
See Also:
for means of extending the way Wicket resolves keys to localized messages.

getPackageResourceGuard

IPackageResourceGuard getPackageResourceGuard()
Gets the package resource guard.

Returns:
The package resource guard

getPropertiesFactory

IPropertiesFactory getPropertiesFactory()
Get the property factory which will be used to load property files

Returns:
PropertiesFactory

getResourceFactory

IResourceFactory getResourceFactory(String name)
Parameters:
name - Name of the factory to get
Returns:
The IResourceFactory with the given name.

getResourceFinder

IResourceFinder getResourceFinder()
Gets the resource finder to use when searching for resources.

Returns:
Returns the resourceFinder.
See Also:
setResourceFinder(IResourceFinder)

getResourcePollFrequency

Duration getResourcePollFrequency()
Returns:
Returns the resourcePollFrequency.
See Also:
setResourcePollFrequency(Duration)

getResourceStreamLocator

IResourceStreamLocator getResourceStreamLocator()
Returns:
Resource locator for this application

getResourceWatcher

IModificationWatcher getResourceWatcher(boolean start)
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.

getStringResourceLoaders

List<IStringResourceLoader> getStringResourceLoaders()
Returns:
list of all available string resource loaders
See Also:
#addStringResourceLoader(IStringResourceLoader), #addStringResourceLoader(int, IStringResourceLoader)

getThrowExceptionOnMissingResource

boolean getThrowExceptionOnMissingResource()
Returns:
boolean

getUseDefaultOnMissingResource

boolean getUseDefaultOnMissingResource()
Returns:
Whether to use a default value (if available) when a missing resource is requested

setDefaultCacheDuration

void setDefaultCacheDuration(Duration defaultDuration)
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.

Parameters:
defaultDuration - default cache duration in seconds
See Also:
Duration.NONE, WebResponse.MAX_CACHE_DURATION

setDisableGZipCompression

void setDisableGZipCompression(boolean disableGZipCompression)
Sets whether to disable gzip compression for resources. You need to set this on some SAP versions, which gzip things twice.

Parameters:
disableGZipCompression -
Since:
1.3.0

setLocalizer

void setLocalizer(Localizer localizer)
Sets the localizer which will be used to find property values.

Parameters:
localizer -
Since:
1.3.0

setPackageResourceGuard

void setPackageResourceGuard(IPackageResourceGuard packageResourceGuard)
Sets the package resource guard.

Parameters:
packageResourceGuard - The package resource guard

setPropertiesFactory

void setPropertiesFactory(IPropertiesFactory factory)
Set the property factory which will be used to load property files

Parameters:
factory -

setResourceFinder

void setResourceFinder(IResourceFinder resourceFinder)
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.

Parameters:
resourceFinder - The resourceFinder to set

setResourcePollFrequency

void setResourcePollFrequency(Duration resourcePollFrequency)
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. Default is for no resource polling to occur.

Parameters:
resourcePollFrequency - Frequency at which to poll resources
See Also:
setResourceFinder(IResourceFinder)

setResourceStreamLocator

void setResourceStreamLocator(IResourceStreamLocator resourceStreamLocator)
Sets the resource stream locator for this application

Parameters:
resourceStreamLocator - new resource stream locator

setResourceWatcher

void setResourceWatcher(IModificationWatcher watcher)
Sets the resource watcher

Parameters:
watcher -

setFileUploadCleaner

void setFileUploadCleaner(IFileUploadCleaner fileUploadCleaner)
Sets a cleaner for the temporary files created by FileUpload functionality

Parameters:
fileUploadCleaner - the actual cleaner implementation. Can be null

getFileUploadCleaner

IFileUploadCleaner getFileUploadCleaner()
Returns:
the cleaner for the temporary files created by FileUpload functionality. Can be null

setThrowExceptionOnMissingResource

void setThrowExceptionOnMissingResource(boolean throwExceptionOnMissingResource)
Parameters:
throwExceptionOnMissingResource -

setUseDefaultOnMissingResource

void setUseDefaultOnMissingResource(boolean useDefaultOnMissingResource)
Parameters:
useDefaultOnMissingResource - Whether to use a default value (if available) when a missing resource is requested

setJavaScriptCompressor

IJavaScriptCompressor setJavaScriptCompressor(IJavaScriptCompressor compressor)
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.

Parameters:
compressor - The implementation to be used
Returns:
The old value

getJavaScriptCompressor

IJavaScriptCompressor getJavaScriptCompressor()
Get the javascript compressor to remove comments and whitespace characters from javascripts

Returns:
whether the comments and whitespace characters will be stripped from resources served through JavaScriptPackageResource. Null is a valid value.

getParentFolderPlaceholder

String getParentFolderPlaceholder()
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 empty '' 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.

Returns:
placeholder

setParentFolderPlaceholder

void setParentFolderPlaceholder(String sequence)
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 empty '' 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.

Parameters:
sequence - character sequence which must not be ambiguous within urls
See Also:
getParentFolderPlaceholder()

getUseTimestampOnResources

boolean getUseTimestampOnResources()
Control the usage of timestamps on resources

Normally the resource names won't change when the resource ifself changes, for example when you add a new style to your CSS sheet. This can be very annoying as browsers (and proxies) usally cache resources in their cache based on the filename and therefore won't update. Unless you change the file name of the resource, force a reload or clear the browser's cache the page will still render with your old CSS.

Depending on HTTP response headers like 'Last-Modified' and 'Cache' automatic cache invalidation can take very, very long or neven happen at all.

Enabling timestamps on resources will inject the last modification time of the resource into the filename (the name will look something like 'style-ts1282915831000.css' where the large number is the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts with filenames that already contain a number before their extension. *

Since browsers and proxies use the filename of the resource as a cache key the changed filename will not hit the cache and the page gets rendered with the changed file.

Returns:
true if timestamps are enabled

setUseTimestampOnResources

void setUseTimestampOnResources(boolean enable)
Control the usage of timestamps on resources

Normally the resource names won't change when the resource ifself changes, for example when you add a new style to your CSS sheet. This can be very annoying as browsers (and proxies) usally cache resources in their cache based on the filename and therefore won't update. Unless you change the file name of the resource, force a reload or clear the browser's cache the page will still render with your old CSS.

Depending on HTTP response headers like 'Last-Modified' and 'Cache' automatic cache invalidation can take very, very long or neven happen at all.

Enabling timestamps on resources will inject the last modification time of the resource into the filename (the name will look something like 'style-ts1282915831000.css' where the large number is the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts with filenames that already contain a number before their extension. *

Since browsers and proxies use the filename of the resource as a cache key the changed filename will not hit the cache and the page gets rendered with the changed file.

Parameters:
enable - true for using timestamps on resource names


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