org.apache.beehive.netui.core.urltemplates
Class URLTemplatesFactory

Object
  extended by Factory
      extended by URLTemplatesFactory
All Implemented Interfaces:
Serializable

public abstract class URLTemplatesFactory
extends Factory

Access point to URL templates (an optional config file to help format rewritten URLs) used by a TemplatedURLFormatter via the URLRewriterService.

See Also:
Serialized Form

Field Summary
protected  String _configFilePath
           
protected  Collection _knownTokens
           
protected  Collection _requiredTokens
           
static String ACTION_TEMPLATE
           
static String DEFAULT_TEMPLATE
           
static String DEFAULT_URL_TEMPLATE_CONFIG_FILE_PATH
          Default value for path from the web app to the URL templates.
static String RENDER_TEMPLATE
           
static String RESOURCE_TEMPLATE
           
static String SECURE_ACTION_TEMPLATE
           
static String SECURE_DEFAULT_TEMPLATE
           
static String SECURE_RENDER_TEMPLATE
           
static String SECURE_RESOURCE_TEMPLATE
           
 
Constructor Summary
URLTemplatesFactory()
           
 
Method Summary
abstract  String getTemplateNameByRef(String refGroupName, String key)
          Returns URL template name of the given type (by key) from the desired reference group.
abstract  URLTemplate getURLTemplate(String name)
          Returns URL template given the name of the template.
abstract  URLTemplate[] getURLTemplates()
          Returns an array of the URL templates.
static URLTemplatesFactory getURLTemplatesFactory(ServletContext servletContext)
          Gets the URLTemplatesFactory instance attribute of the ServletContext.
static void initServletContext(ServletContext servletContext, URLTemplatesFactory templatesFactory)
          Adds a given URLTemplatesFactory instance as an attribute of the ServletContext.
abstract  void load(ServletContext servletContext)
          Initialization method that parses the URL template config file to get the URL templates and template reference groups.
 void setConfigFilePath(String configFilePath)
          Allow clients to set their own URL template config file name/path.
 void setKnownTokens(Collection knownTokens)
          Allow clients to define a set of known tokens for the template verification.
 void setRequiredTokens(Collection requiredTokens)
          Allow clients to define a set of required tokens for the template verification.
 
Methods inherited from class Factory
getConfig, getServletContext, onCreate, reinit
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TEMPLATE

public static final String DEFAULT_TEMPLATE
See Also:
Constant Field Values

SECURE_DEFAULT_TEMPLATE

public static final String SECURE_DEFAULT_TEMPLATE
See Also:
Constant Field Values

ACTION_TEMPLATE

public static final String ACTION_TEMPLATE
See Also:
Constant Field Values

SECURE_ACTION_TEMPLATE

public static final String SECURE_ACTION_TEMPLATE
See Also:
Constant Field Values

RESOURCE_TEMPLATE

public static final String RESOURCE_TEMPLATE
See Also:
Constant Field Values

SECURE_RESOURCE_TEMPLATE

public static final String SECURE_RESOURCE_TEMPLATE
See Also:
Constant Field Values

RENDER_TEMPLATE

public static final String RENDER_TEMPLATE
See Also:
Constant Field Values

SECURE_RENDER_TEMPLATE

public static final String SECURE_RENDER_TEMPLATE
See Also:
Constant Field Values

DEFAULT_URL_TEMPLATE_CONFIG_FILE_PATH

public static final String DEFAULT_URL_TEMPLATE_CONFIG_FILE_PATH
Default value for path from the web app to the URL templates.

See Also:
Constant Field Values

_configFilePath

protected String _configFilePath

_knownTokens

protected Collection _knownTokens

_requiredTokens

protected Collection _requiredTokens
Constructor Detail

URLTemplatesFactory

public URLTemplatesFactory()
Method Detail

getURLTemplatesFactory

public static URLTemplatesFactory getURLTemplatesFactory(ServletContext servletContext)
Gets the URLTemplatesFactory instance attribute of the ServletContext.

Parameters:
servletContext - the current ServletContext.
Returns:
the URLTemplatesFactory instance from the ServletContext.

initServletContext

public static void initServletContext(ServletContext servletContext,
                                      URLTemplatesFactory templatesFactory)
Adds a given URLTemplatesFactory instance as an attribute of the ServletContext.

Parameters:
servletContext - the current ServletContext.
templatesFactory - the URLTemplatesFactory instance to add as an attribute of the context

setConfigFilePath

public void setConfigFilePath(String configFilePath)
Allow clients to set their own URL template config file name/path.

Parameters:
configFilePath - An absolute path from the web app root to the URL template config file.

setKnownTokens

public void setKnownTokens(Collection knownTokens)
Allow clients to define a set of known tokens for the template verification. Tokens are expected to be qualified in braces. E.g. {url:path}

The template verification will ensure the known tokens in the URL template conforms to a valid format.

Parameters:
knownTokens - The set of known tokens for a valid template.

setRequiredTokens

public void setRequiredTokens(Collection requiredTokens)
Allow clients to define a set of required tokens for the template verification. Tokens are expected to be qualified in braces. E.g. {url:path}

The template verification will ensure the URL template conforms to a valid format for known tokens and contains the required tokens.

Parameters:
requiredTokens - The set of required tokens in a valid template.

getURLTemplates

public abstract URLTemplate[] getURLTemplates()
Returns an array of the URL templates.

Returns:
the URL templates

getURLTemplate

public abstract URLTemplate getURLTemplate(String name)
Returns URL template given the name of the template.

Parameters:
name - name of the template
Returns:
template

getTemplateNameByRef

public abstract String getTemplateNameByRef(String refGroupName,
                                            String key)
Returns URL template name of the given type (by key) from the desired reference group.

Parameters:
refGroupName - name of a group of templates from the config file.
key - type of the template
Returns:
template name

load

public abstract void load(ServletContext servletContext)
Initialization method that parses the URL template config file to get the URL templates and template reference groups.

Parameters:
servletContext - the current ServletContext.