[jbosscache-commits] JBoss Cache SVN: r5939 - in searchable/trunk/src/main/java: org and 3 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jun 3 08:50:34 EDT 2008


Author: navssurtani
Date: 2008-06-03 08:50:34 -0400 (Tue, 03 Jun 2008)
New Revision: 5939

Added:
   searchable/trunk/src/main/java/org/
   searchable/trunk/src/main/java/org/jboss/
   searchable/trunk/src/main/java/org/jboss/cache/
   searchable/trunk/src/main/java/org/jboss/cache/search/
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.java
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
   searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
Log:
Created SearchableListener, SearchableCacheFactory, SearchableCacheImpl classes and SearchableCache interface.

Added: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.java	                        (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCache.java	2008-06-03 12:50:34 UTC (rev 5939)
@@ -0,0 +1,20 @@
+package org.jboss.cache.search;
+
+import org.apache.lucene.search.Query;
+import org.jboss.cache.Cache;
+
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: navin
+ * Date: Jun 3, 2008
+ * Time: 10:48:46 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public interface SearchableCache extends Cache
+{
+   public List find(Query luceneQuery);
+
+
+}

Added: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java	                        (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java	2008-06-03 12:50:34 UTC (rev 5939)
@@ -0,0 +1,26 @@
+package org.jboss.cache.search;
+
+import org.jboss.cache.Cache;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: navin
+ * Date: Jun 3, 2008
+ * Time: 10:52:25 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SearchableCacheFactory
+{
+   public SearchableCache createSearchableCache (Cache c, Class...  classes)
+   {
+
+      // TODO: Initialise HS internals
+
+      SearchableListener listener = new SearchableListener();
+      c.addCacheListener(listener);
+
+      SearchableCache sc = new SearchableCacheImpl(c);
+      return sc;
+   }
+
+}

Added: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java	                        (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheImpl.java	2008-06-03 12:50:34 UTC (rev 5939)
@@ -0,0 +1,252 @@
+package org.jboss.cache.search;
+
+import org.apache.lucene.search.Query;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.Region;
+import org.jboss.cache.config.Configuration;
+import org.jgroups.Address;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: navin
+ * Date: Jun 3, 2008
+ * Time: 10:51:53 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class SearchableCacheImpl implements SearchableCache
+{
+   // this is the ACTUAL cache. that does all the work.
+   private Cache cache;
+
+   public SearchableCacheImpl(Cache cache)
+   {
+      this.cache = cache;
+   }
+
+   public List find(Query luceneQuery)
+   {
+      // TODO: Write up find() method. What does HS do when given the Lucene/Hibernate query ??
+
+      return null;  //To change body of implemented methods use File | Settings | File Templates.
+   }
+
+   public Configuration getConfiguration()
+   {
+      return cache.getConfiguration();
+   }
+
+   public Node getRoot()
+   {
+      return cache.getRoot();
+   }
+
+   public void addCacheListener(Object listener)
+   {
+      cache.addCacheListener(listener);
+   }
+
+   public void removeCacheListener(Object listener)
+   {
+      cache.removeCacheListener(listener);
+   }
+
+   public Set getCacheListeners()
+   {
+      return cache.getCacheListeners();
+   }
+
+   public Object put(String fqn, Object key, Object value)
+   {
+      return cache.put(fqn, key, value);
+   }
+
+   public void put(String fqn, Map data)
+   {
+      cache.put(fqn, data);
+   }
+
+   public Object remove(String fqn, Object key)
+   {
+      return cache.remove(fqn, key);
+   }
+
+   public boolean removeNode(String fqn)
+   {
+      return cache.removeNode(fqn);
+   }
+
+   public Node getNode(String fqn)
+   {
+      return cache.getNode(fqn);
+   }
+
+   public Object get(String fqn, Object key)
+   {
+      return cache.get(fqn, key);
+   }
+
+   public void create() throws CacheException
+   {
+      cache.create();
+   }
+
+   public void start() throws CacheException
+   {
+      cache.start();
+   }
+
+   public void stop()
+   {
+      cache.stop();
+   }
+
+   public void destroy()
+   {
+      cache.destroy();
+   }
+
+   public CacheStatus getCacheStatus()
+   {
+      return cache.getCacheStatus();
+   }
+
+   public InvocationContext getInvocationContext()
+   {
+      return cache.getInvocationContext();
+   }
+
+   public void setInvocationContext(InvocationContext ctx)
+   {
+      cache.setInvocationContext(ctx);
+   }
+
+   public Address getLocalAddress()
+   {
+      return cache.getLocalAddress();
+   }
+
+   public List getMembers()
+   {
+      return cache.getMembers();
+   }
+
+   public void move(String nodeToMove, String newParent) throws NodeNotExistsException
+   {
+      cache.move(nodeToMove, newParent);
+   }
+
+   public String getVersion()
+   {
+      return cache.getVersion();
+   }
+
+   public Set getKeys(String fqn)
+   {
+      return cache.getKeys(fqn);
+   }
+
+   public void clearData(String fqn)
+   {
+      cache.clearData(fqn);
+   }
+
+   public void clearData(Fqn fqn)
+   {
+      cache.clearData(fqn);
+   }
+
+   public Set getKeys(Fqn fqn)
+   {
+      return cache.getKeys(fqn);
+   }
+
+   public Map getData(Fqn fqn)
+   {
+      return cache.getData(fqn);
+   }
+
+   public void move(Fqn nodeToMove, Fqn newParent) throws NodeNotExistsException
+   {
+      cache.move(nodeToMove, newParent);
+   }
+
+   public boolean removeRegion(Fqn fqn)
+   {
+      return cache.removeRegion(fqn);
+   }
+
+   public Region getRegion(Fqn fqn, boolean createIfAbsent)
+   {
+      return cache.getRegion(fqn, createIfAbsent);
+   }
+
+   public void evict(Fqn fqn)
+   {
+      cache.evict(fqn);
+   }
+
+   public void evict(Fqn fqn, boolean recursive)
+   {
+      cache.evict(fqn, recursive);
+   }
+
+   public Object get(Fqn fqn, Object key)
+   {
+      return cache.get(fqn, key);
+   }
+
+   public Node getNode(Fqn fqn)
+   {
+      return cache.getNode(fqn);
+   }
+
+   public boolean removeNode(Fqn fqn)
+   {
+      return cache.removeNode(fqn);
+   }
+
+   public Object remove(Fqn fqn, Object key)
+   {
+      return cache.remove(fqn, key);
+   }
+
+   public void put(Fqn fqn, Map data)
+   {
+      cache.put(fqn, data);
+   }
+
+   public void putForExternalRead(Fqn fqn, Object key, Object value)
+   {
+      cache.putForExternalRead(fqn, key, value);
+   }
+
+   public Object put(Fqn fqn, Object key, Object value)
+   {
+      return cache.put(fqn, key, value);
+   }
+
+   public Set getCacheListeners(Fqn region)
+   {
+      return cache.getCacheListeners(region);
+   }
+
+   public void removeCacheListener(Fqn region, Object listener)
+   {
+      cache.removeCacheListener(region, listener);
+   }
+
+   public void addCacheListener(Fqn region, Object listener)
+   {
+      cache.addCacheListener(region, listener);
+   }
+}

Added: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java	                        (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java	2008-06-03 12:50:34 UTC (rev 5939)
@@ -0,0 +1,37 @@
+package org.jboss.cache.search;
+
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeCreated;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.annotation.NodeMoved;
+import org.jboss.cache.notifications.annotation.NodeRemoved;
+import org.jboss.cache.notifications.event.NodeEvent;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: navin
+ * Date: Jun 3, 2008
+ * Time: 11:42:50 AM
+ * To change this template use File | Settings | File Templates.
+ */
+
+ at CacheListener
+public class SearchableListener
+{
+
+   @NodeCreated
+   @NodeRemoved
+   @NodeModified
+   @NodeMoved
+   public void updateLuceneIndexes(NodeEvent event)
+   {
+      if (!event.isPre())
+      {
+         //  TODO: Update Lucene Indexes.  See Hibernate Search's FullTextEventListener class for details on what to do.
+      }
+      else
+      {
+         // ignore the event.
+      }
+   }
+}




More information about the jbosscache-commits mailing list