Author: navssurtani
Date: 2009-01-04 12:43:15 -0500 (Sun, 04 Jan 2009)
New Revision: 7355
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
Log:
Commented out pojo classes ...
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java 2009-01-04
17:38:05 UTC (rev 7354)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/PojoTransactionContext.java 2009-01-04
17:43:15 UTC (rev 7355)
@@ -1,72 +1,72 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.jboss.cache.search;
-
-import org.hibernate.search.backend.TransactionContext;
-import org.jboss.cache.pojo.notification.event.Event;
-
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-
-/**
- * @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
- */
-public class PojoTransactionContext implements TransactionContext
-{
- Event event;
-
- public PojoTransactionContext(Event event)
- {
- if (event == null) throw new NullPointerException("event cannot be
null");
- this.event = event;
-
- }
- public boolean isTransactionInProgress()
- {
- return (event.getContext().getTransaction() != null);
-
- }
-
- public Object getTransactionIdentifier()
- {
- return event.getContext().getTransaction();
- }
-
- public void registerSynchronization(Synchronization synchronization)
- {
- Transaction transaction = event.getContext().getTransaction();
-
- if (transaction != null)
- {
-
- try
- {
- transaction.registerSynchronization(synchronization);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
- }
-}
+///*
+// * JBoss, Home of Professional Open Source
+// * Copyright ${year}, Red Hat Middleware LLC, and individual contributors
+// * by the @authors tag. See the copyright.txt in the distribution for a
+// * full listing of individual contributors.
+// *
+// * This is free software; you can redistribute it and/or modify it
+// * under the terms of the GNU Lesser General Public License as
+// * published by the Free Software Foundation; either version 2.1 of
+// * the License, or (at your option) any later version.
+// *
+// * This software is distributed in the hope that it will be useful,
+// * but WITHOUT ANY WARRANTY; without even the implied warranty of
+// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// * Lesser General Public License for more details.
+// *
+// * You should have received a copy of the GNU Lesser General Public
+// * License along with this software; if not, write to the Free
+// * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+// * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+// */
+//
+//package org.jboss.cache.search;
+//
+//import org.hibernate.search.backend.TransactionContext;
+//import org.jboss.cache.pojo.notification.event.Event;
+//
+//import javax.transaction.Synchronization;
+//import javax.transaction.Transaction;
+//
+///**
+// * @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
+// */
+//public class PojoTransactionContext implements TransactionContext
+//{
+// Event event;
+//
+// public PojoTransactionContext(Event event)
+// {
+// if (event == null) throw new NullPointerException("event cannot be
null");
+// this.event = event;
+//
+// }
+// public boolean isTransactionInProgress()
+// {
+// return (event.getContext().getTransaction() != null);
+//
+// }
+//
+// public Object getTransactionIdentifier()
+// {
+// return event.getContext().getTransaction();
+// }
+//
+// public void registerSynchronization(Synchronization synchronization)
+// {
+// Transaction transaction = event.getContext().getTransaction();
+//
+// if (transaction != null)
+// {
+//
+// try
+// {
+// transaction.registerSynchronization(synchronization);
+// }
+// catch (Exception e)
+// {
+// throw new RuntimeException(e);
+// }
+// }
+// }
+//}
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
---
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2009-01-04
17:38:05 UTC (rev 7354)
+++
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2009-01-04
17:43:15 UTC (rev 7355)
@@ -27,7 +27,6 @@
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheStatus;
-import org.jboss.cache.pojo.PojoCache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -106,65 +105,64 @@
}
- /**
- * This method creates a searchable cache as well but requires the properties object.
- *
- * @param pojo - the pojoCache
- * @param properties - java.util.properties
- * @param classes - a class array
- * @return a SearchableCache
- */
+// /**
+// * This method creates a searchable cache as well but requires the properties
object.
+// *
+// * @param pojo - the pojoCache
+// * @param properties - java.util.properties
+// * @param classes - a class array
+// * @return a SearchableCache
+// */
- public SearchableCache createSearchableCache(PojoCache pojo, Properties properties,
Class... classes)
- {
-
- System.out.println("create searchable cache called with pojo cache");
- //TODO: Ask Manik and/or Jason if there is a way to directly check if the pojo
cache is started or not
- validateClasses(classes);
-
- Cache coreCache = pojo.getCache();
-
- if (coreCache.getCacheStatus() != CacheStatus.STARTED)
- {
- if (log.isInfoEnabled()) log.info("Cache not started. Starting cache
first.");
- pojo.start();
- }
-
- if (classes.length == 0)
- {
- if (log.isWarnEnabled()) log.warn("You haven't passed in any classes to
index. Is this an error?");
- }
-
- // step 1: create hibernate search searchFactory
- SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
- // set classes in the cfg
-
- SearchFactoryImplementor searchFactory = new SearchFactoryImpl(cfg);
-
- //Now create the pojoListener
+// public SearchableCache createSearchableCache(PojoCache pojo, Properties properties,
Class... classes)
+// {
+//
+// System.out.println("create searchable cache called with pojo cache");
+// //TODO: Ask Manik and/or Jason if there is a way to directly check if the pojo
cache is started or not
+// validateClasses(classes);
+//
+// Cache coreCache = pojo.getCache();
+//
+// if (coreCache.getCacheStatus() != CacheStatus.STARTED)
+// {
+// if (log.isInfoEnabled()) log.info("Cache not started. Starting cache
first.");
+// pojo.start();
+// }
+//
+// if (classes.length == 0)
+// {
+// if (log.isWarnEnabled()) log.warn("You haven't passed in any classes
to index. Is this an error?");
+// }
+//
+// // step 1: create hibernate search searchFactory
+// SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
+// // set classes in the cfg
+//
+// SearchFactoryImplementor searchFactory = new SearchFactoryImpl(cfg);
+//
+// //Now create the pojoListener
// SearchablePojoListener pojoListener = new SearchablePojoListener(searchFactory);
// pojo.addListener(pojoListener);
// pojo.getCache().addCacheListener(pojoListener);
+//
+// SearchableCache sc = new SearchableCacheImpl(coreCache, searchFactory);
+// return sc;
+// }
- //TODO: - This could be a break point. But it should not be.
- SearchableCache sc = new SearchableCacheImpl(coreCache, searchFactory);
- return sc;
- }
+// /**
+// * Creates a searchable cache from a cache object and a class array, without the
properties object.
+// *
+// * @param pojo - the pojoCache
+// * @param classes - Class array to be added
+// * @return a SearchableCache
+// */
+//
+//
+// public SearchableCache createSearchableCache(PojoCache pojo, Class... classes)
+// {
+// return createSearchableCache(pojo, null, classes);
+// }
- /**
- * Creates a searchable cache from a cache object and a class array, without the
properties object.
- *
- * @param pojo - the pojoCache
- * @param classes - Class array to be added
- * @return a SearchableCache
- */
-
-
- public SearchableCache createSearchableCache(PojoCache pojo, Class... classes)
- {
- return createSearchableCache(pojo, null, classes);
- }
-
//This is to check that both the @ProvidedId is present and the the @DocumentId is not
present. This is because
// don't want both of these 2 annotations used at the same time.
private void validateClasses(Class... classes)
Modified:
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java
===================================================================
---
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2009-01-04
17:38:05 UTC (rev 7354)
+++
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalPOJOCacheTest.java 2009-01-04
17:43:15 UTC (rev 7355)
@@ -1,193 +1,193 @@
-package org.jboss.cache.search.blackbox;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Query;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.pojo.PojoCache;
-import org.jboss.cache.pojo.PojoCacheFactory;
-import org.jboss.cache.search.CacheQuery;
-import org.jboss.cache.search.SearchableCache;
-import org.jboss.cache.search.SearchableCacheFactory;
-import org.jboss.cache.search.QueryResultIterator;
-import org.jboss.cache.search.helper.IndexCleanUp;
-import org.jboss.cache.search.test.Person;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.List;
-import java.util.Iterator;
-
-/**
- * Same as LocalCacheTest except that you will use a POJO Cache instead and use
pojoCache.attach() ad pojoCache.detach()
- * instead of cache.put() and cache.remove().
- * <p/>
- *
- * @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
- */
-
-@Test(groups = "functional", enabled = false)
-public class LocalPOJOCacheTest
-{
- SearchableCache searchableCache;
- PojoCache pojo;
- Person person1;
- Person person2;
- Person person3;
- Person person4;
- QueryParser queryParser;
- Query luceneQuery;
- CacheQuery cacheQuery;
- List found;
- private static final Log log = LogFactory.getLog(LocalPOJOCacheTest.class);
-
-
- @BeforeMethod
- public void setUp()
- {
- boolean toStart = false;
- pojo = PojoCacheFactory.createCache(new Configuration(), toStart);
- pojo.start(); // if toStart above is true, it will starts the cache automatically.
- searchableCache = new SearchableCacheFactory().createSearchableCache(pojo,
Person.class);
-
- person1 = new Person();
- person1.setName("Navin Surtani");
- person1.setBlurb("Likes playing WoW");
-
- person2 = new Person();
- person2.setName("BigGoat");
- person2.setBlurb("Eats grass");
-
- person3 = new Person();
- person3.setName("MiniGoat");
- person3.setBlurb("Eats cheese");
-
- pojo.attach("/a/b/c", person1);
- pojo.attach("/a/b/d", person2);
- pojo.attach("/c/a/t", person3);
-
-
- }
-
- @AfterMethod
- public void tearDown()
- {
- if (pojo != null) pojo.stop();
- if (searchableCache != null) searchableCache.stop();
- IndexCleanUp.cleanUpIndexes();
- }
-
- public void testSimple() throws ParseException
- {
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
- luceneQuery = queryParser.parse("playing");
- cacheQuery = searchableCache.createQuery(luceneQuery);
-
- QueryResultIterator found = cacheQuery.iterator();
- found.first();
- System.out.println("First object is " + found.next());
- }
-
- public void testMultipleResults() throws ParseException
- {
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
- luceneQuery = queryParser.parse("Eats");
- cacheQuery = searchableCache.createQuery(luceneQuery);
- found = cacheQuery.list();
-
- System.out.println("size is " + found.size());
- assert found.size() == 2;
-
- System.out.println("object 0 is " + found.get(0));
- System.out.println("object 1 is " + found.get(1));
- assert !found.get(1).equals(person2);
- assert !found.get(0).equals(person3);
-
- }
-
- public void testModified() throws ParseException
- {
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
- luceneQuery = queryParser.parse("playing");
- cacheQuery = searchableCache.createQuery(luceneQuery);
-
- found = cacheQuery.list();
-
- assert found.size() == 1;
-// assert found.get(0).equals(person1);
-
- person1.setBlurb("Likes pizza");
-
- pojo.attach(Fqn.fromString("/a/b/c/"), person1);
-
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
- luceneQuery = queryParser.parse("pizza");
- cacheQuery = searchableCache.createQuery(luceneQuery);
-
- found = cacheQuery.list();
-
- assert found.size() == 1;
-// assert found.get(0).equals(person1);
- }
-
- public void testAdded() throws ParseException
- {
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
- luceneQuery = queryParser.parse("eats");
- cacheQuery = searchableCache.createQuery(luceneQuery);
- found = cacheQuery.list();
-
- assert found.size() == 2 : "Size of list should be 2";
- assert found.contains(person2);
- assert found.contains(person3);
- assert !found.contains(person4) : "This should not contain object
person4";
-
- person4 = new Person();
- person4.setName("MightyGoat");
- person4.setBlurb("Also eats grass");
-
- pojo.attach(Fqn.fromString("/r/a/m/"), person4);
-
- luceneQuery = queryParser.parse("eats");
- cacheQuery = searchableCache.createQuery(luceneQuery);
- found = cacheQuery.list();
-
- assert found.size() == 3 : "Size of list should be 3";
- assert found.contains(person2);
- assert found.contains(person3);
- assert found.contains(person4) : "This should now contain object
person4";
- }
-
- public void testRemoved() throws ParseException
- {
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
- luceneQuery = queryParser.parse("eats");
- cacheQuery = searchableCache.createQuery(luceneQuery);
- found = cacheQuery.list();
-
- assert found.size() == 2;
- assert found.contains(person2);
- assert found.contains(person3) : "This should still contain object
person3";
-
- pojo.detach("/a/b/d");
-
- luceneQuery = queryParser.parse("eats");
- cacheQuery = searchableCache.createQuery(luceneQuery);
- found = cacheQuery.list();
-
- assert found.size() == 1;
- assert found.contains(person2);
- assert !found.contains(person3) : "The search should not return
person3";
-
-
- }
-
-}
-
-
-
+//package org.jboss.cache.search.blackbox;
+//
+//import org.apache.commons.logging.Log;
+//import org.apache.commons.logging.LogFactory;
+//import org.apache.lucene.analysis.standard.StandardAnalyzer;
+//import org.apache.lucene.queryParser.ParseException;
+//import org.apache.lucene.queryParser.QueryParser;
+//import org.apache.lucene.search.Query;
+//import org.jboss.cache.Fqn;
+//import org.jboss.cache.config.Configuration;
+//import org.jboss.cache.pojo.PojoCache;
+//import org.jboss.cache.pojo.PojoCacheFactory;
+//import org.jboss.cache.search.CacheQuery;
+//import org.jboss.cache.search.SearchableCache;
+//import org.jboss.cache.search.SearchableCacheFactory;
+//import org.jboss.cache.search.QueryResultIterator;
+//import org.jboss.cache.search.helper.IndexCleanUp;
+//import org.jboss.cache.search.test.Person;
+//import org.testng.annotations.AfterMethod;
+//import org.testng.annotations.BeforeMethod;
+//import org.testng.annotations.Test;
+//
+//import java.util.List;
+//import java.util.Iterator;
+//
+///**
+// * Same as LocalCacheTest except that you will use a POJO Cache instead and use
pojoCache.attach() ad pojoCache.detach()
+// * instead of cache.put() and cache.remove().
+// * <p/>
+// *
+// * @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
+// */
+//
+//@Test(groups = "functional", enabled = false)
+//public class LocalPOJOCacheTest
+//{
+// SearchableCache searchableCache;
+// PojoCache pojo;
+// Person person1;
+// Person person2;
+// Person person3;
+// Person person4;
+// QueryParser queryParser;
+// Query luceneQuery;
+// CacheQuery cacheQuery;
+// List found;
+// private static final Log log = LogFactory.getLog(LocalPOJOCacheTest.class);
+//
+//
+// @BeforeMethod
+// public void setUp()
+// {
+// boolean toStart = false;
+// pojo = PojoCacheFactory.createCache(new Configuration(), toStart);
+// pojo.start(); // if toStart above is true, it will starts the cache
automatically.
+// searchableCache = new SearchableCacheFactory().createSearchableCache(pojo,
Person.class);
+//
+// person1 = new Person();
+// person1.setName("Navin Surtani");
+// person1.setBlurb("Likes playing WoW");
+//
+// person2 = new Person();
+// person2.setName("BigGoat");
+// person2.setBlurb("Eats grass");
+//
+// person3 = new Person();
+// person3.setName("MiniGoat");
+// person3.setBlurb("Eats cheese");
+//
+// pojo.attach("/a/b/c", person1);
+// pojo.attach("/a/b/d", person2);
+// pojo.attach("/c/a/t", person3);
+//
+//
+// }
+//
+// @AfterMethod
+// public void tearDown()
+// {
+// if (pojo != null) pojo.stop();
+// if (searchableCache != null) searchableCache.stop();
+// IndexCleanUp.cleanUpIndexes();
+// }
+//
+// public void testSimple() throws ParseException
+// {
+// queryParser = new QueryParser("blurb", new StandardAnalyzer());
+// luceneQuery = queryParser.parse("playing");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+//
+// QueryResultIterator found = cacheQuery.iterator();
+// found.first();
+// System.out.println("First object is " + found.next());
+// }
+//
+// public void testMultipleResults() throws ParseException
+// {
+// queryParser = new QueryParser("blurb", new StandardAnalyzer());
+// luceneQuery = queryParser.parse("Eats");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+// found = cacheQuery.list();
+//
+// System.out.println("size is " + found.size());
+// assert found.size() == 2;
+//
+// System.out.println("object 0 is " + found.get(0));
+// System.out.println("object 1 is " + found.get(1));
+// assert !found.get(1).equals(person2);
+// assert !found.get(0).equals(person3);
+//
+// }
+//
+// public void testModified() throws ParseException
+// {
+// queryParser = new QueryParser("blurb", new StandardAnalyzer());
+// luceneQuery = queryParser.parse("playing");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+//
+// found = cacheQuery.list();
+//
+// assert found.size() == 1;
+//// assert found.get(0).equals(person1);
+//
+// person1.setBlurb("Likes pizza");
+//
+// pojo.attach(Fqn.fromString("/a/b/c/"), person1);
+//
+// queryParser = new QueryParser("blurb", new StandardAnalyzer());
+// luceneQuery = queryParser.parse("pizza");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+//
+// found = cacheQuery.list();
+//
+// assert found.size() == 1;
+//// assert found.get(0).equals(person1);
+// }
+//
+// public void testAdded() throws ParseException
+// {
+// queryParser = new QueryParser("blurb", new StandardAnalyzer());
+// luceneQuery = queryParser.parse("eats");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+// found = cacheQuery.list();
+//
+// assert found.size() == 2 : "Size of list should be 2";
+// assert found.contains(person2);
+// assert found.contains(person3);
+// assert !found.contains(person4) : "This should not contain object
person4";
+//
+// person4 = new Person();
+// person4.setName("MightyGoat");
+// person4.setBlurb("Also eats grass");
+//
+// pojo.attach(Fqn.fromString("/r/a/m/"), person4);
+//
+// luceneQuery = queryParser.parse("eats");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+// found = cacheQuery.list();
+//
+// assert found.size() == 3 : "Size of list should be 3";
+// assert found.contains(person2);
+// assert found.contains(person3);
+// assert found.contains(person4) : "This should now contain object
person4";
+// }
+//
+// public void testRemoved() throws ParseException
+// {
+// queryParser = new QueryParser("blurb", new StandardAnalyzer());
+// luceneQuery = queryParser.parse("eats");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+// found = cacheQuery.list();
+//
+// assert found.size() == 2;
+// assert found.contains(person2);
+// assert found.contains(person3) : "This should still contain object
person3";
+//
+// pojo.detach("/a/b/d");
+//
+// luceneQuery = queryParser.parse("eats");
+// cacheQuery = searchableCache.createQuery(luceneQuery);
+// found = cacheQuery.list();
+//
+// assert found.size() == 1;
+// assert found.contains(person2);
+// assert !found.contains(person3) : "The search should not return
person3";
+//
+//
+// }
+//
+//}
+//
+//
+//