Package org.apache.wicket
Class SharedResources
- java.lang.Object
-
- org.apache.wicket.SharedResources
-
public class SharedResources extends java.lang.ObjectClass which holds shared resources. Resources can be shared by name. An optional scope can be given to prevent naming conflicts and a locale and/or style can be given as well.Unlike component hosted resources, shared resources have stable URLs, which makes them suitable for indexing by web crawlers and caching by web browsers. As they are also not synchronised on the
Session, they can be loaded asynchronously, which is important with images and resources such as JavaScript and CSS.
-
-
Constructor Summary
Constructors Constructor Description SharedResources(ResourceReferenceRegistry registry)Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.lang.Class<?> scope, java.lang.String name, java.util.Locale locale, java.lang.String style, java.lang.String variation, IResource resource)Adds a resource.voidadd(java.lang.String name, java.util.Locale locale, IResource resource)Adds a resource.voidadd(java.lang.String name, IResource resource)Adds a resource.ResourceReferenceget(java.lang.Class<?> scope, java.lang.String name, java.util.Locale locale, java.lang.String style, java.lang.String variation, boolean strict)Resolves aResourceReferencefor a shared resource.ResourceReferenceget(java.lang.String name)Resolves aResourceReferencefor a shared resource by usingApplicationas a scope andnullfor locale, style and variation.ResourceReferenceremove(ResourceReference.Key key)Removes a resource.
-
-
-
Constructor Detail
-
SharedResources
public SharedResources(ResourceReferenceRegistry registry)
Construct.- Parameters:
registry-
-
-
Method Detail
-
add
public final void add(java.lang.Class<?> scope, java.lang.String name, java.util.Locale locale, java.lang.String style, java.lang.String variation, IResource resource)Adds a resource.- Parameters:
scope- Scope of resourcename- Logical name of resourcelocale- The locale of the resourcestyle- The resource style (seeSession)variation- The component specific variation of the styleresource- Resource to store
-
add
public final void add(java.lang.String name, java.util.Locale locale, IResource resource)Adds a resource.- Parameters:
name- Logical name of resourcelocale- The locale of the resourceresource- Resource to store
-
add
public final void add(java.lang.String name, IResource resource)Adds a resource.- Parameters:
name- Logical name of resourceresource- Resource to store
-
get
public final ResourceReference get(java.lang.String name)
Resolves aResourceReferencefor a shared resource by usingApplicationas a scope andnullfor locale, style and variation.- Parameters:
name- Logical name of resource
-
get
public ResourceReference get(java.lang.Class<?> scope, java.lang.String name, java.util.Locale locale, java.lang.String style, java.lang.String variation, boolean strict)
Resolves aResourceReferencefor a shared resource.- Parameters:
scope- Scope of resourcename- Logical name of resourcelocale- The locale of the resourcestyle- The resource style (seeSession)variation- The component specific variation of the stylestrict- If true, "weaker" combination of scope, name, locale etc. are not tested- Returns:
- Either the resource reference found in the registry or, if requested, a resource reference automatically created based on the parameters provided. The automatically created resource reference will automatically be added to the registry.
-
remove
public final ResourceReference remove(ResourceReference.Key key)
Removes a resource.- Parameters:
key- the resource reference's identifier- Returns:
- the removed
ResourceReference.nullif there was no registration for thisResourceReference.Key
-
-