org.jboss.dna.connector.filesystem
Class FileSystemSource

java.lang.Object
  extended by org.jboss.dna.connector.filesystem.FileSystemSource
All Implemented Interfaces:
Serializable, Referenceable, ObjectFactory, RepositorySource

@ThreadSafe
public class FileSystemSource
extends Object
implements RepositorySource, ObjectFactory

The RepositorySource for the connector that exposes an area of the local file system as content in a repository. This source considers a workspace name to be the path to the directory on the file system that represents the root of that workspace. New workspaces can be created, as long as the names represent valid paths to existing directories.

Author:
Randall Hauch
See Also:
Serialized Form

Field Summary
static int DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS
           
static int DEFAULT_RETRY_LIMIT
           
static boolean DEFAULT_SUPPORTS_UPDATES
          This source does not support udpates by default, but each instance may be configured to be read-only or updateable}.
 
Constructor Summary
FileSystemSource()
           
 
Method Summary
 int getCacheTimeToLiveInMilliseconds()
          Get the time in milliseconds that content returned from this source may used while in the cache.
 RepositorySourceCapabilities getCapabilities()
          Get the capabilities for this source.
 RepositoryConnection getConnection()
          Get a connection from this source.
 String getDirectoryForDefaultWorkspace()
          Get the file system path to the existing directory that should be used for the default workspace.
 String getName()
          Get the name for this repository source.
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          
 String[] getPredefinedWorkspaceNames()
          Gets the names of the workspaces that are available when this source is created.
 Reference getReference()
          
 int getRetryLimit()
          Get the maximum number of retries that may be performed on a given operation when using connections created by this source.
 boolean getSupportsUpdates()
          Get whether this source supports updates.
 void initialize(RepositoryContext context)
          Initialize this source to use the supplied RepositoryContext, from which this source can obtain the configuration defining this source, connections to other sources, and the execution context.
 boolean isCreatingWorkspacesAllowed()
          Get whether this source allows workspaces to be created dynamically.
 void setCacheTimeToLiveInMilliseconds(int cacheTimeToLive)
          Set the time in milliseconds that content returned from this source may used while in the cache.
 void setCreatingWorkspacesAllowed(boolean allowWorkspaceCreation)
          Set whether this source allows workspaces to be created dynamically.
 void setDirectoryForDefaultWorkspace(String pathToDirectoryForDefaultWorkspace)
          Set the file system path to the existing directory that should be used for the default workspace.
 void setName(String name)
          Set the name for the source
 void setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)
          Sets the names of the workspaces that are available when this source is created.
 void setRetryLimit(int limit)
          Set the maximum number of retries that may be performed on a given operation when using connections created by this source.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SUPPORTS_UPDATES

public static final boolean DEFAULT_SUPPORTS_UPDATES
This source does not support udpates by default, but each instance may be configured to be read-only or updateable}.

See Also:
Constant Field Values

DEFAULT_RETRY_LIMIT

public static final int DEFAULT_RETRY_LIMIT
See Also:
Constant Field Values

DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS

public static final int DEFAULT_CACHE_TIME_TO_LIVE_IN_SECONDS
See Also:
Constant Field Values
Constructor Detail

FileSystemSource

public FileSystemSource()
Method Detail

getCapabilities

public RepositorySourceCapabilities getCapabilities()
Get the capabilities for this source.

Specified by:
getCapabilities in interface RepositorySource
Returns:
the capabilities for this source; never null
See Also:
RepositorySource.getCapabilities()

getName

public String getName()
Get the name for this repository source.

Specified by:
getName in interface RepositorySource
Returns:
the name; never null or empty
See Also:
RepositorySource.getName()

setName

public void setName(String name)
Set the name for the source

Parameters:
name - the new name for the source

getSupportsUpdates

public boolean getSupportsUpdates()
Get whether this source supports updates.

Returns:
true if this source supports updates, or false if this source only supports reading content.

getDirectoryForDefaultWorkspace

public String getDirectoryForDefaultWorkspace()
Get the file system path to the existing directory that should be used for the default workspace. If the default is specified as a null String or is not a valid and resolvable path, this source will consider the default to be the current working directory of this virtual machine, as defined by the new File(".").

Returns:
the file system path to the directory representing the default workspace, or null if the default should be the current working directory

setDirectoryForDefaultWorkspace

public void setDirectoryForDefaultWorkspace(String pathToDirectoryForDefaultWorkspace)
Set the file system path to the existing directory that should be used for the default workspace. If the default is specified as a null String or is not a valid and resolvable path, this source will consider the default to be the current working directory of this virtual machine, as defined by the new File(".").

Parameters:
pathToDirectoryForDefaultWorkspace - the valid and resolvable file system path to the directory representing the default workspace, or null if the current working directory should be used as the default workspace

getPredefinedWorkspaceNames

public String[] getPredefinedWorkspaceNames()
Gets the names of the workspaces that are available when this source is created. Each workspace name corresponds to a path to a directory on the file system.

Returns:
the names of the workspaces that this source starts with, or null if there are no such workspaces
See Also:
setPredefinedWorkspaceNames(String[]), setCreatingWorkspacesAllowed(boolean)

setPredefinedWorkspaceNames

public void setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)
Sets the names of the workspaces that are available when this source is created. Each workspace name corresponds to a path to a directory on the file system.

Parameters:
predefinedWorkspaceNames - the names of the workspaces that this source should start with, or null if there are no such workspaces
See Also:
setCreatingWorkspacesAllowed(boolean), getPredefinedWorkspaceNames()

isCreatingWorkspacesAllowed

public boolean isCreatingWorkspacesAllowed()
Get whether this source allows workspaces to be created dynamically.

Returns:
true if this source allows workspaces to be created by clients, or false if the set of workspaces is fixed
See Also:
setPredefinedWorkspaceNames(String[]), getPredefinedWorkspaceNames(), setCreatingWorkspacesAllowed(boolean)

setCreatingWorkspacesAllowed

public void setCreatingWorkspacesAllowed(boolean allowWorkspaceCreation)
Set whether this source allows workspaces to be created dynamically.

Parameters:
allowWorkspaceCreation - true if this source allows workspaces to be created by clients, or false if the set of workspaces is fixed
See Also:
setPredefinedWorkspaceNames(String[]), getPredefinedWorkspaceNames(), isCreatingWorkspacesAllowed()

getRetryLimit

public int getRetryLimit()
Get the maximum number of retries that may be performed on a given operation when using connections created by this source. This value does not constitute a minimum number of retries; in fact, the connection user is not required to retry any operations.

Specified by:
getRetryLimit in interface RepositorySource
Returns:
the maximum number of allowable retries, or 0 if the source has no limit
See Also:
RepositorySource.getRetryLimit()

setRetryLimit

public void setRetryLimit(int limit)
Set the maximum number of retries that may be performed on a given operation when using connections created by this source. This value does not constitute a minimum number of retries; in fact, the connection user is not required to retry any operations.

Specified by:
setRetryLimit in interface RepositorySource
Parameters:
limit - the maximum number of allowable retries, or 0 if the source has no limit
See Also:
RepositorySource.setRetryLimit(int)

getCacheTimeToLiveInMilliseconds

public int getCacheTimeToLiveInMilliseconds()
Get the time in milliseconds that content returned from this source may used while in the cache.

Returns:
the time to live, in milliseconds, or 0 if the time to live is not specified by this source

setCacheTimeToLiveInMilliseconds

public void setCacheTimeToLiveInMilliseconds(int cacheTimeToLive)
Set the time in milliseconds that content returned from this source may used while in the cache.

Parameters:
cacheTimeToLive - the time to live, in milliseconds; 0 if the time to live is not specified by this source; or a negative number for the default value

initialize

public void initialize(RepositoryContext context)
                throws RepositorySourceException
Initialize this source to use the supplied RepositoryContext, from which this source can obtain the configuration defining this source, connections to other sources, and the execution context.

This method may be called each time the configuration changes, allowing the source to update itself.

Specified by:
initialize in interface RepositorySource
Throws:
RepositorySourceException
See Also:
RepositorySource.initialize(org.jboss.dna.graph.connector.RepositoryContext)

getReference

public Reference getReference()

Specified by:
getReference in interface Referenceable
See Also:
Referenceable.getReference()

getObjectInstance

public Object getObjectInstance(Object obj,
                                Name name,
                                Context nameCtx,
                                Hashtable<?,?> environment)
                         throws Exception

Specified by:
getObjectInstance in interface ObjectFactory
Throws:
Exception

getConnection

public RepositoryConnection getConnection()
                                   throws RepositorySourceException
Get a connection from this source.

Specified by:
getConnection in interface RepositorySource
Returns:
a connection
Throws:
RepositorySourceException - if there is a problem obtaining a connection
See Also:
RepositorySource.getConnection()


Copyright © 2008-Present JBoss a division of Red Hat. All Rights Reserved.