org.apache.jcs.auxiliary.remote.http.client
Class RemoteHttpCacheClient<K extends Serializable,V extends Serializable>

java.lang.Object
  extended by org.apache.jcs.auxiliary.remote.http.client.RemoteHttpCacheClient<K,V>
All Implemented Interfaces:
Remote, IRemoteHttpCacheClient<K,V>, ICacheService<K,V>, ICacheServiceNonLocal<K,V>

public class RemoteHttpCacheClient<K extends Serializable,V extends Serializable>
extends Object
implements IRemoteHttpCacheClient<K,V>

This is the service used by the remote http auxiliary cache.


Constructor Summary
RemoteHttpCacheClient()
          For factory construction.
RemoteHttpCacheClient(RemoteHttpCacheAttributes attributes)
          Constructs a client.
 
Method Summary
 void dispose(String cacheName)
          Frees the specified cache.
 ICacheElement<K,V> get(String cacheName, K key)
          Create a request, process, extract the payload.
 ICacheElement<K,V> get(String cacheName, K key, long requesterId)
          Create a request, process, extract the payload.
 Set<K> getGroupKeys(String cacheName, String groupName)
          Gets the set of keys of objects currently in the group.
 Set<String> getGroupNames(String cacheName)
          Gets the set of group names in the cache
 Map<K,ICacheElement<K,V>> getMatching(String cacheName, String pattern)
          Gets multiple items from the cache matching the pattern.
 Map<K,ICacheElement<K,V>> getMatching(String cacheName, String pattern, long requesterId)
          Gets multiple items from the cache matching the pattern.
 Map<K,ICacheElement<K,V>> getMultiple(String cacheName, Set<K> keys)
          Gets multiple items from the cache based on the given set of keys.
 Map<K,ICacheElement<K,V>> getMultiple(String cacheName, Set<K> keys, long requesterId)
          Gets multiple items from the cache based on the given set of keys.
 IRemoteCacheDispatcher getRemoteDispatcher()
           
 RemoteHttpCacheAttributes getRemoteHttpCacheAttributes()
           
 void initialize(RemoteHttpCacheAttributes attributes)
          The provides an extension point.
 boolean isAlive()
          Make and alive request.
protected  boolean isInitialized()
           
 void release()
          Frees the specified cache.
 void remove(String cacheName, K key)
          Removes the given key from the specified cache.
 void remove(String cacheName, K key, long requesterId)
          Removes the given key from the specified cache.
 void removeAll(String cacheName)
          Remove all keys from the specified cache.
 void removeAll(String cacheName, long requesterId)
          Remove all keys from the sepcified cache.
protected  void setInitialized(boolean initialized)
           
 void setRemoteDispatcher(IRemoteCacheDispatcher remoteDispatcher)
           
 void setRemoteHttpCacheAttributes(RemoteHttpCacheAttributes remoteHttpCacheAttributes)
           
 void update(ICacheElement<K,V> item)
          Puts a cache item to the cache.
 void update(ICacheElement<K,V> cacheElement, long requesterId)
          Puts a cache item to the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteHttpCacheClient

public RemoteHttpCacheClient()
For factory construction.


RemoteHttpCacheClient

public RemoteHttpCacheClient(RemoteHttpCacheAttributes attributes)
Constructs a client.

Parameters:
attributes -
Method Detail

initialize

public void initialize(RemoteHttpCacheAttributes attributes)
The provides an extension point. If you want to extend this and use a special dispatcher, here is the place to do it.

Specified by:
initialize in interface IRemoteHttpCacheClient<K extends Serializable,V extends Serializable>
Parameters:
attributes -

get

public ICacheElement<K,V> get(String cacheName,
                              K key)
                                                                 throws IOException
Create a request, process, extract the payload.

Specified by:
get in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
key -
Returns:
ICacheElement
Throws:
IOException

get

public ICacheElement<K,V> get(String cacheName,
                              K key,
                              long requesterId)
                                                                 throws IOException
Create a request, process, extract the payload.

Specified by:
get in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
key -
requesterId -
Returns:
ICacheElement
Throws:
IOException

getMatching

public Map<K,ICacheElement<K,V>> getMatching(String cacheName,
                                             String pattern)
                                                                                                     throws IOException
Gets multiple items from the cache matching the pattern.

Specified by:
getMatching in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
pattern -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache matching the pattern.
Throws:
IOException

getMatching

public Map<K,ICacheElement<K,V>> getMatching(String cacheName,
                                             String pattern,
                                             long requesterId)
                                                                                                     throws IOException
Gets multiple items from the cache matching the pattern.

Specified by:
getMatching in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
pattern -
requesterId -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache matching the pattern.
Throws:
IOException

getMultiple

public Map<K,ICacheElement<K,V>> getMultiple(String cacheName,
                                             Set<K> keys)
                                                                                                     throws IOException
Gets multiple items from the cache based on the given set of keys.

Specified by:
getMultiple in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
keys -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
Throws:
IOException

getMultiple

public Map<K,ICacheElement<K,V>> getMultiple(String cacheName,
                                             Set<K> keys,
                                             long requesterId)
                                                                                                     throws IOException
Gets multiple items from the cache based on the given set of keys.

Specified by:
getMultiple in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
keys -
requesterId -
Returns:
a map of K key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
Throws:
IOException

remove

public void remove(String cacheName,
                   K key)
            throws IOException
Removes the given key from the specified cache.

Specified by:
remove in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
key -
Throws:
IOException

remove

public void remove(String cacheName,
                   K key,
                   long requesterId)
            throws IOException
Removes the given key from the specified cache.

Specified by:
remove in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
key -
requesterId -
Throws:
IOException

removeAll

public void removeAll(String cacheName)
               throws IOException
Remove all keys from the specified cache.

Specified by:
removeAll in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
Throws:
IOException

removeAll

public void removeAll(String cacheName,
                      long requesterId)
               throws IOException
Remove all keys from the sepcified cache.

Specified by:
removeAll in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
requesterId -
Throws:
IOException

update

public void update(ICacheElement<K,V> item)
            throws IOException
Puts a cache item to the cache.

Specified by:
update in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
item -
Throws:
IOException

update

public void update(ICacheElement<K,V> cacheElement,
                   long requesterId)
            throws IOException
Puts a cache item to the cache.

Specified by:
update in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheElement -
requesterId -
Throws:
IOException

dispose

public void dispose(String cacheName)
             throws IOException
Frees the specified cache.

Specified by:
dispose in interface ICacheService<K extends Serializable,V extends Serializable>
Parameters:
cacheName -
Throws:
IOException

release

public void release()
             throws IOException
Frees the specified cache.

Specified by:
release in interface ICacheService<K extends Serializable,V extends Serializable>
Throws:
IOException

getGroupKeys

public Set<K> getGroupKeys(String cacheName,
                           String groupName)
                                         throws IOException
Gets the set of keys of objects currently in the group.

Specified by:
getGroupKeys in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName - the name of the cache
groupName - the name of the group
Returns:
a Set of group keys.
Throws:
IOException

getGroupNames

public Set<String> getGroupNames(String cacheName)
                          throws IOException
Gets the set of group names in the cache

Specified by:
getGroupNames in interface ICacheServiceNonLocal<K extends Serializable,V extends Serializable>
Parameters:
cacheName - the name of the cache
Returns:
a Set of group names.
Throws:
IOException

isAlive

public boolean isAlive()
                throws IOException
Make and alive request.

Specified by:
isAlive in interface IRemoteHttpCacheClient<K extends Serializable,V extends Serializable>
Returns:
true if we make a successful alive request.
Throws:
IOException

setRemoteDispatcher

public void setRemoteDispatcher(IRemoteCacheDispatcher remoteDispatcher)
Parameters:
remoteDispatcher - the remoteDispatcher to set

getRemoteDispatcher

public IRemoteCacheDispatcher getRemoteDispatcher()
Returns:
the remoteDispatcher

setRemoteHttpCacheAttributes

public void setRemoteHttpCacheAttributes(RemoteHttpCacheAttributes remoteHttpCacheAttributes)
Parameters:
remoteHttpCacheAttributes - the remoteHttpCacheAttributes to set

getRemoteHttpCacheAttributes

public RemoteHttpCacheAttributes getRemoteHttpCacheAttributes()
Returns:
the remoteHttpCacheAttributes

setInitialized

protected void setInitialized(boolean initialized)
Parameters:
initialized - the initialized to set

isInitialized

protected boolean isInitialized()
Returns:
the initialized


Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.