org.apache.servicemix.store.ehcache
Class EhCacheStore

java.lang.Object
  extended by org.apache.servicemix.store.base.BaseStore
      extended by org.apache.servicemix.store.ehcache.EhCacheStore
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, net.sf.ehcache.event.CacheEventListener, Store

public class EhCacheStore
extends BaseStore
implements net.sf.ehcache.event.CacheEventListener

EhCache Store.

Note: The current implementation always "removes" expired items.

Author:
n.dimos
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.servicemix.store.base.BaseStore
storeListeners
 
Fields inherited from interface org.apache.servicemix.store.Store
CLUSTERED, PERSISTENT, TRANSACTIONAL
 
Constructor Summary
EhCacheStore(net.sf.ehcache.Cache cache, IdGenerator idGenerator, java.lang.String name)
           
 
Method Summary
 java.lang.Object clone()
           
 void destroy()
           
 void dispose()
           
 net.sf.ehcache.Cache getCache()
           
 IdGenerator getIdGenerator()
           
 java.lang.String getName()
           
 boolean hasFeature(java.lang.String feature)
           Returns true if feature is provided by the store (clustered), false else.
 java.lang.Object load(java.lang.String id)
           Loads an object that has been previously stored under the specified key.
 void notifyElementEvicted(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
           
 void notifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
           
 void notifyElementPut(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
           
 void notifyElementRemoved(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
           
 void notifyElementUpdated(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
           
 void notifyRemoveAll(net.sf.ehcache.Ehcache cache)
           
 java.lang.Object peek(java.lang.String id)
           Loads an object that has been previously stored under the specified key.
 void setCache(net.sf.ehcache.Cache cache)
           
 void setIdGenerator(IdGenerator idGenerator)
           
 void setName(java.lang.String name)
           
 java.lang.String store(java.lang.Object data)
           Put an object into the store and return the unique id that may be used at a later time to retrieve the object.
 void store(java.lang.String id, java.lang.Object data)
           Put an object in the store under the given id.
 
Methods inherited from class org.apache.servicemix.store.base.BaseStore
addListener, fireAddedEvent, fireEvictedEvent, fireRemovedEvent, getStoreListeners, removeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EhCacheStore

public EhCacheStore(net.sf.ehcache.Cache cache,
                    IdGenerator idGenerator,
                    java.lang.String name)
Method Detail

hasFeature

public boolean hasFeature(java.lang.String feature)

Returns true if feature is provided by the store (clustered), false else.

Specified by:
hasFeature in interface Store
Parameters:
feature - the feature.
Returns:
true if the given feature is provided by the store, false else.

destroy

public void destroy()
             throws java.lang.Exception
Throws:
java.lang.Exception

store

public void store(java.lang.String id,
                  java.lang.Object data)
           throws java.io.IOException

Put an object in the store under the given id. This method must be used with caution and the behavior is unspecified if an object already exist for the same id.

Specified by:
store in interface Store
Parameters:
id - the id of the object to store
data - the object to store
Throws:
java.io.IOException - if an error occurs

store

public java.lang.String store(java.lang.Object data)
                       throws java.io.IOException

Put an object into the store and return the unique id that may be used at a later time to retrieve the object.

Specified by:
store in interface Store
Parameters:
data - the object to store
Returns:
the id of the object stored
Throws:
java.io.IOException - if an error occurs

load

public java.lang.Object load(java.lang.String id)
                      throws java.io.IOException

Loads an object that has been previously stored under the specified key. The object is removed from the store.

Specified by:
load in interface Store
Parameters:
id - the id of the object
Returns:
the object, or null> if the object could not be found
Throws:
java.io.IOException - if an error occurs

peek

public java.lang.Object peek(java.lang.String id)
                      throws java.io.IOException

Loads an object that has been previously stored under the specified key. The object is not removed from the store.

Specified by:
peek in interface Store
Parameters:
id - the id of the object
Returns:
the object, or null if the object could not be found
Throws:
java.io.IOException - if an error occurs

notifyElementPut

public void notifyElementPut(net.sf.ehcache.Ehcache cache,
                             net.sf.ehcache.Element element)
                      throws net.sf.ehcache.CacheException
Specified by:
notifyElementPut in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementUpdated

public void notifyElementUpdated(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)
                          throws net.sf.ehcache.CacheException
Specified by:
notifyElementUpdated in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementExpired

public void notifyElementExpired(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)
Specified by:
notifyElementExpired in interface net.sf.ehcache.event.CacheEventListener

notifyElementEvicted

public void notifyElementEvicted(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)
Specified by:
notifyElementEvicted in interface net.sf.ehcache.event.CacheEventListener

notifyRemoveAll

public void notifyRemoveAll(net.sf.ehcache.Ehcache cache)
Specified by:
notifyRemoveAll in interface net.sf.ehcache.event.CacheEventListener

dispose

public void dispose()
Specified by:
dispose in interface net.sf.ehcache.event.CacheEventListener

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface net.sf.ehcache.event.CacheEventListener
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

notifyElementRemoved

public void notifyElementRemoved(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)
                          throws net.sf.ehcache.CacheException
Specified by:
notifyElementRemoved in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

getCache

public net.sf.ehcache.Cache getCache()

setCache

public void setCache(net.sf.ehcache.Cache cache)

getIdGenerator

public IdGenerator getIdGenerator()

setIdGenerator

public void setIdGenerator(IdGenerator idGenerator)

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)


Copyright © 2005-2011 FuseSource. All Rights Reserved.