|
Oracle Fusion Middleware Java API Reference for Oracle WebCenter Portal 11g Release 1 (11.1.1.6.0) E15995-05 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.wcps.cache.CacheFactory
public abstract class CacheFactory
Factory to create/retrieve Singleton Cache
objects.
There are two types of caches - normal caches and local caches.
Normal caches may (or may not) be remote or external to this VM (and are thus also externally managed). As the cached objects are often held remotely, these caches require the keys and values that they hold to be Serializable
. The principal/preferred implementation for these caches is Coherence.
Local caches are based on local in-memory Maps, and thus do not have any remote capability, etc. So local caches do not have any serializable restrictions.
To use Coherence caches, the Coherence classes must be accessible via the same ClassLoader where this CacheFactory class is loaded. Also, a cache-config file named factoryName-coherence-cache-config.xml
must also be accessible via the same loader (where factoryName is the argument to getInstance, and the file conforms to cache-config.dtd
) . If Coherence is not available, the configuration file is not found, or there are problems in loading the configuration, then local caches will be used.
Each Coherence-backed CacheFactory will construct a DefaultConfigurableCacheFactory with the factoryName-coherence-cache-config.xml
as a parameter. Note that, in an application with multiple cache factory names, a tangasol-coherence-override.xml
file will likely be required to specify service-type names for each service in the cache-config file. This is necessary to keep the caches and their configurations separate from each other. For example, if you have one factoryName=wcps which uses a local-scheme with the default service-name, and a factoryName=foo which also uses a local-scheme, then foo's local-service will probably need a unique service-name and that service-type will need to be defined in a tangasol-coherence-override.xml
file. See the Coherence documentation for more information.
It may also be advisable to use something like WebLogic's prefer-application-resources in your Ear's weblogic-application.xml
descriptor in order to isolate configuration for your application from other applications (and the server's classpath). For example:
<prefer-application-resources> <resource-name>wcps-coherence-cache-config.xml</resource-name> <resource-name>foo-coherence-cache-config.xml</resource-name> <resource-name>tangosol-coherence-override.xml</resource-name> </prefer-application-resources>
The above assumes that the caches are configured per-ear, and that the named resources (config files) are accessible via the ear's classloader, for example APP-INF/classes/wcps-coherence-cache-config.xml
.
Caches have their configuration exposed via CacheConfig
, although regular caches may not obey any of the configuration settings, as they are intended to be managed externally. Local caches always observe configuration changes.
CacheConfig is a JMX MXBean, so management of caches (especially local caches) can be done via jconsole (for example). The MBean ObjectName is oracle.wcps.cache:name=factoryName.cacheName
If the system property oracle.wcps.cache.forceLocalCaches is set to true (before the first use of this class), then all caches will be forced to be local, regardless of any other configuration.
If the system property oracle.wcps.cache.localCachesInactive is set to true, the default initial value for the isActive attribute for local caches will be false.
To disable caching system-wide, set both oracle.wcps.cache.forceLocalCaches and oracle.wcps.cache.localCachesInactive to true (and don't change the cache isActive property after that via code or via JMX).
Field Summary | |
---|---|
static java.lang.String |
FORCE_LOCAL_CACHES system property - set to true to force use of local caches system-wide |
static java.lang.String |
LOCAL_CACHES_INACTIVE System property - set to true to disable all local caches system-wide. |
protected CacheFactory |
localInstance |
static java.lang.String |
MBEAN_BASE_NAME CacheConfig ObjectName in the platform mbean server is MBEAN_BASE_NAME + factoryName.cacheName (oracle.wcps.cache:name=factoryName.cacheName) factoryName is the arg to CacheFactory.getInstance(factoryName) cacheName is the name of the cache. |
Constructor Summary | |
---|---|
protected |
CacheFactory(java.lang.String factoryName) |
Method Summary | ||
---|---|---|
boolean |
cacheExists(java.lang.String name) Is this cache name known. |
|
protected abstract Cache<?,?> |
createCache(java.lang.String name) |
|
Cache<? extends java.io.Serializable,? extends java.io.Serializable> |
getCache(java.lang.String name) Create or access an existing Cache . |
|
|
getCache(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType) Create or retrieve a cache. |
|
java.util.Set<java.lang.String> |
getCacheNames() Return all known caches that have been accessed by this instance's getCache method. |
|
static CacheFactory |
getInstance(java.lang.String factoryName) Return the named cache factory instance. |
|
Cache<?,?> |
getLocalCache(java.lang.String name) Create or access an existing LOCAL Cache . |
|
|
getLocalCache(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType) Create or retrieve a local cache. |
|
java.util.Set<java.lang.String> |
getLocalCacheNames() Return all local caches that have been created by this instance's getLocalCache method. |
|
java.lang.String |
getName() |
|
abstract boolean |
isLocal() Returns true if the caches are all local. |
|
boolean |
localCacheExists(java.lang.String name) Is this local cache name known. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MBEAN_BASE_NAME
public static final java.lang.String FORCE_LOCAL_CACHES
public static final java.lang.String LOCAL_CACHES_INACTIVE
protected final CacheFactory localInstance
Constructor Detail |
---|
protected CacheFactory(java.lang.String factoryName)
Method Detail |
---|
public static final CacheFactory getInstance(java.lang.String factoryName)
public final java.lang.String getName()
protected abstract Cache<?,?> createCache(java.lang.String name)
public abstract boolean isLocal()
public final boolean cacheExists(java.lang.String name)
public final boolean localCacheExists(java.lang.String name)
public final Cache<? extends java.io.Serializable,? extends java.io.Serializable> getCache(java.lang.String name)
Cache
. Will never return null, will always return some instance of a cache.
If the named cache exists already in the CacheFactory's collection (eg, it has been created by a previous call to CacheFactory.getCache()), then that same cache instance will be returned.
name
- the name of the cache to create or retrievejava.lang.IllegalArgumentException
- if a LOCAL cache with this name already existspublic final Cache<?,?> getLocalCache(java.lang.String name)
Cache
. Will never return null, will always return some instance of a cache.
If the named cache exists already in the CacheFactory's collection (eg, it has been created by a previous call to CacheFactory.getLocalCache()), then that same cache instance will be returned.
name
- the name of the local cache to create or retrievejava.lang.IllegalArgumentException
- if a Serializable cache with this name already existspublic final <K extends java.io.Serializable,V extends java.io.Serializable> Cache<K,V> getCache(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
The resulting cache will not be type safe (checked) - this is simply a convenience to allow you to avoid excess generic-related casts in your code.
K
- key typeV
- value typename
- cache namekeyType
- key type class objectvalueType
- value type class objectjava.lang.IllegalArgumentException
- if a LOCAL cache with this name already existspublic final <K,V> Cache<K,V> getLocalCache(java.lang.String name, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
The resulting cache will not be type safe (checked) - this is simply a convenience to allow you to avoid excess generic-related casts in your code.
K
- key typeV
- value typename
- cache namekeyType
- key type class objectvalueType
- value type class objectjava.lang.IllegalArgumentException
- if a Serializable cache with this name already existspublic java.util.Set<java.lang.String> getCacheNames()
public java.util.Set<java.lang.String> getLocalCacheNames()
|
Oracle Fusion Middleware Java API Reference for Oracle WebCenter Portal 11g Release 1 (11.1.1.6.0) E15995-05 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |