org.norther.tammi.core.cache
Class DefaultKeyCacheClient

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.cache.DefaultCacheClient
          extended by org.norther.tammi.core.cache.DefaultKeyCacheClient
All Implemented Interfaces:
Serializable, EventListener, NotificationBroadcaster, NotificationEmitter, NotificationListener, Manageable, MBeanDelegate, Refreshable, CacheClient, KeyCacheClient

public class DefaultKeyCacheClient
extends DefaultCacheClient
implements KeyCacheClient

A default implementation of KeyCacheClient.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static String DEFAULT_CACHE_KEY_NAME
          The default cache key name in object names.
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultKeyCacheClient()
          Constructs a new client.
DefaultKeyCacheClient(String key)
          Constructs a new client with a cache key.
 
Method Summary
 Set cacheKeySet()
          Returns the cache key set.
 void clearCached()
          Clears all cached entries without notifying.
 void clearCaches()
          Removes all caches.
 void expireCached(long timestamp)
          Expires all cached entries notifying them about expiration.
 void expireFraction(long timestamp, float fraction)
          Expires the specified fraction of cached entries notifying them about expiration.
 ConcurrentMap getCache(String key, boolean create)
          Gets and optionally creates the cache for the specified key.
 void handleNotification(Notification notif, Object handback)
          Handle domain cache removals.
 void removeCache(String key)
          Removes the specified cache.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.cache.DefaultCacheClient
getCache, getClientCache, getExpired, getRefreshed, getSharedCache, isCachingDisabled, postmanaged, refresh, removeCache, setCachingDisabled
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.cache.CacheClient
getCache, isCachingDisabled, removeCache, setCachingDisabled
 
Methods inherited from interface org.norther.tammi.core.base.Refreshable
getRefreshed, refresh
 

Field Detail

DEFAULT_CACHE_KEY_NAME

public static final String DEFAULT_CACHE_KEY_NAME
The default cache key name in object names.

See Also:
Constant Field Values
Constructor Detail

DefaultKeyCacheClient

public DefaultKeyCacheClient()
Constructs a new client.


DefaultKeyCacheClient

public DefaultKeyCacheClient(String key)
Constructs a new client with a cache key.

Parameters:
key - the cache key to apply in object names.
Method Detail

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class DefaultCacheClient
Throws:
Exception - if the adaptee refused to be unmanaged.

expireCached

public void expireCached(long timestamp)
Description copied from interface: CacheClient
Expires all cached entries notifying them about expiration.

Specified by:
expireCached in interface CacheClient
Overrides:
expireCached in class DefaultCacheClient
Parameters:
timestamp - the timestamp of the expiration.

expireFraction

public void expireFraction(long timestamp,
                           float fraction)
Description copied from interface: CacheClient
Expires the specified fraction of cached entries notifying them about expiration.

Specified by:
expireFraction in interface CacheClient
Overrides:
expireFraction in class DefaultCacheClient
Parameters:
timestamp - the timestamp of the expiration.
fraction - the fraction of entries to expire (0.0..1.0).

clearCached

public void clearCached()
Description copied from interface: CacheClient
Clears all cached entries without notifying.

Specified by:
clearCached in interface CacheClient
Overrides:
clearCached in class DefaultCacheClient

getCache

public ConcurrentMap getCache(String key,
                              boolean create)
Description copied from interface: KeyCacheClient
Gets and optionally creates the cache for the specified key.

Specified by:
getCache in interface KeyCacheClient
Parameters:
key - the cache key.
create - true to create a missing cache.
Returns:
the cache or null if disabled.

removeCache

public void removeCache(String key)
Description copied from interface: KeyCacheClient
Removes the specified cache.

Specified by:
removeCache in interface KeyCacheClient
Parameters:
key - the cache key.

cacheKeySet

public Set cacheKeySet()
Description copied from interface: KeyCacheClient
Returns the cache key set.

Specified by:
cacheKeySet in interface KeyCacheClient
Returns:
the client key set.

clearCaches

public void clearCaches()
Description copied from interface: KeyCacheClient
Removes all caches.

Specified by:
clearCaches in interface KeyCacheClient

handleNotification

public void handleNotification(Notification notif,
                               Object handback)
Description copied from class: DefaultCacheClient
Handle domain cache removals.

Specified by:
handleNotification in interface NotificationListener
Overrides:
handleNotification in class DefaultCacheClient
Parameters:
notif - the notification.
handback - not used.


Copyright © 2004 The Norther Organization. All rights reserved.