org.jboss.dna.connector.jbosscache
Class JBossCacheWorkspaces

java.lang.Object
  extended by org.jboss.dna.connector.jbosscache.JBossCacheWorkspaces

@ThreadSafe
public class JBossCacheWorkspaces
extends Object

This class represents a set of workspaces used by the JBoss Cache connector.


Constructor Summary
JBossCacheWorkspaces(String sourceName, org.jboss.cache.CacheFactory<Name,Object> cacheFactory, String defaultCacheFactoryConfigurationName, Set<String> initialNames, Context jndiContext)
          Create a new instance of the workspace and cache manager for the JBoss Cache connector.
 
Method Summary
 org.jboss.cache.Cache<Name,Object> createWorkspace(String workspaceName)
          Attempt to create a new workspace with the supplied name.
 org.jboss.cache.Cache<Name,Object> getWorkspace(String workspaceName, boolean createIfMissing)
          Get the cache that corresponds to the supplied workspace name, and optionally create a new cache if no such cache already exists.
 Set<String> getWorkspaceNames()
          Return an immutable set of names for the currently available workspaces.
 boolean removeWorkspace(String workspaceName)
          Remove the cache that corresponds to the supplied workspace name as no longer being available.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JBossCacheWorkspaces

public JBossCacheWorkspaces(String sourceName,
                            org.jboss.cache.CacheFactory<Name,Object> cacheFactory,
                            String defaultCacheFactoryConfigurationName,
                            Set<String> initialNames,
                            Context jndiContext)
Create a new instance of the workspace and cache manager for the JBoss Cache connector.

Parameters:
sourceName - the name of the source that uses this object; may not be null
cacheFactory - the factory that should be used to create new caches; may not be null
defaultCacheFactoryConfigurationName - the name of the configuration that is supplied to the cache factory to create the new cache if the workspace name does not correspond to a configuration; may be null
initialNames - the initial names for the workspaces; may be null or empty
jndiContext - the JNDI context that should be used, or null if JNDI should not be used at all
Method Detail

createWorkspace

public org.jboss.cache.Cache<Name,Object> createWorkspace(String workspaceName)
Attempt to create a new workspace with the supplied name.

Parameters:
workspaceName - the name of the new workspace, which may be a valid URI if the cache is to be found in JNDI
Returns:
the new workspace, or null if there is already a workspace with the name

getWorkspace

public org.jboss.cache.Cache<Name,Object> getWorkspace(String workspaceName,
                                                       boolean createIfMissing)
Get the cache that corresponds to the supplied workspace name, and optionally create a new cache if no such cache already exists. This method first checks for Cache instances previously found for the same workspace name. If no cache is found, this method then checks whether the supplied workspace name is a valid URI, and if so the method looks for a Cache instance in JNDI at that URI. If none is found (or the name is not a valid URI), this method then creates a new Cache instance using the CacheFactory supplied in the constructor.

Parameters:
workspaceName - the name of the workspace, which may be a valid URI if the cache is to be found in JNDI
createIfMissing - true if the cache should be created if no such cache already exists
Returns:
the cache that corresponds to the workspace with the supplied name, or null if there is no cache for that workspace (and one could not be or was not created)

getWorkspaceNames

public Set<String> getWorkspaceNames()
Return an immutable set of names for the currently available workspaces.

Returns:
the immutable set of workspace names; never null

removeWorkspace

public boolean removeWorkspace(String workspaceName)
Remove the cache that corresponds to the supplied workspace name as no longer being available. This will remove the cache even if the workspace name is one of the "initial names" provided to this object's constructor.

Parameters:
workspaceName - the name of the existing workspace that is to be removed
Returns:
true if there was an existing workspace that was removed by this call, or false if there was no workspace with the supplied name


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