public class ResourceReferenceRegistry extends Object
ResourceReference
s per Application.Application.getResourceReferenceRegistry()
,
Application.newResourceReferenceRegistry()
Modifier and Type | Class and Description |
---|---|
static class |
ResourceReferenceRegistry.DefaultResourceReferenceFactory
A simple implementation of
IResourceReferenceFactory that creates
PackageResourceReference |
Constructor and Description |
---|
ResourceReferenceRegistry()
Constructor.
|
ResourceReferenceRegistry(IResourceReferenceFactory resourceReferenceFactory)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
clearAutoAddedEntries()
Unregisters all auto-added Resource References
|
protected ResourceReference |
createDefaultResourceReference(ResourceReference.Key key)
Creates a default resource reference in case no registry entry and it was requested to create
one.
|
int |
getAutoAddedCacheSize() |
int |
getAutoAddedCapacity()
Gets cache size in number of entries
|
ResourceReference |
getResourceReference(Class<?> scope,
String name,
Locale locale,
String style,
String variation,
boolean strict,
boolean createIfNotFound)
Get a resource reference matching the parameters from the registry or if not found and
requested, create an default resource reference and add it to the registry.
|
ResourceReference |
getResourceReference(ResourceReference.Key key,
boolean strict,
boolean createIfNotFound)
Get a resource reference matching the parameters from the registry or if not found and
requested, create an default resource reference and add it to the registry.
|
IResourceReferenceFactory |
getResourceReferenceFactory() |
int |
getSize() |
boolean |
registerResourceReference(ResourceReference reference)
Registers the given
ResourceReference . |
void |
setAutoAddedCapacity(int autoAddedCapacity)
Set the cache size in number of entries
|
void |
setResourceReferenceFactory(IResourceReferenceFactory resourceReferenceFactory)
Sets the factory to use when a ResourceReference is not previously
registered and a new instance should be created
|
ResourceReference |
unregisterResourceReference(ResourceReference.Key key)
Unregisters a
ResourceReference by its identifier. |
public ResourceReferenceRegistry()
Uses DefaultResourceReferenceFactory to create ResourceReference when there is no registered one for the requested attributes
public ResourceReferenceRegistry(IResourceReferenceFactory resourceReferenceFactory)
resourceReferenceFactory
- The factory that will create ResourceReference by Key when there is no registered onepublic final boolean registerResourceReference(ResourceReference reference)
ResourceReference
.
ResourceReference.canBeRegistered()
must return true
. Else, the resource
reference will not be registered.
reference
- the reference to registertrue
if the resource was registered successfully or has been registered previously
already.public final ResourceReference unregisterResourceReference(ResourceReference.Key key)
ResourceReference
by its identifier.key
- the ResourceReference
's identifiernull
if the registry did not contain an entry for this key.public final ResourceReference getResourceReference(Class<?> scope, String name, Locale locale, String style, String variation, boolean strict, boolean createIfNotFound)
Part of the search is scanning the class (scope) and it's superclass for static ResourceReference fields. Found fields get registered automatically (but are different from auto-generated ResourceReferences).
scope
- The scope of resource reference (e.g. the Component's class)name
- The name of resource reference (e.g. filename)locale
- see Componentstyle
- see Componentvariation
- see Componentstrict
- If true, "weaker" combination of scope, name, locale etc. are not testedcreateIfNotFound
- If true a default resource reference is created if no entry can be found in the
registry. The newly created resource reference will be added to the registry.createDefaultResourceReference(org.apache.wicket.request.resource.ResourceReference.Key)
,
ClassScanner
public final ResourceReference getResourceReference(ResourceReference.Key key, boolean strict, boolean createIfNotFound)
Part of the search is scanning the class (scope) and it's superclass for static ResourceReference fields. Found fields get registered automatically (but are different from auto-generated ResourceReferences).
key
- The data making up the resource referencestrict
- If true, "weaker" combination of scope, name, locale etc. are not testedcreateIfNotFound
- If true a default resource reference is created if no entry can be found in the
registry. The newly created resource reference will be added to the registry.createDefaultResourceReference(org.apache.wicket.request.resource.ResourceReference.Key)
,
ClassScanner
protected ResourceReference createDefaultResourceReference(ResourceReference.Key key)
A PackageResourceReference
will be created by default
key
- the data making up the resource referenceResourceReference
created or null
if not successfulpublic final void setAutoAddedCapacity(int autoAddedCapacity)
autoAddedCapacity
- A value < 0 will disable aging of auto-create resource references. They will be
created, added to the registry and live their until manually removed or the
application shuts down.public final int getAutoAddedCapacity()
public final void clearAutoAddedEntries()
public final int getAutoAddedCacheSize()
public final int getSize()
public IResourceReferenceFactory getResourceReferenceFactory()
ResourceReference.Key
public void setResourceReferenceFactory(IResourceReferenceFactory resourceReferenceFactory)
resourceReferenceFactory
- the factory that will create the resource reference by using the parsed
ResourceReference.Key
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.