GemFire 5.5.1

com.gemstone.gemfire.cache
Class CacheFactory

java.lang.Object
  extended by com.gemstone.gemfire.cache.CacheFactory

public class CacheFactory
extends Object

A factory class that must be used to obtain instances of Cache.

To create a new cache instance use create(com.gemstone.gemfire.distributed.DistributedSystem).

To get the existing unclosed cache instance use getInstance(com.gemstone.gemfire.distributed.DistributedSystem).

An instance of DistributedSystem is required to obtain a cache instance from this factory. Because DistributedSystem only allows a single instance of itself per VM, you can only have a single open cache, per VM.

Since:
3.0

Method Summary
static Cache create(DistributedSystem system)
          Creates a new cache that uses the specified system.
static Cache getAnyInstance()
          Gets an arbitrary open instance of Cache produced by an earlier call to create(com.gemstone.gemfire.distributed.DistributedSystem).
static Cache getInstance(DistributedSystem system)
          Gets the instance of Cache produced by an earlier call to create(com.gemstone.gemfire.distributed.DistributedSystem).
static Cache getInstanceCloseOk(DistributedSystem system)
          Gets the instance of Cache produced by an earlier call to create(com.gemstone.gemfire.distributed.DistributedSystem) even if it has been closed.
static String getVersion()
          Returns the version of the cache implementation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Cache create(DistributedSystem system)
                    throws CacheExistsException,
                           TimeoutException,
                           CacheWriterException,
                           GatewayException,
                           RegionExistsException
Creates a new cache that uses the specified system.

The system can specify a "cache-xml-file" property which will cause this creation to also create the regions, objects, and attributes declared in the file. The contents of the file must comply with the "doc-files/cache5_0.dtd"> file. Note that when parsing the XML file Declarable classes are loaded using the current thread's context class loader.

Parameters:
system - a DistributedSystem obtained by calling DistributedSystem.connect(java.util.Properties).
Returns:
a Cache that uses the specified system for distribution.
Throws:
IllegalArgumentException - If system is not connected.
CacheExistsException - If an open cache already exists.
CacheXmlException - If a problem occurs while parsing the declarative caching XML file.
TimeoutException - If a Region.put(Object, Object) times out while initializing the cache.
CacheWriterException - If a CacheWriterException is thrown while initializing the cache.
GatewayException - If a GatewayException is thrown while initializing the cache.
RegionExistsException - If the declarative caching XML file desribes a region that already exists (including the root region).

getInstance

public static Cache getInstance(DistributedSystem system)
Gets the instance of Cache produced by an earlier call to create(com.gemstone.gemfire.distributed.DistributedSystem).

Parameters:
system - the DistributedSystem the cache was created with.
Returns:
the Cache associated with the specified system.
Throws:
CacheClosedException - if a cache has not been created or the created one is closed

getInstanceCloseOk

public static Cache getInstanceCloseOk(DistributedSystem system)
Gets the instance of Cache produced by an earlier call to create(com.gemstone.gemfire.distributed.DistributedSystem) even if it has been closed.

Parameters:
system - the DistributedSystem the cache was created with.
Returns:
the Cache associated with the specified system.
Throws:
CacheClosedException - if a cache has not been created
Since:
3.5

getAnyInstance

public static Cache getAnyInstance()
Gets an arbitrary open instance of Cache produced by an earlier call to create(com.gemstone.gemfire.distributed.DistributedSystem).

Throws:
CacheClosedException - if a cache has not been created or the only created one is closed

getVersion

public static String getVersion()
Returns the version of the cache implementation. For the 3.0 release of GemFire the string returned is "3.0".

Returns:
the version of the cache implementation as a String

GemFire 5.5.1

Copyright © 2002-2008 GemStone Systems, Inc. All Rights Reserved.