org.openbp.common.resource
Class ResourceProvider

java.lang.Object
  extended by org.openbp.common.resource.ResourceProvider
Direct Known Subclasses:
ClasspathResourceProvider, FileResourceProvider, HttpResourceProvider

public abstract class ResourceProvider
extends java.lang.Object

BaseClass for various types of ResourceProviders: E.g.: - FileResourceProvider - ClassPathResourceProvider - HttpResourceProvider - DatabaseResourceProvider Multiple ResourceProviders are used by a ResourceResolver to resolve a resource name and load a resource requested by the ResourceManager.

Author:
prachtp

Field Summary
static java.lang.String PROTOCOL_PREFIX_SEPARATOR
           
protected  org.springframework.core.io.ResourceLoader resourceLoader
          Resource loader used by this provider
 
Constructor Summary
protected ResourceProvider(int priority, org.springframework.core.io.ResourceLoader resourceLoader)
          Constructor.
 
Method Summary
 java.lang.String applyPrefix(java.lang.String resourceLocation)
          Applies the protocl prefix to the given resource location.
 java.lang.String getPrefix()
          Protocol prefix of this provider
 int getPriority()
          Gets the priority of this provider; small numbers will be tried before larger numbers.
abstract  org.springframework.core.io.Resource getResource(java.lang.String resourceLocation)
          Gets a resource.
 org.springframework.core.io.ResourceLoader getResourceLoader()
          Gets the resource loader used by this provider.
 boolean hasPrefix(java.lang.String resourceLocation)
          Checks if a resourceName is prefixed with a protocol.
 void setPriority(int priority)
          Sets the priority of this provider; small numbers will be tried before larger numbers.
 void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
          Sets the resource loader used by this provider.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL_PREFIX_SEPARATOR

public static final java.lang.String PROTOCOL_PREFIX_SEPARATOR
See Also:
Constant Field Values

resourceLoader

protected org.springframework.core.io.ResourceLoader resourceLoader
Resource loader used by this provider

Constructor Detail

ResourceProvider

protected ResourceProvider(int priority,
                           org.springframework.core.io.ResourceLoader resourceLoader)
Constructor.

Parameters:
priority - Priority of the provider
resourceLoader - Resource loader
Method Detail

getResource

public abstract org.springframework.core.io.Resource getResource(java.lang.String resourceLocation)
                                                          throws ResourceMgrException
Gets a resource.

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()
Protocol prefix of this provider

Returns:
E.g. "file:", "classpath:", "http:"; default is ""

hasPrefix

public boolean hasPrefix(java.lang.String resourceLocation)
Checks if a resourceName is prefixed with a protocol.

Parameters:
resourceLocation - Spring framework-style resource location
Returns:
true if the resource has a protocol prefix

applyPrefix

public java.lang.String applyPrefix(java.lang.String resourceLocation)
Applies the protocl prefix to the given resource location.

Parameters:
resourceLocation - Resource
Returns:
The resource location, prefixed by the prefix of the provider (e. h. "file:")

getResourceLoader

public org.springframework.core.io.ResourceLoader getResourceLoader()
Gets the resource loader used by this provider.


setResourceLoader

public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
Sets the resource loader used by this provider.


getPriority

public int getPriority()
Gets the priority of this provider; small numbers will be tried before larger numbers.


setPriority

public void setPriority(int priority)
Sets the priority of this provider; small numbers will be tried before larger numbers.



Copyright © 2011. All Rights Reserved.