org.jboss.cache.search
Class SearchableCacheImpl<K,V>

java.lang.Object
  extended by org.jboss.cache.search.SearchableCacheImpl<K,V>
All Implemented Interfaces:
org.jboss.cache.Cache<K,V>, SearchableCache<K,V>

public class SearchableCacheImpl<K,V>
extends Object
implements SearchableCache<K,V>

Implementation class for the SearchableCache interface.

Author:
Navin Surtani (nsurtani@redhat.com)

Constructor Summary
SearchableCacheImpl(org.jboss.cache.Cache<K,V> cache, org.hibernate.search.engine.SearchFactoryImplementor searchFactory)
           
 
Method Summary
 void addCacheListener(Object listener)
          Adds a listener to the cache.
 void addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor i, Class<? extends org.jboss.cache.interceptors.base.CommandInterceptor> afterInterceptor)
           
 void addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor i, int position)
           
 void clearData(org.jboss.cache.Fqn fqn)
           
 void clearData(String fqn)
           
 void create()
          Lifecycle method that initializes configuration state, the root node, etc.
 CacheQuery createQuery(org.apache.lucene.search.Query luceneQuery, Class... classes)
          Creates a CacheQuery object from a Lucene Query and a class array.
 void destroy()
          Lifecycle method that destroys the cache and removes any interceptors/configuration elements.
 void endBatch(boolean successful)
           
 void evict(org.jboss.cache.Fqn fqn)
           
 void evict(org.jboss.cache.Fqn fqn, boolean recursive)
           
 V get(org.jboss.cache.Fqn fqn, K key)
           
 V get(String fqn, K key)
          Convenience method that allows for direct access to the data in a Node.
 Set getCacheListeners()
          Returns a set of listeners that the cache has.
 org.jboss.cache.CacheStatus getCacheStatus()
          Gets where the cache currently is its lifecycle transitions.
 org.jboss.cache.config.Configuration getConfiguration()
          Returns an org.jboss.cache.config.Configuration instance.
 Map<K,V> getData(org.jboss.cache.Fqn fqn)
           
 org.jboss.cache.InvocationContext getInvocationContext()
          The current invocation context for the current invocation and cache instance.
 Set<K> getKeys(org.jboss.cache.Fqn fqn)
           
 Set<K> getKeys(String fqn)
          Returns a set of attribute keys for the Fqn.
 org.jgroups.Address getLocalAddress()
          Returns the local address of this cache in a cluster, or null if running in local mode.
 List getMembers()
          Returns a list of members in the cluster, or null if running in local mode.
 org.jboss.cache.Node<K,V> getNode(org.jboss.cache.Fqn fqn)
           
 org.jboss.cache.Node getNode(String fqn)
          Gets a node from a String representation of a Fqn
 org.jboss.cache.Region getRegion(org.jboss.cache.Fqn fqn, boolean createIfAbsent)
           
 org.jboss.cache.Node getRoot()
          Returns an org.jboss.cache.Node instance.
 String getVersion()
          Returns the version of the cache as a string.
 void move(org.jboss.cache.Fqn nodeToMove, org.jboss.cache.Fqn newParent)
           
 void move(String nodeToMove, String newParent)
          Moves a part of the cache to a different subtree.
 V put(org.jboss.cache.Fqn fqn, K key, V value)
           
 void put(org.jboss.cache.Fqn fqn, Map<? extends K,? extends V> data)
           
 V put(String fqn, K key, V value)
          Puts something into the cache with a given Fqn, key and value.
 void put(String fqn, Map<? extends K,? extends V> data)
           
 void putForExternalRead(org.jboss.cache.Fqn fqn, K key, V value)
           
 V remove(org.jboss.cache.Fqn fqn, K key)
           
 V remove(String fqn, K key)
           
 void removeCacheListener(Object listener)
          Removes a listener from the cache.
 void removeInterceptor(Class<? extends org.jboss.cache.interceptors.base.CommandInterceptor> interceptorType)
           
 void removeInterceptor(int position)
           
 boolean removeNode(org.jboss.cache.Fqn fqn)
           
 boolean removeNode(String fqn)
          Convenience method that takes a string representation of an Fqn.
 boolean removeRegion(org.jboss.cache.Fqn fqn)
           
 void setInvocationContext(org.jboss.cache.InvocationContext ctx)
          Sets the passed in InvocationContext as current.
 void start()
          Lifecycle method that starts the cache loader, starts cache replication, starts the region manager, etc., and (if configured) warms the cache using a state transfer or cache loader preload.
 void startBatch()
           
 void stop()
          Lifecycle method that stops the cache, including replication, clustering, cache loading, notifications, etc., and clears all cache in-memory state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchableCacheImpl

public SearchableCacheImpl(org.jboss.cache.Cache<K,V> cache,
                           org.hibernate.search.engine.SearchFactoryImplementor searchFactory)
Method Detail

createQuery

public CacheQuery createQuery(org.apache.lucene.search.Query luceneQuery,
                              Class... classes)
Creates a CacheQuery object from a Lucene Query and a class array.

Specified by:
createQuery in interface SearchableCache<K,V>
Parameters:
luceneQuery - - for lucene
classes - array
Returns:
CacheQuery object.

getConfiguration

public org.jboss.cache.config.Configuration getConfiguration()
Returns an org.jboss.cache.config.Configuration instance.

Specified by:
getConfiguration in interface org.jboss.cache.Cache<K,V>
Returns:
org.jboss.cache.config.Configuration

getRoot

public org.jboss.cache.Node getRoot()
Returns an org.jboss.cache.Node instance.

Specified by:
getRoot in interface org.jboss.cache.Cache<K,V>
Returns:
org.jboss.cache.Node

addCacheListener

public void addCacheListener(Object listener)
Adds a listener to the cache.

Specified by:
addCacheListener in interface org.jboss.cache.Cache<K,V>
Parameters:
listener -

removeCacheListener

public void removeCacheListener(Object listener)
Removes a listener from the cache.

Specified by:
removeCacheListener in interface org.jboss.cache.Cache<K,V>
Parameters:
listener -

getCacheListeners

public Set getCacheListeners()
Returns a set of listeners that the cache has.

Specified by:
getCacheListeners in interface org.jboss.cache.Cache<K,V>
Returns:
A set of listeners.

put

public V put(org.jboss.cache.Fqn fqn,
             K key,
             V value)
Specified by:
put in interface org.jboss.cache.Cache<K,V>

put

public V put(String fqn,
             K key,
             V value)
Puts something into the cache with a given Fqn, key and value.

Specified by:
put in interface org.jboss.cache.Cache<K,V>
Parameters:
fqn -
key -
value -
Returns:

putForExternalRead

public void putForExternalRead(org.jboss.cache.Fqn fqn,
                               K key,
                               V value)
Specified by:
putForExternalRead in interface org.jboss.cache.Cache<K,V>

put

public void put(org.jboss.cache.Fqn fqn,
                Map<? extends K,? extends V> data)
Specified by:
put in interface org.jboss.cache.Cache<K,V>

put

public void put(String fqn,
                Map<? extends K,? extends V> data)
Specified by:
put in interface org.jboss.cache.Cache<K,V>

remove

public V remove(org.jboss.cache.Fqn fqn,
                K key)
Specified by:
remove in interface org.jboss.cache.Cache<K,V>

remove

public V remove(String fqn,
                K key)
Specified by:
remove in interface org.jboss.cache.Cache<K,V>

removeNode

public boolean removeNode(org.jboss.cache.Fqn fqn)
Specified by:
removeNode in interface org.jboss.cache.Cache<K,V>

removeNode

public boolean removeNode(String fqn)
Convenience method that takes a string representation of an Fqn. Otherwise identical to removeNode(Fqn)

Specified by:
removeNode in interface org.jboss.cache.Cache<K,V>
Parameters:
fqn -
Returns:
True if the node was removed, false if the node wasn't

getNode

public org.jboss.cache.Node<K,V> getNode(org.jboss.cache.Fqn fqn)
Specified by:
getNode in interface org.jboss.cache.Cache<K,V>

getNode

public org.jboss.cache.Node getNode(String fqn)
Gets a node from a String representation of a Fqn

Specified by:
getNode in interface org.jboss.cache.Cache<K,V>
Parameters:
fqn -
Returns:

get

public V get(org.jboss.cache.Fqn fqn,
             K key)
Specified by:
get in interface org.jboss.cache.Cache<K,V>

get

public V get(String fqn,
             K key)
Convenience method that allows for direct access to the data in a Node.

Specified by:
get in interface org.jboss.cache.Cache<K,V>
Parameters:
fqn -
key -
Returns:

evict

public void evict(org.jboss.cache.Fqn fqn,
                  boolean recursive)
Specified by:
evict in interface org.jboss.cache.Cache<K,V>

evict

public void evict(org.jboss.cache.Fqn fqn)
Specified by:
evict in interface org.jboss.cache.Cache<K,V>

getRegion

public org.jboss.cache.Region getRegion(org.jboss.cache.Fqn fqn,
                                        boolean createIfAbsent)
Specified by:
getRegion in interface org.jboss.cache.Cache<K,V>

removeRegion

public boolean removeRegion(org.jboss.cache.Fqn fqn)
Specified by:
removeRegion in interface org.jboss.cache.Cache<K,V>

create

public void create()
            throws org.jboss.cache.CacheException
Lifecycle method that initializes configuration state, the root node, etc.

Specified by:
create in interface org.jboss.cache.Cache<K,V>
Throws:
org.jboss.cache.CacheException

start

public void start()
           throws org.jboss.cache.CacheException
Lifecycle method that starts the cache loader, starts cache replication, starts the region manager, etc., and (if configured) warms the cache using a state transfer or cache loader preload.

Specified by:
start in interface org.jboss.cache.Cache<K,V>
Throws:
org.jboss.cache.CacheException

stop

public void stop()
Lifecycle method that stops the cache, including replication, clustering, cache loading, notifications, etc., and clears all cache in-memory state.

Specified by:
stop in interface org.jboss.cache.Cache<K,V>

destroy

public void destroy()
Lifecycle method that destroys the cache and removes any interceptors/configuration elements.

Specified by:
destroy in interface org.jboss.cache.Cache<K,V>

getCacheStatus

public org.jboss.cache.CacheStatus getCacheStatus()
Gets where the cache currently is its lifecycle transitions.

Specified by:
getCacheStatus in interface org.jboss.cache.Cache<K,V>
Returns:
the CacheStatus. Will not return null.

getInvocationContext

public org.jboss.cache.InvocationContext getInvocationContext()
The current invocation context for the current invocation and cache instance.

Specified by:
getInvocationContext in interface org.jboss.cache.Cache<K,V>
Returns:
the current invocation context for the current invocation and cache instance

setInvocationContext

public void setInvocationContext(org.jboss.cache.InvocationContext ctx)
Sets the passed in InvocationContext as current.

Specified by:
setInvocationContext in interface org.jboss.cache.Cache<K,V>
Parameters:
ctx -

getLocalAddress

public org.jgroups.Address getLocalAddress()
Returns the local address of this cache in a cluster, or null if running in local mode.

Specified by:
getLocalAddress in interface org.jboss.cache.Cache<K,V>
Returns:
Returns the local address of this cache in a cluster, or null if running in local mode.

getMembers

public List getMembers()
Returns a list of members in the cluster, or null if running in local mode.

Specified by:
getMembers in interface org.jboss.cache.Cache<K,V>
Returns:
Returns a list of members in the cluster, or null if running in local mode.

move

public void move(org.jboss.cache.Fqn nodeToMove,
                 org.jboss.cache.Fqn newParent)
          throws org.jboss.cache.NodeNotExistsException
Specified by:
move in interface org.jboss.cache.Cache<K,V>
Throws:
org.jboss.cache.NodeNotExistsException

move

public void move(String nodeToMove,
                 String newParent)
          throws org.jboss.cache.NodeNotExistsException
Moves a part of the cache to a different subtree. Takes Strings for convenience.

Specified by:
move in interface org.jboss.cache.Cache<K,V>
Parameters:
nodeToMove -
newParent -
Throws:
org.jboss.cache.NodeNotExistsException

getVersion

public String getVersion()
Returns the version of the cache as a string.

Specified by:
getVersion in interface org.jboss.cache.Cache<K,V>
Returns:
Returns the version of the cache as a string.

getData

public Map<K,V> getData(org.jboss.cache.Fqn fqn)
Specified by:
getData in interface org.jboss.cache.Cache<K,V>

getKeys

public Set<K> getKeys(String fqn)
Returns a set of attribute keys for the Fqn. Takes Strings for convenience.

Specified by:
getKeys in interface org.jboss.cache.Cache<K,V>
Parameters:
fqn -
Returns:
Returns a set of attribute keys for the Fqn.

getKeys

public Set<K> getKeys(org.jboss.cache.Fqn fqn)
Specified by:
getKeys in interface org.jboss.cache.Cache<K,V>

clearData

public void clearData(String fqn)
Specified by:
clearData in interface org.jboss.cache.Cache<K,V>

clearData

public void clearData(org.jboss.cache.Fqn fqn)
Specified by:
clearData in interface org.jboss.cache.Cache<K,V>

startBatch

public void startBatch()
Specified by:
startBatch in interface org.jboss.cache.Cache<K,V>

endBatch

public void endBatch(boolean successful)
Specified by:
endBatch in interface org.jboss.cache.Cache<K,V>

removeInterceptor

public void removeInterceptor(Class<? extends org.jboss.cache.interceptors.base.CommandInterceptor> interceptorType)
Specified by:
removeInterceptor in interface org.jboss.cache.Cache<K,V>

removeInterceptor

public void removeInterceptor(int position)
Specified by:
removeInterceptor in interface org.jboss.cache.Cache<K,V>

addInterceptor

public void addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor i,
                           Class<? extends org.jboss.cache.interceptors.base.CommandInterceptor> afterInterceptor)
Specified by:
addInterceptor in interface org.jboss.cache.Cache<K,V>

addInterceptor

public void addInterceptor(org.jboss.cache.interceptors.base.CommandInterceptor i,
                           int position)
Specified by:
addInterceptor in interface org.jboss.cache.Cache<K,V>


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.