org.apache.wicket
Class SharedResources

java.lang.Object
  extended by org.apache.wicket.SharedResources

public class SharedResources
extends java.lang.Object

Class 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
SharedResources(ResourceReferenceRegistry registry)
          Construct.
 
Method Summary
 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.
 void add(java.lang.String name, IResource resource)
          Adds a resource.
 void add(java.lang.String name, java.util.Locale locale, IResource resource)
          Adds a resource.
 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 a ResourceReference for a shared resource.
 ResourceReference remove(ResourceReference.Key key)
          Removes a resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 resource
name - Logical name of resource
locale - The locale of the resource
style - The resource style (see Session)
variation - The component specific variation of the style
resource - 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 resource
locale - The locale of the resource
resource - Resource to store

add

public final void add(java.lang.String name,
                      IResource resource)
Adds a resource.

Parameters:
name - Logical name of resource
resource - Resource to store

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 a ResourceReference for a shared resource.

Parameters:
scope - Scope of resource
name - Logical name of resource
locale - The locale of the resource
style - The resource style (see Session)
variation - The component specific variation of the style
strict - 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. null if there was no registration for this ResourceReference.Key


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