org.openbp.common.resource
Class FileResourceProvider

java.lang.Object
  extended by org.openbp.common.resource.ResourceProvider
      extended by org.openbp.common.resource.FileResourceProvider

public class FileResourceProvider
extends ResourceProvider

Provides access to file system-based resources. Resources are retrieved from the file system from a resource directory. A Spring ResourceLoader is used to retrieve file resources. Multiple FileResourceProviders-Obects can be registered with a common ResourceResolver. This is used by the ResourceResolver to implement a "match-first" strategy, where multiple sources for resources can be configured (with multiple ResourceProviders) and the first match is returned.

Author:
Heiko Erhardt

Field Summary
 
Fields inherited from class org.openbp.common.resource.ResourceProvider
PROTOCOL_PREFIX_SEPARATOR, resourceLoader
 
Constructor Summary
FileResourceProvider(int priority, org.springframework.core.io.ResourceLoader loader, java.lang.String resourceDir)
          Constructor.
 
Method Summary
 java.lang.String getPrefix()
          Protocol prefix of this provider
 org.springframework.core.io.Resource getResource(java.lang.String resourceLocation)
          file based resources are first matched with the root dir name
 java.lang.String getResourceDir()
          Gets the directory to load the resource files from.
 void setResourceDir(java.lang.String resourceDir)
          Sets the directory to load the resource files from.
 java.lang.String toString()
           
 
Methods inherited from class org.openbp.common.resource.ResourceProvider
applyPrefix, getPriority, getResourceLoader, hasPrefix, setPriority, setResourceLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileResourceProvider

public FileResourceProvider(int priority,
                            org.springframework.core.io.ResourceLoader loader,
                            java.lang.String resourceDir)
Constructor.

Parameters:
priority - Priority of the provider
loader - Loader
resourceDir - Resource dir
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getResource

public org.springframework.core.io.Resource getResource(java.lang.String resourceLocation)
                                                 throws ResourceMgrException
file based resources are first matched with the root dir name

Specified by:
getResource in class ResourceProvider
Parameters:
resourceLocation - Resource location
Returns:
The resource
Throws:
ResourceMgrException - If the provider is unable to find the specified resource

getPrefix

public java.lang.String getPrefix()
Description copied from class: ResourceProvider
Protocol prefix of this provider

Overrides:
getPrefix in class ResourceProvider
Returns:
E.g. "file:", "classpath:", "http:"; default is ""

getResourceDir

public java.lang.String getResourceDir()
Gets the directory to load the resource files from.


setResourceDir

public void setResourceDir(java.lang.String resourceDir)
Sets the directory to load the resource files from.



Copyright © 2011. All Rights Reserved.