org.apache.sling.fsprovider.internal
Class FsResourceProvider

java.lang.Object
  extended by org.apache.sling.fsprovider.internal.FsResourceProvider
All Implemented Interfaces:
ResourceProvider

public class FsResourceProvider
extends Object
implements ResourceProvider

The FsResourceProvider is a resource provider which maps filesystem files and folders into the virtual resource tree. The provider is implemented in terms of a component factory, that is multiple instances of this provider may be created by creating respective configuration.

Each provider instance is configured with two properties: The location in the resource tree where resources are provided (ResourceProvider.ROOTS) and the file system path from where files and folders are mapped into the resource (PROP_PROVIDER_FILE).


Field Summary
static long DEFAULT_CHECKINTERVAL
           
static String PROP_PROVIDER_CHECKINTERVAL
          The name of the configuration property providing the check interval for file changes (value is "provider.checkinterval").
static String PROP_PROVIDER_FILE
          The name of the configuration property providing file system path of files and folders mapped into the resource tree (value is "provider.file").
 
Fields inherited from interface org.apache.sling.api.resource.ResourceProvider
RESOURCE_TYPE_SYNTHETIC, ROOTS, SERVICE_NAME
 
Constructor Summary
FsResourceProvider()
           
 
Method Summary
protected  void activate(org.osgi.framework.BundleContext bundleContext, Map<?,?> props)
           
protected  void deactivate()
           
 Resource getResource(ResourceResolver resourceResolver, javax.servlet.http.HttpServletRequest request, String path)
          Same as getResource(ResourceResolver, String), i.e.
 Resource getResource(ResourceResolver resourceResolver, String path)
          Returns a resource wrapping a filesystem file or folder for the given path.
 Iterator<Resource> listChildren(Resource parent)
          Returns an iterator of resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_PROVIDER_FILE

public static final String PROP_PROVIDER_FILE
The name of the configuration property providing file system path of files and folders mapped into the resource tree (value is "provider.file").

See Also:
Constant Field Values

PROP_PROVIDER_CHECKINTERVAL

public static final String PROP_PROVIDER_CHECKINTERVAL
The name of the configuration property providing the check interval for file changes (value is "provider.checkinterval").

See Also:
Constant Field Values

DEFAULT_CHECKINTERVAL

public static long DEFAULT_CHECKINTERVAL
Constructor Detail

FsResourceProvider

public FsResourceProvider()
Method Detail

getResource

public Resource getResource(ResourceResolver resourceResolver,
                            javax.servlet.http.HttpServletRequest request,
                            String path)
Same as getResource(ResourceResolver, String), i.e. the request parameter is ignored.

Specified by:
getResource in interface ResourceProvider
Parameters:
resourceResolver - The ResourceResolver to which the returned Resource is attached.
Returns:
null If this provider does not have a resource for the path.
See Also:
getResource(ResourceResolver, String)

getResource

public Resource getResource(ResourceResolver resourceResolver,
                            String path)
Returns a resource wrapping a filesystem file or folder for the given path. If the path is equal to the configured resource tree location of this provider, the configured file system file or folder is used for the resource. Otherwise the configured resource tree location prefix is removed from the path and the remaining relative path is used to access the file or folder. If no such file or folder exists, this method returns null.

Specified by:
getResource in interface ResourceProvider
Parameters:
resourceResolver - The ResourceResolver to which the returned Resource is attached.
Returns:
null If this provider does not have a resource for the path.

listChildren

public Iterator<Resource> listChildren(Resource parent)
Returns an iterator of resources.

Specified by:
listChildren in interface ResourceProvider
Parameters:
parent - The Resource whose children are requested.
Returns:
An Iterator of Resource objects or null if the resource provider has no children for the given resource.

activate

protected void activate(org.osgi.framework.BundleContext bundleContext,
                        Map<?,?> props)

deactivate

protected void deactivate()


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.