Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.connector.jbosscache
Class JBossCacheSource

    java.lang.Object
      org.modeshape.connector.jbosscache.JBossCacheSource

All Implemented Interfaces:
  Serializable, Referenceable, ObjectFactory, BaseRepositorySource, RepositorySource

    @ThreadSafe
    public class JBossCacheSource

extends Object
implements BaseRepositorySource, 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.

See Also:
  Serialized Form

Field Summary
`protected static String` | `ALLOW_CREATING_WORKSPACES`
`protected static String` | `CACHE_CONFIGURATION_NAME`
`protected static String` | `CACHE_FACTORY_JNDI_NAME`
`protected static String` | `CACHE_JNDI_NAME`
`protected static String` | `DEFAULT_CACHE_POLICY`
`static String` | `DEFAULT_NAME_OF_DEFAULT_WORKSPACE` The initial `name of the default workspace` is ""default" ", unless otherwise specified.
`static int` | `DEFAULT_RETRY_LIMIT` The default limit is 0 for retrying `connection` calls to the underlying source.
`static boolean` | `DEFAULT_UPDATES_ALLOWED` The initial value for whether updates are allowed is "true ", unless otherwise specified.
`static String` | `DEFAULT_UUID_PROPERTY_NAME`
`protected static String` | `DEFAULT_WORKSPACE`
`protected static String` | `PREDEFINED_WORKSPACE_NAMES`
`protected static String` | `RETRY_LIMIT`
`protected static String` | `ROOT_NODE_UUID`
`protected static String` | `SOURCE_NAME`
`protected static String` | `UPDATES_ALLOWED`

Constructor Summary
`JBossCacheSource()` 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.
`protected org.jboss.cache.Cache<UUID,JBossCacheNode>` | `createNewCache(org.jboss.cache.CacheFactory<UUID,JBossCacheNode> cacheFactory, String repositoryName)` Method that is responsible for attempting to create a new cache given the supplied workspace name.
`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.
`protected Context` | `getContext()`
`CachePolicy` | `getDefaultCachePolicy()` Get the default cache policy for this source, or null if the global default cache policy should be used
`String` | `getDefaultWorkspaceName()` Get the name of the default workspace.
`String` | `getName()` Get the name for this repository source.
`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()`
`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 of the root node for the cache.
`int` | `hashCode()`
`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` | `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.
`protected void` | `setContext(Context context)`
`void` | `setCreatingWorkspacesAllowed(boolean allowWorkspaceCreation)` Set whether this source allows workspaces to be created dynamically.
`void` | `setDefaultCachePolicy(CachePolicy defaultCachePolicy)`
`void` | `setDefaultWorkspaceName(String nameOfDefaultWorkspace)` Set the name of the workspace that should be used when clients don't specify a workspace.
`void` | `setName(String name)` Set the name of this 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.
`void` | `setRootNodeUuid(String rootNodeUuid)` Set the UUID of the root node in this repository.
`void` | `setUpdatesAllowed(boolean updatesAllowed)` Set whether this source allows updates to data within workspaces

Methods inherited from class java.lang.Object
`clone, finalize, getClass, 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

### 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

### ROOT_NODE_UUID

    protected static final String ROOT_NODE_UUID

See Also:
  Constant Field Values

### SOURCE_NAME

    protected static final String SOURCE_NAME

See Also:
  Constant Field Values

### DEFAULT_CACHE_POLICY

    protected static final String DEFAULT_CACHE_POLICY

See Also:
  Constant Field Values

### CACHE_CONFIGURATION_NAME

    protected static final String CACHE_CONFIGURATION_NAME

See Also:
  Constant Field Values

### CACHE_FACTORY_JNDI_NAME

    protected static final String CACHE_FACTORY_JNDI_NAME

See Also:
  Constant Field Values

### CACHE_JNDI_NAME

    protected static final String CACHE_JNDI_NAME

See Also:
  Constant Field Values

### RETRY_LIMIT

    protected static final String RETRY_LIMIT

See Also:
  Constant Field Values

### DEFAULT_WORKSPACE

    protected static final String DEFAULT_WORKSPACE

See Also:
  Constant Field Values

### PREDEFINED_WORKSPACE_NAMES

    protected static final String PREDEFINED_WORKSPACE_NAMES

See Also:
  Constant Field Values

### ALLOW_CREATING_WORKSPACES

    protected static final String ALLOW_CREATING_WORKSPACES

See Also:
  Constant Field Values

### UPDATES_ALLOWED

    protected static final String UPDATES_ALLOWED

See Also:
  Constant Field Values

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 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.modeshape.graph.connector.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

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

### 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

  Specified by:
    `getDefaultCachePolicy` in interface `BaseRepositorySource`
  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.

  Specified by:
    `getRootNodeUuidObject` in interface `BaseRepositorySource`
  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

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

### isCreatingWorkspacesAllowed

    @Description(i18n=JBossCacheConnectorI18n.class,
                 value="creatingWorkspacesAllowedPropertyDescription")
    @Label(i18n=JBossCacheConnectorI18n.class,
           value="creatingWorkspacesAllowedPropertyLabel")
    @Category(i18n=JBossCacheConnectorI18n.class,
              value="creatingWorkspacesAllowedPropertyCategory")
    public boolean isCreatingWorkspacesAllowed()

  Get whether this source allows workspaces to be created dynamically.

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

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

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

### createNewCache

    protected org.jboss.cache.Cache<UUID,JBossCacheNode> createNewCache(org.jboss.cache.CacheFactory<UUID,JBossCacheNode> cacheFactory,
                                                                        String repositoryName)

  Method that is responsible for attempting to create a new cache given the supplied workspace name. Note that this is probably called at most once for each workspace name (except if this method fails to create a cache for a given workspace name).

  Parameters:
    `cacheFactory` - the cache factory
    `repositoryName` - the name of the repository
  Returns:
    the new cache that corresponds to the workspace name

### getRepositoryContext

    public RepositoryContext getRepositoryContext()

  Description copied from interface: `BaseRepositorySource`
  Returns the `repository context` for the repository source

  Specified by:
    `getRepositoryContext` in interface `BaseRepositorySource`
  Returns:
    repositoryContext

### getObserver

    protected Observer getObserver()

### getContext

    protected Context getContext()

### setContext

    protected void setContext(Context context)

### areUpdatesAllowed

    public boolean areUpdatesAllowed()

  Description copied from interface: `BaseRepositorySource`
  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.setUpdatesAllowed(boolean)`

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

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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