org.modeshape.graph.connector.base
Class AbstractRepositorySource

java.lang.Object
  extended by org.modeshape.graph.connector.base.AbstractRepositorySource
All Implemented Interfaces:
Serializable, Referenceable, BaseRepositorySource, RepositorySource
Direct Known Subclasses:
AbstractNodeCachingRepositorySource

public abstract class AbstractRepositorySource
extends Object
implements BaseRepositorySource

Basic implementation of BaseRepositorySource, providing default implementations of the accessors and mutators in that interface.

See Also:
Serialized Form

Field Summary
protected  CachePolicy cachePolicy
           
static CachePolicy DEFAULT_CACHE_POLICY
          The default cache policy for this repository source (no caching)
static int DEFAULT_RETRY_LIMIT
          The default number of times that a request that failed due to system error should be retried
static String DEFAULT_ROOT_NODE_UUID
          The default UUID that is used for root nodes in a store.
protected  RepositoryContext repositoryContext
           
protected  int retryLimit
           
protected  UUID rootNodeUuid
           
 
Constructor Summary
AbstractRepositorySource()
           
 
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.
 CachePolicy getDefaultCachePolicy()
          Returns the cache policy for the repository source
 String getName()
          Get the name for this repository source.
 RepositoryContext getRepositoryContext()
          Returns the repository context for the repository source
 int getRetryLimit()
          Get the maximum number of retries that may be performed on a given operation when using connections created by this source.
 String getRootNodeUuid()
          Get the UUID of the root node for the cache.
 UUID getRootNodeUuidObject()
          Get the UUID for the root node.
 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.
 void setCachePolicy(CachePolicy cachePolicy)
          Sets the cache policy for the repository and replaces the path repository cache with a new path repository cache tied to the new cache policy
 void setName(String name)
          Sets the name of the repository source.
 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.
 void setRootNodeUuid(String rootNodeUuid)
          Set the UUID of the root node in this repository.
 void setRootNodeUuidObject(String rootNodeUuid)
           
protected  Map<String,Object> valuesFrom(Reference ref)
          Extracts the values from the given reference, automatically translating BinaryRefAddr instances into the deserialized classes that they represent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.modeshape.graph.connector.base.BaseRepositorySource
getDefaultWorkspaceName, setUpdatesAllowed
 
Methods inherited from interface org.modeshape.graph.connector.RepositorySource
getCapabilities, getConnection
 
Methods inherited from interface javax.naming.Referenceable
getReference
 

Field Detail

DEFAULT_ROOT_NODE_UUID

public static final String DEFAULT_ROOT_NODE_UUID
The default UUID that is used for root nodes in a store.

See Also:
Constant Field Values

DEFAULT_RETRY_LIMIT

public static final int DEFAULT_RETRY_LIMIT
The default number of times that a request that failed due to system error should be retried

See Also:
Constant Field Values

DEFAULT_CACHE_POLICY

public static final CachePolicy DEFAULT_CACHE_POLICY
The default cache policy for this repository source (no caching)


retryLimit

@Description(i18n=GraphI18n.class,
             value="retryLimitPropertyDescription")
@Label(i18n=GraphI18n.class,
       value="retryLimitPropertyLabel")
@Category(i18n=GraphI18n.class,
          value="retryLimitPropertyCategory")
protected int retryLimit

rootNodeUuid

@Description(i18n=GraphI18n.class,
             value="rootNodeUuidWithDefaultPropertyDescription")
@Label(i18n=GraphI18n.class,
       value="rootNodeUuidPropertyLabel")
@Category(i18n=GraphI18n.class,
          value="rootNodeUuidPropertyCategory")
protected transient UUID rootNodeUuid

repositoryContext

protected transient RepositoryContext repositoryContext

cachePolicy

protected transient CachePolicy cachePolicy
Constructor Detail

AbstractRepositorySource

public AbstractRepositorySource()
Method Detail

areUpdatesAllowed

public boolean areUpdatesAllowed()
Get whether this source allows updates.

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

isCreatingWorkspacesAllowed

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

Specified by:
isCreatingWorkspacesAllowed in interface BaseRepositorySource
Returns:
true if this source allows workspaces to be created by clients, or false if creating workspaces is not allowed
See Also:
BaseRepositorySource.isCreatingWorkspacesAllowed()

getRepositoryContext

public RepositoryContext getRepositoryContext()
Returns the repository context for the repository source

Specified by:
getRepositoryContext in interface BaseRepositorySource
Returns:
the repository context for the repository source
See Also:
BaseRepositorySource.getRepositoryContext()

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

getDefaultCachePolicy

public CachePolicy getDefaultCachePolicy()
Returns the cache policy for the repository source

Specified by:
getDefaultCachePolicy in interface BaseRepositorySource
Returns:
the cache policy for the repository source
See Also:
BaseRepositorySource.getDefaultCachePolicy()

setCachePolicy

public void setCachePolicy(CachePolicy cachePolicy)
Sets the cache policy for the repository and replaces the path repository cache with a new path repository cache tied to the new cache policy

Parameters:
cachePolicy - the new cache policy; may not be null

getRootNodeUuidObject

public UUID getRootNodeUuidObject()
Get the UUID for the root node.

Specified by:
getRootNodeUuidObject in interface BaseRepositorySource
Returns:
the root node's UUID; may not be null
See Also:
BaseRepositorySource.getRootNodeUuidObject()

setRootNodeUuidObject

public void setRootNodeUuidObject(String rootNodeUuid)
Parameters:
rootNodeUuid - Sets rootNodeUuid to the specified value.
Throws:
IllegalArgumentException - if the string value cannot be converted to UUID

getRootNodeUuid

public String getRootNodeUuid()
Get the UUID of the root node for the cache. If the cache exists, this UUID is not used but is instead set to the UUID of the existing root node.

Returns:
the UUID of the root node for the cache.

setRootNodeUuid

public void setRootNodeUuid(String rootNodeUuid)
Set the UUID of the root node in this repository. If the cache exists, this UUID is not used but is instead set to the UUID of the existing root node.

Parameters:
rootNodeUuid - the UUID of the root node for the cache, or null if the UUID should be randomly generated

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
See Also:
RepositorySource.close()

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)
Sets the name of the repository source. The name should be unique among loaded repository sources.

Parameters:
name - the new name for the repository source; may not be empty

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

valuesFrom

protected Map<String,Object> valuesFrom(Reference ref)
                                 throws IOException,
                                        ClassNotFoundException
Extracts the values from the given reference, automatically translating BinaryRefAddr instances into the deserialized classes that they represent.

Parameters:
ref - the reference from which the values should be extracted
Returns:
a map of value names to values from the reference
Throws:
IOException - if there is an error deserializing a BinaryRefAddr
ClassNotFoundException - if a serialized class cannot be deserialized because its class is not in the class path


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