org.jboss.dna.connector.jbosscache
Class JBossCacheSource

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

@ThreadSafe
public class JBossCacheSource
extends Object
implements RepositorySource, ObjectFactory

A repository source that uses a JBoss Cache instance to manage the content. This source is capable of using an existing Cache instance or creating a new instance. This process is controlled entirely by the JavaBean properties of the JBossCacheSource instance.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

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

Author:
Randall Hauch
See Also:
Serialized Form

Field Summary
static int DEFAULT_RETRY_LIMIT
          The default limit is 0 for retrying connection calls to the underlying source.
static String DEFAULT_UUID_PROPERTY_NAME
           
 
Constructor Summary
JBossCacheSource()
          Create a repository source instance.
 
Method Summary
 boolean equals(Object obj)
          
 String getCacheConfigurationName()
          Get the name of the configuration that should be used if a cache is to be created using the CacheFactory found in JNDI or the DefaultCacheFactory if needed.
 String getCacheFactoryJndiName()
          Get the name in JNDI of a CacheFactory instance that should be used to create the cache for this source.
 String getCacheJndiName()
          Get the name in JNDI of a Cache instance that should be used by this source.
 RepositorySourceCapabilities getCapabilities()
          Get the capabilities for this source.
 RepositoryConnection getConnection()
          Get a connection from this source.
 CachePolicy getDefaultCachePolicy()
          Get the default cache policy for this source, or null if the global default cache policy should be used
 String getName()
          Get the name for this repository source.
 Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
          
 Reference getReference()
          
 RepositoryContext getRepositoryContext()
           
 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 of the root node for the cache.
 String getUuidPropertyName()
          Get the property name where the UUID is stored for each node.
 void initialize(RepositoryContext context)
          Initialize this source to use the supplied RepositoryContext, from which this source can obtain connections to other sources as well as execution contexts.
 void setCacheConfigurationName(String cacheConfigurationName)
          Get the name of the configuration that should be used if a cache is to be created using the CacheFactory found in JNDI or the DefaultCacheFactory if needed.
 void setCacheFactoryJndiName(String jndiName)
          Set the name in JNDI of a CacheFactory instance that should be used to obtain the Cache instance used by this source.
 void setCacheJndiName(String cacheJndiName)
          Set the name in JNDI of a Cache instance that should be used by this source.
 void setDefaultCachePolicy(CachePolicy defaultCachePolicy)
           
 void setName(String name)
          Set the name of this 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 setUuidPropertyName(String uuidPropertyName)
          Set the property name where the UUID is stored for each node.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RETRY_LIMIT

public static final int DEFAULT_RETRY_LIMIT
The default limit is 0 for retrying connection calls to the underlying source.

See Also:
Constant Field Values

DEFAULT_UUID_PROPERTY_NAME

public static final String DEFAULT_UUID_PROPERTY_NAME
Constructor Detail

JBossCacheSource

public JBossCacheSource()
Create a repository source instance.

Method Detail

initialize

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

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

getRepositoryContext

public RepositoryContext getRepositoryContext()
Returns:
repositoryContext

getName

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

Specified by:
getName in interface RepositorySource
Returns:
the name; never null or 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)

setName

public void setName(String name)
Set the name of this source

Parameters:
name - the name for this source

getDefaultCachePolicy

public CachePolicy getDefaultCachePolicy()
Get the default cache policy for this source, or null if the global default cache policy should be used

Returns:
the default cache policy, or null if this source has no explicit default cache policy

setDefaultCachePolicy

public void setDefaultCachePolicy(CachePolicy defaultCachePolicy)
Parameters:
defaultCachePolicy - Sets defaultCachePolicy to the specified value.

getCacheJndiName

public String getCacheJndiName()
Get the name in JNDI of a Cache instance that should be used by this source.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

Returns:
the JNDI name of the Cache instance that should be used, or null if the cache is to be created with a cache factory found in JNDI using the specified cache configuration name.
See Also:
setCacheJndiName(String), getCacheConfigurationName(), getCacheFactoryJndiName()

setCacheJndiName

public void setCacheJndiName(String cacheJndiName)
Set the name in JNDI of a Cache instance that should be used by this source.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

Parameters:
cacheJndiName - the JNDI name of the Cache instance that should be used, or null if the cache is to be created with a cache factory found in JNDI using the specified cache configuration name.
See Also:
getCacheJndiName(), getCacheConfigurationName(), getCacheFactoryJndiName()

getCacheFactoryJndiName

public String getCacheFactoryJndiName()
Get the name in JNDI of a CacheFactory instance that should be used to create the cache for this source.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

Returns:
the JNDI name of the CacheFactory instance that should be used, or null if the DefaultCacheFactory should be used if a cache is to be created
See Also:
setCacheFactoryJndiName(String), getCacheConfigurationName(), getCacheJndiName()

setCacheFactoryJndiName

public void setCacheFactoryJndiName(String jndiName)
Set the name in JNDI of a CacheFactory instance that should be used to obtain the Cache instance used by this source.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

Parameters:
jndiName - the JNDI name of the CacheFactory instance that should be used, or null if the DefaultCacheFactory should be used if a cache is to be created
See Also:
setCacheFactoryJndiName(String), getCacheConfigurationName(), getCacheJndiName()

getCacheConfigurationName

public String getCacheConfigurationName()
Get the name of the configuration that should be used if a cache is to be created using the CacheFactory found in JNDI or the DefaultCacheFactory if needed.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

Returns:
the name of the configuration that should be passed to the CacheFactory, or null if the default configuration should be used
See Also:
setCacheConfigurationName(String), getCacheFactoryJndiName(), getCacheJndiName()

setCacheConfigurationName

public void setCacheConfigurationName(String cacheConfigurationName)
Get the name of the configuration that should be used if a cache is to be created using the CacheFactory found in JNDI or the DefaultCacheFactory if needed.

This source first attempts to find an existing cache in JNDI. If none is found, then it attempts to create a cache instance using the CacheFactory found in JNDI (or the DefaultCacheFactory if no such factory is available) and the cache configuration name if supplied or the default configuration if not set.

Parameters:
cacheConfigurationName - the name of the configuration that should be passed to the CacheFactory, or null if the default configuration should be used
See Also:
getCacheConfigurationName(), getCacheFactoryJndiName(), getCacheJndiName()

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.

getRootNodeUuidObject

public UUID getRootNodeUuidObject()
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

getUuidPropertyName

public String getUuidPropertyName()
Get the property name where the UUID is stored for each node.

Returns:
the name of the UUID property; never null

setUuidPropertyName

public void setUuidPropertyName(String uuidPropertyName)
Set the property name where the UUID is stored for each node.

Parameters:
uuidPropertyName - the name of the UUID property, or null if the default name should be used

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

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

getReference

public Reference getReference()

Specified by:
getReference in interface Referenceable

getObjectInstance

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

Specified by:
getObjectInstance in interface ObjectFactory
Throws:
Exception

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


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