org.norther.tammi.spray.engine.resource
Class AbstractResourceResolver

java.lang.Object
  extended by org.norther.tammi.spray.engine.resource.AbstractResourceResolver
All Implemented Interfaces:
Serializable, ResourceResolver
Direct Known Subclasses:
ClassPathResourceResolver, FileResourceResolver, JarResourceResolver, PropertyResourceResolver

public abstract class AbstractResourceResolver
extends Object
implements ResourceResolver, Serializable

An abstract implementation of ResourceResolver.

Author:
Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
protected  class AbstractResourceResolver.AbstractResource
          An abstract resource.
 
Constructor Summary
AbstractResourceResolver()
          Constructs a new resolver.
 
Method Summary
 String getFinderAlias()
          Gets the name or alias of the finder to apply.
 String getFinderKey()
          Gets the finder key to apply.
abstract  long getLastModified(String name)
          Gets a timestamp of the last modification of the resource.
protected  MBeanServer getMBeanServer()
          Gets the MBean server.
protected  PathFinder getPathFinder()
          Gets the path finder.
 String[] getPaths()
          Gets the array of resource paths.
abstract  Resource getResource(String name)
          Gets a named resource.
abstract  InputStream getResourceAsStream(String name)
          Gets a named resource as a stream.
 MBeanReference getTemplateEngineMBean()
          Gets a reference to the template engine MBean.
protected  Locale resolveLocale(StringBuilder name)
          Resolves the locale from a named resource, if any.
abstract  boolean resourceExists(String name)
          Checks whether a resource exists.
 void setFinderAlias(String alias)
          Sets the name or alias of the finder to apply.
 void setFinderKey(String key)
          Sets the finder key to apply.
 void setPaths(String[] paths)
          Sets the array of resource paths.
 void setTemplateEngineMBean(MBeanReference instance)
          Sets a reference to the template engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResourceResolver

public AbstractResourceResolver()
Constructs a new resolver.

Method Detail

setPaths

public void setPaths(String[] paths)
Description copied from interface: ResourceResolver
Sets the array of resource paths.

Specified by:
setPaths in interface ResourceResolver
Parameters:
paths - the resource paths.

getPaths

public String[] getPaths()
Description copied from interface: ResourceResolver
Gets the array of resource paths.

Specified by:
getPaths in interface ResourceResolver
Returns:
the resource paths or null.

getFinderKey

public String getFinderKey()
Description copied from interface: ResourceResolver
Gets the finder key to apply.

Specified by:
getFinderKey in interface ResourceResolver
Returns:
the finder key or null.

setFinderKey

public void setFinderKey(String key)
Description copied from interface: ResourceResolver
Sets the finder key to apply.

Specified by:
setFinderKey in interface ResourceResolver
Parameters:
key - the finder key.

getFinderAlias

public String getFinderAlias()
Description copied from interface: ResourceResolver
Gets the name or alias of the finder to apply.

Specified by:
getFinderAlias in interface ResourceResolver
Returns:
the finder alias or null.

setFinderAlias

public void setFinderAlias(String alias)
Description copied from interface: ResourceResolver
Sets the name or alias of the finder to apply.

Specified by:
setFinderAlias in interface ResourceResolver
Parameters:
alias - the finder alias.

getTemplateEngineMBean

public MBeanReference getTemplateEngineMBean()
Description copied from interface: ResourceResolver
Gets a reference to the template engine MBean.

Specified by:
getTemplateEngineMBean in interface ResourceResolver
Returns:
a reference to the template engine MBean.

setTemplateEngineMBean

public void setTemplateEngineMBean(MBeanReference instance)
Description copied from interface: ResourceResolver
Sets a reference to the template engine.

Specified by:
setTemplateEngineMBean in interface ResourceResolver
Parameters:
instance - a reference to the template engine MBean.

getResource

public abstract Resource getResource(String name)
Description copied from interface: ResourceResolver
Gets a named resource.

Specified by:
getResource in interface ResourceResolver
Parameters:
name - the name of the resource.
Returns:
the named resource or null if not found.

getResourceAsStream

public abstract InputStream getResourceAsStream(String name)
                                         throws IOException
Description copied from interface: ResourceResolver
Gets a named resource as a stream.

Specified by:
getResourceAsStream in interface ResourceResolver
Parameters:
name - the name of the resource.
Returns:
the named resource as a stream or null if not found.
Throws:
IOException - on I/O errors.

getLastModified

public abstract long getLastModified(String name)
Description copied from interface: ResourceResolver
Gets a timestamp of the last modification of the resource.

Specified by:
getLastModified in interface ResourceResolver
Parameters:
name - the name of the resource.
Returns:
the modification time stamp or 0 if not found.

resourceExists

public abstract boolean resourceExists(String name)
Description copied from interface: ResourceResolver
Checks whether a resource exists.

Specified by:
resourceExists in interface ResourceResolver
Parameters:
name - the name of the resource.
Returns:
true if the resource exists, otherwise false.

resolveLocale

protected Locale resolveLocale(StringBuilder name)
Resolves the locale from a named resource, if any. The resolved locale string is also removed from the name.

Parameters:
name - the resource name.
Returns:
the locale or null.

getMBeanServer

protected MBeanServer getMBeanServer()
Gets the MBean server.

Returns:
the server or null.

getPathFinder

protected PathFinder getPathFinder()
Gets the path finder.

Returns:
the path finder.
Throws:
IllegalStateException - if not found.


Copyright © 2004 The Norther Organization. All rights reserved.