javax.cache
Enum CacheManagerFactory

java.lang.Object
  extended by java.lang.Enum<CacheManagerFactory>
      extended by javax.cache.CacheManagerFactory
All Implemented Interfaces:
Serializable, Comparable<CacheManagerFactory>

public enum CacheManagerFactory
extends Enum<CacheManagerFactory>

A factory for creating CacheManagers using the SPI conventions in the JDK's ServiceLoader For a provider to be discovered by the CacheManagerFactory, it's jar must contain a resource called:

   META-INF/services/javax.cache.spi.CacheManagerFactoryProvider
 
containing the class name implementing CacheManagerFactoryProvider e.g. For the reference implementation: "javax.cache.implementation.RIServiceFactory" The CacheManagerFactory also keeps track of all CacheManagers created by the factory. Subsequent calls to getCacheManager() return the same CacheManager.

Since:
1.7
Author:
Yannis Cosmadopoulos
See Also:
ServiceLoader, CacheManagerFactoryProvider

Enum Constant Summary
INSTANCE
          The singleton instance.
 
Field Summary
static String DEFAULT_CACHE_MANAGER_NAME
          The name of the default cache manager.
 
Method Summary
 CacheManager getCacheManager()
          Get the default cache manager.
 CacheManager getCacheManager(String name)
          Get a named cache manager.
static CacheManagerFactory valueOf(String name)
          Returns the enum constant of this type with the specified name.
static CacheManagerFactory[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

INSTANCE

public static final CacheManagerFactory INSTANCE
The singleton instance.

Field Detail

DEFAULT_CACHE_MANAGER_NAME

public static final String DEFAULT_CACHE_MANAGER_NAME
The name of the default cache manager. This is the name of the CacheManager returned when getCacheManager() is invoked. The default CacheManager is always created.

See Also:
Constant Field Values
Method Detail

values

public static CacheManagerFactory[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (CacheManagerFactory c : CacheManagerFactory.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static CacheManagerFactory valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

getCacheManager

public CacheManager getCacheManager()
Get the default cache manager. The default cache manager is named DEFAULT_CACHE_MANAGER_NAME

Returns:
the default cache manager
Throws:
IllegalStateException - if no CacheManagerFactoryProvider was found

getCacheManager

public CacheManager getCacheManager(String name)
Get a named cache manager. The first time a name is used, the cache manager will be created. Subsequent calls will return the same cache manager.

Parameters:
name - the name of this cache manager
Returns:
the new cache manager
Throws:
NullPointerException - if name is null
IllegalStateException - if no CacheManagerFactoryProvider was found


Copyright © 2011. All Rights Reserved.