wicket.settings
Interface IResourceSettings

All Known Implementing Classes:
Settings

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(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.
 void addStringResourceLoader(IStringResourceLoader loader)
          Add a string resource loader to the chain of loaders.
 java.util.Locale getDefaultLocale()
           
 Localizer getLocalizer()
          Get the application's localizer.
 IPackageResourceGuard getPackageResourceGuard()
          Gets the package resource guard.
 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()
           
 ModificationWatcher getResourceWatcher()
           
 java.util.List getStringResourceLoaders()
           
 boolean getThrowExceptionOnMissingResource()
           
 boolean getUseDefaultOnMissingResource()
           
 void setDefaultLocale(java.util.Locale defaultLocale)
           
 void setPackageResourceGuard(IPackageResourceGuard packageResourceGuard)
          Sets the package resource guard.
 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 setThrowExceptionOnMissingResource(boolean throwExceptionOnMissingResource)
           
 void setUseDefaultOnMissingResource(boolean useDefaultOnMissingResource)
           
 

Method Detail

addResourceFactory

void addResourceFactory(java.lang.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(java.lang.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

addStringResourceLoader

void addStringResourceLoader(IStringResourceLoader loader)
Add a string resource loader to the chain of loaders. If this is the first call to this method since the creation of the application settings then the existing chain is cleared before the new loader is added.

Parameters:
loader - The loader to be added

getDefaultLocale

java.util.Locale getDefaultLocale()
Returns:
Returns the defaultLocale.

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(java.lang.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

ModificationWatcher getResourceWatcher()
Returns:
Resource watcher with polling frequency determined by setting, or null if no polling frequency has been set.

getStringResourceLoaders

java.util.List getStringResourceLoaders()
Returns:
an unmodifiable list of all available string resource loaders

getThrowExceptionOnMissingResource

boolean getThrowExceptionOnMissingResource()
Returns:
boolean
See Also:
IExceptionSettings.getThrowExceptionOnMissingResource()

getUseDefaultOnMissingResource

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

setDefaultLocale

void setDefaultLocale(java.util.Locale defaultLocale)
Parameters:
defaultLocale - The defaultLocale to set.

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

setThrowExceptionOnMissingResource

void setThrowExceptionOnMissingResource(boolean throwExceptionOnMissingResource)
Parameters:
throwExceptionOnMissingResource -
See Also:
IExceptionSettings.setThrowExceptionOnMissingResource(boolean)

setUseDefaultOnMissingResource

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


Copyright © 2004-2008 Wicket developers. All Rights Reserved.