org.modeshape.connector.disk
Class DiskSource

java.lang.Object
  extended by org.modeshape.graph.connector.base.AbstractRepositorySource
      extended by org.modeshape.graph.connector.base.AbstractNodeCachingRepositorySource<UUID,DiskNode>
          extended by org.modeshape.connector.disk.DiskSource
All Implemented Interfaces:
Serializable, Referenceable, ObjectFactory, BaseRepositorySource, RepositorySource

@ThreadSafe
public class DiskSource
extends AbstractNodeCachingRepositorySource<UUID,DiskNode>
implements ObjectFactory

A repository source that uses a uses a disk to store arbitrary content. Unlike the FileSystemSource, this connector can store arbitrary content and is not limited to storing nodes of type nt:folder, nt:file, and nt:resource. However, content stored by this connector is not intended to be accessible to other applications unless they integrate with ModeShape to read the data.

Nodes created by this source are assigned a UUID and mapped to a system of folders and subfolders based on this UUID.

Like other RepositorySource classes, instances of DiskSource can be placed into JNDI and do support the creation of JNDI referenceable objects and resolution of references into DiskSource.

See Also:
Serialized Form

Field Summary
static boolean DEFAULT_LOCK_FILE_USED
          The initial value for whether a lock file is used is "false ", unless otherwise specified.
static String DEFAULT_NAME_OF_DEFAULT_WORKSPACE
          The initial name of the default workspace is ""default" ", unless otherwise specified.
static String DEFAULT_REPOSITORY_ROOT_PATH
          The initial value for where content should be stored on disk is ""/tmp" ", unless otherwise specified.
static boolean DEFAULT_UPDATES_ALLOWED
          The initial value for whether updates are allowed is "true ", unless otherwise specified.
 
Fields inherited from class org.modeshape.graph.connector.base.AbstractNodeCachingRepositorySource
DEFAULT_NODE_CACHE_POLICY, NODE_CACHE_POLICY
 
Fields inherited from class org.modeshape.graph.connector.base.AbstractRepositorySource
cachePolicy, DEFAULT_CACHE_POLICY, DEFAULT_RETRY_LIMIT, DEFAULT_ROOT_NODE_UUID, retryLimit, rootNodeUuid
 
Constructor Summary
DiskSource()
          Create a repository source instance.
 
Method Summary
 boolean areUpdatesAllowed()
          Get whether this source allows updates.
 void close()
          Signal this source that it is no longer needed and should begin the process of reclaiming or closing all resources that it has acquired.
 boolean equals(Object obj)
          
 RepositorySourceCapabilities getCapabilities()
          Get the capabilities for this source.
 RepositoryConnection getConnection()
          Get a connection from this source.
protected  Context getContext()
           
 String getDefaultWorkspaceName()
          Get the name of the default workspace.
 String getLargeValuePath()
           
 long getLargeValueSizeInBytes()
           
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          
protected  Observer getObserver()
           
 String[] getPredefinedWorkspaceNames()
          Gets the names of the workspaces that are available when this source is created.
 Reference getReference()
          
 String getRepositoryRootPath()
           
 int hashCode()
           
 boolean isCreatingWorkspacesAllowed()
          Get whether this source allows workspaces to be created dynamically.
 boolean isLockFileUsed()
           
protected  void setContext(Context context)
           
 void setCreatingWorkspacesAllowed(boolean allowWorkspaceCreation)
          Set whether this source allows workspaces to be created dynamically.
 void setDefaultWorkspaceName(String nameOfDefaultWorkspace)
          Set the name of the workspace that should be used when clients don't specify a workspace.
 void setLargeValuePath(String largeValuePath)
           
 void setLargeValueSizeInBytes(long largeValueSizeInBytes)
           
 void setLockFileUsed(boolean lockFileUsed)
           
 void setPredefinedWorkspaceNames(String[] predefinedWorkspaceNames)
          Sets the names of the workspaces that are available when this source is created.
 void setRepositoryRootPath(String repositoryRootPath)
          Set the the path to the root of the repository on disk.
 void setUpdatesAllowed(boolean updatesAllowed)
          Set whether this source allows updates to data within workspaces
 
Methods inherited from class org.modeshape.graph.connector.base.AbstractNodeCachingRepositorySource
addNodeCachePolicyChangedListener, addNodeCachePolicyReference, getNodeCachePolicy, removeNodeCachePolicyChangedListener, setNodeCachePolicy
 
Methods inherited from class org.modeshape.graph.connector.base.AbstractRepositorySource
getDefaultCachePolicy, getName, getRepositoryContext, getRetryLimit, getRootNodeUuid, getRootNodeUuidObject, initialize, setCachePolicy, setName, setRetryLimit, setRootNodeUuid, setRootNodeUuidObject, valuesFrom
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAME_OF_DEFAULT_WORKSPACE

public static final String DEFAULT_NAME_OF_DEFAULT_WORKSPACE
The initial name of the default workspace is ""default" ", unless otherwise specified.

See Also:
Constant Field Values

DEFAULT_UPDATES_ALLOWED

public static final boolean DEFAULT_UPDATES_ALLOWED
The initial value for whether updates are allowed is "true ", unless otherwise specified.

See Also:
Constant Field Values

DEFAULT_REPOSITORY_ROOT_PATH

public static final String DEFAULT_REPOSITORY_ROOT_PATH
The initial value for where content should be stored on disk is ""/tmp" ", unless otherwise specified.

See Also:
Constant Field Values

DEFAULT_LOCK_FILE_USED

public static final boolean DEFAULT_LOCK_FILE_USED
The initial value for whether a lock file is used is "false ", unless otherwise specified.

See Also:
Constant Field Values
Constructor Detail

DiskSource

public DiskSource()
Create a repository source instance.

Method Detail

getRepositoryRootPath

public String getRepositoryRootPath()
Returns:
the path to the root of the repository on disk. This path must be (at least) readable.

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()

setRepositoryRootPath

public void setRepositoryRootPath(String repositoryRootPath)
Set the the path to the root of the repository on disk. This path must be (at least) readable.

Parameters:
repositoryRootPath - the path to the root of the repository on disk. This path must be (at least) readable.

getDefaultWorkspaceName

public String getDefaultWorkspaceName()
Get the name of the default workspace.

Specified by:
getDefaultWorkspaceName in interface BaseRepositorySource
Returns:
the name of the workspace that should be used by default; never null

setDefaultWorkspaceName

public void setDefaultWorkspaceName(String nameOfDefaultWorkspace)
Set the name of the workspace that should be used when clients don't specify a workspace.

Parameters:
nameOfDefaultWorkspace - the name of the workspace that should be used by default, or null if the default name should be used

getPredefinedWorkspaceNames

public String[] getPredefinedWorkspaceNames()
Gets the names of the workspaces that are available when this source is created.

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.

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()

getLargeValueSizeInBytes

public long getLargeValueSizeInBytes()
Returns:
largeValueSizeInBytes

setLargeValueSizeInBytes

public void setLargeValueSizeInBytes(long largeValueSizeInBytes)
Parameters:
largeValueSizeInBytes - Sets largeValueSizeInBytes to the specified value.

getLargeValuePath

public String getLargeValuePath()
Returns:
largeValuePath

setLargeValuePath

public void setLargeValuePath(String largeValuePath)
Parameters:
largeValuePath - Sets largeValuePath to the specified value.

isCreatingWorkspacesAllowed

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

Specified by:
isCreatingWorkspacesAllowed in interface BaseRepositorySource
Overrides:
isCreatingWorkspacesAllowed in class AbstractRepositorySource
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()

close

public void close()
Signal this source that it is no longer needed and should begin the process of reclaiming or closing all resources that it has acquired. Because connections may still be in use, this method may not necessarily close all resources immediately.

This is a required method, and must be called when this source is no longer needed if one or more connections have been obtained since the previous call to this method.

Note that calling this method also does not preclude obtaining more connections after this method is called. If that happens, this source should simply reacquire any resources necessary to provide additional connections, and this method needs to be called once again.

Specified by:
close in interface RepositorySource
Overrides:
close in class AbstractRepositorySource
See Also:
RepositorySource.close()

getObserver

protected Observer getObserver()

getContext

protected Context getContext()

setContext

protected void setContext(Context context)

areUpdatesAllowed

public boolean areUpdatesAllowed()
Description copied from class: AbstractRepositorySource
Get whether this source allows updates.

Specified by:
areUpdatesAllowed in interface BaseRepositorySource
Overrides:
areUpdatesAllowed in class AbstractRepositorySource
Returns:
true if this source allows updates by clients, or false if no updates are allowed
See Also:
BaseRepositorySource.areUpdatesAllowed()

setUpdatesAllowed

public void setUpdatesAllowed(boolean updatesAllowed)
Description copied from interface: BaseRepositorySource
Set whether this source allows updates to data within workspaces

Specified by:
setUpdatesAllowed in interface BaseRepositorySource
Parameters:
updatesAllowed - true if this source allows updates to data within workspaces clients, or false if updates are not allowed.
See Also:
BaseRepositorySource.areUpdatesAllowed()

isLockFileUsed

public boolean isLockFileUsed()
Returns:
whether a lock file should be used

setLockFileUsed

public void setLockFileUsed(boolean lockFileUsed)
Parameters:
lockFileUsed - whether a lock file should be used to coordinate repository locks across JVMs

getConnection

public RepositoryConnection getConnection()
                                   throws RepositorySourceException
Get a connection from this source. Even though each RepositorySource need not be thread safe, this method should be safe to be called concurrently by multiple threads.

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

getReference

public Reference getReference()

Specified by:
getReference in interface Referenceable

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getObjectInstance

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

Specified by:
getObjectInstance in interface ObjectFactory
Throws:
Exception


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