JBoss Cache SVN: r6507 - in searchable/trunk: src/main/java/org/jboss/cache/search and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-08-05 06:37:26 -0400 (Tue, 05 Aug 2008)
New Revision: 6507
Added:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java
Removed:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java
Modified:
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
Log:
Old changes and changed core dep to CR7
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-08-05 10:31:21 UTC (rev 6506)
+++ searchable/trunk/pom.xml 2008-08-05 10:37:26 UTC (rev 6507)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-searchable-version>0.1-SNAPSHOT</jbosscache-searchable-version>
+ <jbosscache-searchable-version>0.1-Beta1</jbosscache-searchable-version>
<!-- By default only generate Javadocs when we install the module. -->
<javadocPhase>install</javadocPhase>
</properties>
@@ -31,7 +31,7 @@
<dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-pojo</artifactId>
- <version>2.2.0.CR5</version>
+ <version>2.2.0.CR7</version>
<scope>test</scope>
</dependency>
Deleted: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java 2008-08-05 10:31:21 UTC (rev 6506)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java 2008-08-05 10:37:26 UTC (rev 6507)
@@ -1,69 +0,0 @@
-package org.jboss.cache.search;
-
-import org.hibernate.search.cfg.SearchConfiguration;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.annotations.common.reflection.ReflectionManager;
-
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * Class that implements {@link org.hibernate.search.cfg.SearchConfiguration} so that within JBossCache Searchable, there is no
- * need for a Hibernate Core configuration object.
- *
- * @author Navin Surtani - navin(a)surtani.org
- */
-public class SearchableCacheCfgImpl implements SearchConfiguration
-{
- protected Map<String, Class> classes;
- private Properties properties;
-
- public SearchableCacheCfgImpl(Class[] classArray, Properties properties)
- {
- // null chks
- if (classArray == null) throw new NullPointerException("Classes provided are null");
- this.properties = properties;
- if (this.properties == null) this.properties = new Properties();
-
- classes = new HashMap<String, Class>();
-
- // loop thru your classArray
- // populate your Map
-
- for (Class c: classArray)
- {
- String classname = c.getName();
- classes.put(classname, c);
- }
- }
-
- public Iterator getClassMappings()
- {
- return classes.values().iterator();
- }
-
- public Class getClassMapping(String name)
- {
- return classes.get(name);
- }
-
- public String getProperty(String propertyName)
- {
- return properties.getProperty(propertyName);
- }
-
- public Properties getProperties()
- {
- return properties;
- }
-
- public ReflectionManager getReflectionManager()
- {
- throw new UnsupportedOperationException("This method is not supported within JBossCache Searchable");
-
- }
-
-}
Copied: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java (from rev 6249, searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java)
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java (rev 0)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheConfiguration.java 2008-08-05 10:37:26 UTC (rev 6507)
@@ -0,0 +1,68 @@
+package org.jboss.cache.search;
+
+import org.hibernate.search.cfg.SearchConfiguration;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.annotations.common.reflection.ReflectionManager;
+
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Class that implements {@link org.hibernate.search.cfg.SearchConfiguration} so that within JBossCache Searchable, there is no
+ * need for a Hibernate Core configuration object.
+ *
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+public class SearchableCacheConfiguration implements SearchConfiguration
+{
+ protected Map<String, Class> classes;
+ private Properties properties;
+
+ public SearchableCacheConfiguration(Class[] classArray, Properties properties)
+ {
+ // null chks
+ if (classArray == null) throw new NullPointerException("Classes provided are null");
+ this.properties = properties;
+ if (this.properties == null) this.properties = new Properties();
+
+ classes = new HashMap<String, Class>();
+
+ // loop thru your classArray
+ // populate your Map
+
+ for (Class c: classArray)
+ {
+ String classname = c.getName();
+ classes.put(classname, c);
+ }
+ }
+
+ public Iterator getClassMappings()
+ {
+ return classes.values().iterator();
+ }
+
+ public Class getClassMapping(String name)
+ {
+ return classes.get(name);
+ }
+
+ public String getProperty(String propertyName)
+ {
+ return properties.getProperty(propertyName);
+ }
+
+ public Properties getProperties()
+ {
+ return properties;
+ }
+
+ public ReflectionManager getReflectionManager()
+ {
+ return null;
+ }
+
+}
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-08-05 10:31:21 UTC (rev 6506)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-08-05 10:37:26 UTC (rev 6507)
@@ -60,7 +60,7 @@
}
// step 1: create hibernate search searchFactory
- SearchConfiguration cfg = new SearchableCacheCfgImpl(classes, properties);
+ SearchConfiguration cfg = new SearchableCacheConfiguration(classes, properties);
// set classes in the cfg
SearchFactoryImplementor searchFactory = new SearchFactoryImpl(cfg);
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-08-05 10:31:21 UTC (rev 6506)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-08-05 10:37:26 UTC (rev 6507)
@@ -1,21 +1,21 @@
-//package org.jboss.cache.search;
-//
-//import org.hibernate.search.impl.SearchFactoryImpl;
-//import org.jboss.cache.notifications.event.NodeModifiedEvent;
-//import org.jboss.cache.pojo.notification.annotation.*;
-//import org.jboss.cache.pojo.notification.event.AttachedEvent;
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
-//
-//import javax.transaction.Transaction;
-//
-///**
-// * @author Navin Surtani - navin(a)surtani.org
-// */
-//
+package org.jboss.cache.search;
+
+import org.hibernate.search.impl.SearchFactoryImpl;
+import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.cache.pojo.notification.annotation.*;
+import org.jboss.cache.pojo.notification.event.AttachedEvent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.transaction.Transaction;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+
//@PojoCacheListener
-//public class SearchablePojoListener extends
-//{
+public class SearchablePojoListener //extends
+{
// private SearchFactoryImpl searchFactory;
// private static final Log log = LogFactory.getLog(SearchablePojoListener.class);
//
@@ -23,24 +23,21 @@
// {
// this.searchFactory = searchFactory;
// }
-//
-// /**
-// * Takes in a NodeModifiedEvent and updates the Lucene indexes using methods on the NodeModifiedEvent class.
-// *
-// * @param event that has occured - or a node that has been changed. {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
-// * @throws InvalidKeyException if an invalid key is given.
-// */
-//
+
+ /**
+ * Takes in a NodeModifiedEvent and updates the Lucene indexes using methods on the NodeModifiedEvent class.
+ *
+ * @param event that has occured - or a node that has been changed. {@link org.jboss.cache.notifications.event.NodeModifiedEvent}
+ * @throws InvalidKeyException if an invalid key is given.
+ */
+
// @Attached
// public void handleAttach(AttachedEvent event)
// {
// Object added = event.getSource();
-//
-//
-//
// }
-//
-//
+
+
// @Detached
// @FieldModified
// @ListModified
@@ -54,6 +51,8 @@
// if (!event.isPre())
// {
// if (log.isTraceEnabled()) log.trace("event.isPre is false. Going to start updating indexes");
+//
+//
// switch (event.getModificationType())
// {
// case PUT_MAP:
@@ -67,6 +66,6 @@
// }
// }
// }
-//
-//
-//}
+
+
+}
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-08-05 10:31:21 UTC (rev 6506)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-08-05 10:37:26 UTC (rev 6507)
@@ -3,10 +3,8 @@
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.apache.lucene.search.Sort;
-import org.apache.lucene.search.Filter;
-import org.apache.lucene.search.QueryWrapperFilter;
+import org.apache.lucene.search.*;
+import org.apache.lucene.index.Term;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
@@ -227,13 +225,22 @@
public void testSetFilter() throws ParseException
{
- queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ queryParser = new QueryParser("name", new StandardAnalyzer());
+
luceneQuery = queryParser.parse("goat");
- Filter filter = new QueryWrapperFilter(luceneQuery);
-
cacheQuery = searchableCache.createQuery(luceneQuery);
+ found = cacheQuery.list();
+ assert found.size() == 2;
+
+ Filter filter = new PrefixFilter(new Term("blurb", "cheese"));
+
cacheQuery.setFilter(filter);
+
+ found = cacheQuery.list();
+
+ assert found.size() ==1;
+
}
}
16 years, 5 months
JBoss Cache SVN: r6506 - in benchmarks/benchmark-fwk/trunk/cache-products: jbosscache-3.0.0 and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-05 06:31:21 -0400 (Tue, 05 Aug 2008)
New Revision: 6506
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh
Log:
Dont set XMX params herevi cache-products/coherence-3.3.1/config.sh
Modified: benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh 2008-08-05 10:27:36 UTC (rev 6505)
+++ benchmarks/benchmark-fwk/trunk/cache-products/coherence-3.3.1/config.sh 2008-08-05 10:31:21 UTC (rev 6506)
@@ -15,6 +15,6 @@
#--classpath was set
#additional JVM options
-export JVM_OPTIONS="$JVM_OPTIONS -Xmx2048m -Djava.net.preferIPv4Stack=true -Dtangosol.coherence.localhost=${MYTESTIP_1}"
+export JVM_OPTIONS="$JVM_OPTIONS -Djava.net.preferIPv4Stack=true -Dtangosol.coherence.localhost=${MYTESTIP_1}"
export JVM_OPTIONS="$JVM_OPTIONS -Dtangosol.coherence.cacheconfig=cache-config.xml"
export JVM_OPTIONS="$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName=org.cachebench.cachewrappers.Coherence331Wrapper"
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh 2008-08-05 10:27:36 UTC (rev 6505)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/config.sh 2008-08-05 10:31:21 UTC (rev 6506)
@@ -15,5 +15,5 @@
#--classpath was set
#additional JVM options
-JVM_OPTIONS="$JVM_OPTIONS -Djava.net.preferIPv4Stack=true -Djbosscache.config.validate=false -Xmx2048m"
+JVM_OPTIONS="$JVM_OPTIONS -Djava.net.preferIPv4Stack=true -Djbosscache.config.validate=false"
JVM_OPTIONS="$JVM_OPTIONS -DcacheBenchFwk.cacheWrapperClassName=org.cachebench.cachewrappers.JBossCache300Wrapper"
16 years, 5 months
JBoss Cache SVN: r6505 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-05 06:27:36 -0400 (Tue, 05 Aug 2008)
New Revision: 6505
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java
Log:
More efficient flat map
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java 2008-08-05 10:23:56 UTC (rev 6504)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/src/org/cachebench/cachewrappers/JBossCache300Wrapper.java 2008-08-05 10:27:36 UTC (rev 6505)
@@ -8,7 +8,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Option;
import org.jboss.cache.util.Caches;
-import org.jboss.cache.util.Caches.HashKeySelector;
import java.util.List;
import java.util.Map;
@@ -38,7 +37,7 @@
if (FLAT)
{
log.info("Using FLAT MAP wrapper");
- flatCache = Caches.asPartitionedMap(cache.getRoot(), new HashKeySelector(128));
+ flatCache = Caches.asMap(cache);
}
}
16 years, 5 months
JBoss Cache SVN: r6504 - in core/trunk/src: test/java/org/jboss/cache/util and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-05 06:23:56 -0400 (Tue, 05 Aug 2008)
New Revision: 6504
Modified:
core/trunk/src/main/java/org/jboss/cache/util/Caches.java
core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java
Log:
Update to Caches code
Modified: core/trunk/src/main/java/org/jboss/cache/util/Caches.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/Caches.java 2008-08-04 20:26:13 UTC (rev 6503)
+++ core/trunk/src/main/java/org/jboss/cache/util/Caches.java 2008-08-05 10:23:56 UTC (rev 6504)
@@ -3,6 +3,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.loader.CacheLoader;
import java.util.AbstractMap;
@@ -10,7 +11,6 @@
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
/**
@@ -36,12 +36,13 @@
/**
* Returns a {@link Map} from the root node.
*
+ * @param cache cache to wrap as a map
+ * @return a map representation of the cache
* @see #asMap(Node)
*/
- public static Map asMap(Cache cache)
+ public static <K, V> Map<K, V> asMap(Cache<K, V> cache)
{
- if (cache == null)
- throw new NullPointerException("cache");
+ if (cache == null) throw new NullPointerException("cache");
return asMap(cache.getRoot());
}
@@ -62,10 +63,13 @@
* Also, when using a {@link CacheLoader} for storage, keys used must be valid as
* part of the {@link Fqn} used in calls. Generally speaking, simple string values are
* preferred.
+ *
+ * @param node node in a cache to wrap
+ * @return a Map representation of the cache
*/
- public static Map asMap(Node node)
+ public static <K, V> Map<K, V> asMap(Node<K, V> node)
{
- return new MapNode(node);
+ return new MapNode<K, V>(node);
}
/**
@@ -83,10 +87,13 @@
* of the data at time of calling. This may be very inefficient.
* <p/>
* The map is not serializable.
+ *
+ * @param node node to wrap
+ * @return Map representation of the cache
*/
- public static Map asSimpleMap(Node node)
+ public static <K, V> Map<K, V> asSimpleMap(Node<K, V> node)
{
- return new SimpleMapNode(node);
+ return new SimpleMapNode<K, V>(node);
}
/**
@@ -100,23 +107,28 @@
* and all methods are thread safe.
* <p/>
* The set is not serializable.
+ *
+ * @param node node to wrap
+ * @return a Set representation of the values in a node
*/
- public static Set asSimpleSet(Node node)
+ public static <K, V> Set<V> asSimpleSet(Node<K, V> node)
{
- return new SimpleSetNode(node);
+ return new SimpleSetNode<V>(node);
}
/**
* Returns a {@link Map}, where map entries are partitioned into
* children nodes, within a cache node.
- * The default child selector divides the data into 16 child nodes based on hash code.
+ * The default child selector divides the data into 128 child nodes based on hash code.
* Note that for large data sets, the number of child nodes should be increased.
*
* @param node node to cache under
+ * @return a Map representation of the cache
*/
- public static Map asPartitionedMap(Node node)
+ @SuppressWarnings("unchecked")
+ public static <K, V> Map<K, V> asPartitionedMap(Node<K, V> node)
{
- return new PartitionedMapNode(node, HashKeySelector.DEFAULT);
+ return new PartitionedMapNode<K, V>(node, HashKeySelector.DEFAULT);
}
/**
@@ -132,10 +144,11 @@
*
* @param node node to cache under
* @param ss selector strategy that chooses a segment based on key
+ * @return a Map representation of the cache
*/
- public static Map asPartitionedMap(Node node, ChildSelector ss)
+ public static <K, V> Map<K, V> asPartitionedMap(Node<K, V> node, ChildSelector<K> ss)
{
- return new PartitionedMapNode(node, ss);
+ return new PartitionedMapNode<K, V>(node, ss);
}
/**
@@ -143,31 +156,36 @@
* within the cache root, by key hash code.
*
* @param cache cache to use
- * @return
+ * @return a Map representation of the cache
*/
- public static Map asPartitionedMap(Cache cache)
+ public static <K, V> Map<K, V> asPartitionedMap(Cache<K, V> cache)
{
return asPartitionedMap(cache.getRoot());
}
/**
+ * Computes an improved hash code from an object's hash code.
+ */
+ static protected final int hashCode(int i)
+ {
+ i ^= i >>> 20 ^ i >>> 12;
+ return i ^ i >>> 7 ^ i >>> 4;
+ }
+
+ /**
* Returns a segment ({@link Node#getChild(Object) child node name})
* to use based on the characteristics of a key.
* <p/>
* Here is an example class which selects a child based on a person's department:
* <pre>
- * public static class DepartmentSelector implements ChildSelector<Person>
+ * public static class DepartmentSelector implements ChildSelector<Person>
* {
- * <p/>
- * public Object childName(Person key)
- * {
- * return key.getDepartment();
+ * public Object childName(Person key)
+ * {
+ * return key.getDepartment();
+ * }
* }
- * <p/>
- * }
* </pre>
- *
- * @
*/
public interface ChildSelector<T>
{
@@ -177,21 +195,23 @@
* @param key for calls to {@link Map#put}, {@link Map#get} etc.
* @return node name
*/
- Object childName(T key);
+ Fqn childName(T key);
}
/**
* Class that returns a child name to use based on the hash code of a key.
*/
- public static class HashKeySelector implements ChildSelector
+ public static class HashKeySelector<T> implements ChildSelector<T>
{
- static ChildSelector DEFAULT = new HashKeySelector(16);
+ static ChildSelector DEFAULT = new HashKeySelector(128);
protected int segments;
/**
* Constructs with N segments, where N must be a power of 2.
+ *
+ * @param segments Number of hash segments
*/
public HashKeySelector(int segments)
{
@@ -203,42 +223,34 @@
}
/**
- * Computes an improved hash code from an object's hash code.
- */
- protected int hashCode(int i)
- {
- i ^= i >>> 20 ^ i >>> 12;
- return i ^ i >>> 7 ^ i >>> 4;
- }
-
- /**
* Returns the segment for this key, in the inclusive range 0 to {@link #segments} - 1.
*/
- protected int segmentFor(Object key)
+ protected final int segmentFor(T key)
{
if (key == null)
return 0;
int hc = key.hashCode();
- return hashCode(hc) & (segments - 1);
+ return Caches.hashCode(hc) & (segments - 1);
}
/**
* Returns the node name for this segment.
*/
- protected Object childName(int segment)
+ protected final Fqn childName(int segment)
{
- return "" + segment;//IntegerCache.toString(segment);
+ return Fqn.fromElements(Integer.toString(segment));
}
/**
* Returns the node name for this key.
* By default, returns a String containing the segment.
*/
- public Object childName(Object key)
+ public final Fqn childName(T key)
{
return childName(segmentFor(key));
}
+ @Override
public String toString()
{
return super.toString() + " segments=" + segments;
@@ -246,14 +258,14 @@
}
- static class MapNode extends AbstractMap
+ static class MapNode<K, V> extends AbstractMap<K, V>
{
public static final String KEY = "K";
- private Node node;
+ private Node node; // purposefully un-genericized
- public MapNode(Node node)
+ public MapNode(Node<K, V> node)
{
if (node == null)
throw new NullPointerException("node");
@@ -261,16 +273,16 @@
}
@Override
- public Set entrySet()
+ public Set<Map.Entry<K, V>> entrySet()
{
- return new AbstractSet()
+ return new AbstractSet<Map.Entry<K, V>>()
{
@Override
- public Iterator iterator()
+ public Iterator<Map.Entry<K, V>> iterator()
{
- final Iterator<Node> i = set().iterator();
- return new Iterator()
+ final Iterator<Node<K, V>> i = set().iterator();
+ return new Iterator<Map.Entry<K, V>>()
{
Object name;
@@ -282,13 +294,14 @@
return i.hasNext();
}
- public Object next()
+ @SuppressWarnings("unchecked")
+ public Entry<K, V> next()
{
Node n = i.next();
this.name = n.getFqn().getLastElement();
this.next = true;
Object key = n.get(KEY);
- return new SimpleEntry(name, key);
+ return new SimpleImmutableEntry(name, key);
}
public void remove()
@@ -298,6 +311,7 @@
node.removeChild(name);
}
+ @Override
public String toString()
{
return "Itr name=" + name;
@@ -306,7 +320,8 @@
};
}
- private Set<Node> set()
+ @SuppressWarnings("unchecked")
+ private Set<Node<K, V>> set()
{
return node.getChildren();
}
@@ -334,12 +349,13 @@
}
@Override
- public Object get(Object arg0)
+ @SuppressWarnings("unchecked")
+ public V get(Object arg0)
{
Node child = node.getChild(arg0);
if (child == null)
return null;
- return child.get(KEY);
+ return (V) child.get(KEY);
}
@Override
@@ -349,10 +365,10 @@
}
@Override
- public Set keySet()
+ public Set<K> keySet()
{
- return new AbstractSet()
+ return new AbstractSet<K>()
{
private Set set()
@@ -361,22 +377,23 @@
}
@Override
- public Iterator iterator()
+ public Iterator<K> iterator()
{
final Iterator i = set().iterator();
- return new Iterator()
+ return new Iterator<K>()
{
- Object child;
+ K child;
public boolean hasNext()
{
return i.hasNext();
}
- public Object next()
+ @SuppressWarnings("unchecked")
+ public K next()
{
- child = i.next();
+ child = (K) i.next();
return child;
}
@@ -408,18 +425,20 @@
}
@Override
- public Object put(Object arg0, Object arg1)
+ @SuppressWarnings("unchecked")
+ public V put(K arg0, V arg1)
{
- return node.addChild(Fqn.fromElements(arg0)).put(KEY, arg1);
+ return (V) node.addChild(Fqn.fromElements(arg0)).put(KEY, arg1);
}
@Override
- public Object remove(Object arg0)
+ @SuppressWarnings("unchecked")
+ public V remove(Object arg0)
{
Node child = node.getChild(arg0);
if (child == null)
return null;
- Object o = child.remove(KEY);
+ V o = (V) child.remove(KEY);
node.removeChild(arg0);
return o;
}
@@ -432,12 +451,12 @@
}
- static class SimpleMapNode extends AbstractMap implements java.util.Map
+ static class SimpleMapNode<K, V> extends AbstractMap<K, V>
{
- private Node node;
+ private Node<K, V> node;
- public SimpleMapNode(Node node)
+ public SimpleMapNode(Node<K, V> node)
{
if (node == null)
throw new NullPointerException("node");
@@ -465,39 +484,43 @@
/**
* getData returns a snapshot of the data.
*/
- public Set entrySet()
+ @Override
+ public Set<Map.Entry<K, V>> entrySet()
{
return node.getData().entrySet();
}
@Override
- public Object get(Object key)
+ @SuppressWarnings("unchecked")
+ public V get(Object key)
{
- return node.get(key);
+ return node.get((K) key);
}
@Override
- public Set keySet()
+ public Set<K> keySet()
{
return node.getKeys();
}
@Override
- public Object put(Object key, Object value)
+ public V put(K key, V value)
{
return node.put(key, value);
}
@Override
- public void putAll(Map map)
+ @SuppressWarnings("unchecked")
+ public void putAll(Map<? extends K, ? extends V> map)
{
- node.putAll(map);
+ node.putAll((Map) map);
}
@Override
- public Object remove(Object key)
+ @SuppressWarnings("unchecked")
+ public V remove(Object key)
{
- return node.remove(key);
+ return node.remove((K) key);
}
@Override
@@ -508,14 +531,14 @@
}
- static class SimpleSetNode extends AbstractSet implements java.util.Set
+ static class SimpleSetNode<K> extends AbstractSet<K> implements java.util.Set<K>
{
private Node node;
private static final String VALUE = "V";
- public SimpleSetNode(Node node)
+ public <K, V> SimpleSetNode(Node<K, V> node)
{
if (node == null)
throw new NullPointerException("node");
@@ -535,6 +558,7 @@
}
@Override
+ @SuppressWarnings("unchecked")
public boolean remove(Object key)
{
return node.remove(key) != null;
@@ -547,18 +571,19 @@
}
@Override
- public boolean add(Object arg0)
+ @SuppressWarnings("unchecked")
+ public boolean add(K arg0)
{
return node.put(arg0, VALUE) == null;
}
@Override
- public Iterator iterator()
+ public Iterator<K> iterator()
{
final Iterator i = node.getKeys().iterator();
- return new Iterator()
+ return new Iterator<K>()
{
- Object key;
+ K key;
boolean next = false;
@@ -567,13 +592,15 @@
return i.hasNext();
}
- public Object next()
+ @SuppressWarnings("unchecked")
+ public K next()
{
- key = i.next();
+ key = (K) i.next();
next = true;
return key;
}
+ @SuppressWarnings("unchecked")
public void remove()
{
if (!next)
@@ -586,31 +613,31 @@
}
- static class PartitionedMapNode extends AbstractMap
+ static class PartitionedMapNode<K, V> extends AbstractMap<K, V>
{
- private Node node;
+ private NodeSPI node;
- private ChildSelector selector;
+ private ChildSelector<K> selector;
- public PartitionedMapNode(Node node, ChildSelector selector)
+ public PartitionedMapNode(Node<K, V> node, ChildSelector<K> selector)
{
- this.node = node;
+ this.node = (NodeSPI) node;
this.selector = selector;
}
@Override
- public Set entrySet()
+ public Set<Map.Entry<K, V>> entrySet()
{
- return new AbstractSet<Map.Entry>()
+ return new AbstractSet<Map.Entry<K, V>>()
{
Iterator<Node> ci = node.getChildren().iterator();
@Override
- public Iterator<Entry> iterator()
+ public Iterator<Entry<K, V>> iterator()
{
- return new Iterator<Entry>()
+ return new Iterator<Entry<K, V>>()
{
Iterator ni;
@@ -620,6 +647,7 @@
findNext();
}
+ @SuppressWarnings("unchecked")
private void nextChild()
{
ni = new SimpleMapNode(ci.next()).entrySet().iterator();
@@ -640,9 +668,10 @@
return ni.hasNext();
}
- public Entry next()
+ @SuppressWarnings("unchecked")
+ public Entry<K, V> next()
{
- Entry n = (Entry) ni.next();
+ Entry<K, V> n = (Entry<K, V>) ni.next();
findNext();
return n;
}
@@ -665,15 +694,17 @@
}
@Override
+ @SuppressWarnings("unchecked")
public Set keySet()
{
- return new AbstractSet<Map.Entry>()
+ return new AbstractSet<Map.Entry<K, V>>()
{
@Override
- public Iterator<Entry> iterator()
+ @SuppressWarnings("unchecked")
+ public Iterator<Entry<K, V>> iterator()
{
- return PartitionedMapNode.super.keySet().iterator();
+ return (Iterator<Entry<K, V>>) PartitionedMapNode.super.keySet().iterator();
}
@Override
@@ -706,40 +737,38 @@
node.getChild(o).clearData();
}
- private Node nodeFor(Object o)
+ @SuppressWarnings("unchecked")
+ private Fqn fqnFor(Object o)
{
- return node.getChild(selector.childName(o));
+ return Fqn.fromRelativeFqn(node.getFqn(), selector.childName((K) o));
}
@Override
+ @SuppressWarnings("unchecked")
public boolean containsKey(Object o)
{
- Node n = nodeFor(o);
- if (n == null) return false;
- return n.getKeys().contains(o);
+ Fqn fqn = fqnFor(o);
+ Set keys = node.getCache().getKeys(fqn);
+ return keys != null && keys.contains(o);
}
@Override
- public Object get(Object o)
+ @SuppressWarnings("unchecked")
+ public V get(Object key)
{
- Node n = nodeFor(o);
- if (n == null) return null;
- return n.get(o);
+ return (V) node.getCache().get(fqnFor(key), key);
}
+ @SuppressWarnings("unchecked")
public Object put(Object key, Object value)
{
- Object name = selector.childName(key);
- Node n = node.getChild(name);
- if (n == null)
- n = node.addChild(Fqn.fromElements(name));
- return n.put(key, value);
+ return node.getCache().put(fqnFor(key), key, value);
}
- public Object remove(Object o)
+ @SuppressWarnings("unchecked")
+ public V remove(Object key)
{
- Node n = nodeFor(o);
- return n.remove(o);
+ return (V) node.getCache().remove(fqnFor(key), key);
}
public int size()
@@ -752,65 +781,5 @@
}
return size;
}
-
}
-
- public static class SimpleEntry<K, V> implements Entry<K, V>
- {
- K key;
- V value;
-
- public SimpleEntry(K key, V value)
- {
- this.key = key;
- this.value = value;
- }
-
- public SimpleEntry(Entry<K, V> e)
- {
- this.key = e.getKey();
- this.value = e.getValue();
- }
-
- public K getKey()
- {
- return key;
- }
-
- public V getValue()
- {
- return value;
- }
-
- public V setValue(V value)
- {
- V oldValue = this.value;
- this.value = value;
- return oldValue;
- }
-
- public boolean equals(Object o)
- {
- if (!(o instanceof Map.Entry))
- return false;
- Map.Entry e = (Map.Entry) o;
- return eq(key, e.getKey()) && eq(value, e.getValue());
- }
-
- public int hashCode()
- {
- return ((key == null) ? 0 : key.hashCode()) ^
- ((value == null) ? 0 : value.hashCode());
- }
-
- public String toString()
- {
- return key + "=" + value;
- }
-
- private static boolean eq(Object o1, Object o2)
- {
- return (o1 == null ? o2 == null : o1.equals(o2));
- }
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java 2008-08-04 20:26:13 UTC (rev 6503)
+++ core/trunk/src/test/java/org/jboss/cache/util/CachesTest.java 2008-08-05 10:23:56 UTC (rev 6504)
@@ -1,12 +1,14 @@
package org.jboss.cache.util;
+import junit.framework.TestCase;
import org.jboss.cache.Cache;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.DataContainerImpl;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.util.Caches.ChildSelector;
-import org.jboss.cache.util.Caches.SimpleEntry;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.Test;
import java.util.Collection;
import java.util.Iterator;
@@ -16,8 +18,7 @@
/**
* Tests {@link Caches}.
*/
-@Test(groups = "functional")
-public class CachesTest
+public class CachesTest extends TestCase
{
String a = "a";
@@ -25,11 +26,11 @@
String c = "c";
- Cache<Object, Object> cache = new DefaultCacheFactory<Object, Object>().createCache();
+ Cache cache = new DefaultCacheFactory().createCache();
public void testSegment()
{
- Map<Object, Object> m = Caches.asPartitionedMap(cache);
+ Map m = Caches.asPartitionedMap(cache);
// m.put(a, b);
testMap(m);
m.clear();
@@ -42,14 +43,13 @@
{
assertEquals("foo " + i, m.get(Integer.toHexString(i)));
}
- System.out.println(CachePrinter.printCacheDetails(cache));
}
public void testAsMap()
{
- Map<Object, Object> m = Caches.asMap(cache);
+ Map m = Caches.asMap(cache);
testMap(m);
- for (Node n : cache.getRoot().getChildren())
+ for (Node n : (Set<Node>) cache.getRoot().getChildren())
{
assertEquals("/a", n.getFqn().toString());
assertEquals(c, n.get("K"));
@@ -141,10 +141,10 @@
assertEquals(false, i.hasNext());
assertEquals(true, m.keySet().contains(c));
- assertEquals(true, m.entrySet().contains(new SimpleEntry(c, a)));
+ assertEquals(true, m.entrySet().contains(new SimpleImmutableEntry(c, a)));
assertEquals(true, m.values().contains(a));
assertEquals(false, m.keySet().contains(a));
- assertEquals(false, m.entrySet().contains(new SimpleEntry(a, c)));
+ assertEquals(false, m.entrySet().contains(new SimpleImmutableEntry(a, c)));
assertEquals(false, m.values().contains(c));
assertEquals(false, m.isEmpty());
m.clear();
@@ -173,9 +173,15 @@
m.put(h, 21);
assertEquals(42, m.get(f));
assertEquals(69, m.get(g));
- System.out.println(CachePrinter.printCacheDetails(cache));
+ System.out.println(printDetails(cache));
}
+ private String printDetails(Cache c)
+ {
+ DataContainer dc = ((CacheInvocationDelegate) c).getDataContainer();
+ return ((DataContainerImpl) dc).printDetails();
+ }
+
public static class Person
{
String name;
@@ -203,9 +209,9 @@
public static class DepartmentSelector implements ChildSelector<Person>
{
- public Object childName(Person key)
+ public Fqn childName(Person key)
{
- return key.getDepartment();
+ return Fqn.fromElements(key.getDepartment());
}
}
16 years, 5 months
JBoss Cache SVN: r6503 - core/trunk/src/main/java/org/jboss/cache/util/concurrent.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-04 16:26:13 -0400 (Mon, 04 Aug 2008)
New Revision: 6503
Modified:
core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java
Log:
Worked around http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java 2008-08-04 16:57:25 UTC (rev 6502)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java 2008-08-04 20:26:13 UTC (rev 6503)
@@ -67,22 +67,30 @@
throw new UnsupportedOperationException();
}
- public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks) throws InterruptedException
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public List invokeAll(Collection tasks) throws InterruptedException
{
throw new UnsupportedOperationException();
}
- public <T> List<Future<T>> invokeAll(Collection<Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public List invokeAll(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException
{
throw new UnsupportedOperationException();
}
- public <T> T invokeAny(Collection<Callable<T>> tasks) throws InterruptedException, ExecutionException
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public Object invokeAny(Collection tasks) throws InterruptedException, ExecutionException
{
throw new UnsupportedOperationException();
}
- public <T> T invokeAny(Collection<Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
+ @SuppressWarnings("unchecked")
+ // unchecked on purpose due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6267833
+ public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
{
throw new UnsupportedOperationException();
}
16 years, 5 months
JBoss Cache SVN: r6502 - benchmarks/benchmark-fwk/trunk.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-04 12:57:25 -0400 (Mon, 04 Aug 2008)
New Revision: 6502
Modified:
benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh
Log:
cluster.sh will be called with nohup
Modified: benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh 2008-08-04 16:30:04 UTC (rev 6501)
+++ benchmarks/benchmark-fwk/trunk/allJBossCacheTests.sh 2008-08-04 16:57:25 UTC (rev 6502)
@@ -1,10 +1,9 @@
#!/bin/bash
scaling="2 4 6 8"
-#scaling="2 4 6 8 10"
-#scaling="2 4"
-configs="pess-repl-async.xml pess-repl-sync.xml pess-repl-async-br.xml"
-products="jbosscache-2.0.0 jbosscache-2.1.0"
+configs="pess-repl-sync.xml pess-repl-sync-br.xml pess-repl-async.xml mvcc-repl-sync.xml mvcc-repl-sync-br.xml mvcc-repl-async.xml"
+#configs="distributed replicated"
+products="jbosscache-3.0.0"
mkdir output
@@ -14,7 +13,7 @@
do
for size in $scaling
do
- ./cluster.sh start $product $config $size
+ nohup ./cluster.sh start $product $config $size
outputFileName=data_${product}_${config}_${size}.csv
while [ ! -e $outputFileName ]
16 years, 5 months
JBoss Cache SVN: r6501 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-04 12:30:04 -0400 (Mon, 04 Aug 2008)
New Revision: 6501
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
Log:
updated jbc jar
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
===================================================================
(Binary files differ)
16 years, 5 months
JBoss Cache SVN: r6500 - in core/trunk/src: test/java/org/jboss/cache/config/parsing and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-04 11:57:29 -0400 (Mon, 04 Aug 2008)
New Revision: 6500
Modified:
core/trunk/src/main/resources/jbosscache-config-3.0.xsd
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
Log:
schema now supports the 'listeners' configuration elements
Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-04 15:56:43 UTC (rev 6499)
+++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-08-04 15:57:29 UTC (rev 6500)
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <!-- todo mmarkus - maxOccurs can be added for some elements, revisit that -->
+
<xs:element name="jbosscache">
<xs:complexType>
<xs:all>
- <xs:element name="locking" type="lockingType" minOccurs="0"/>
- <xs:element name="transaction" type="transactionType" minOccurs="0"/>
- <xs:element name="startup" type="startupType" minOccurs="0"/>
- <xs:element name="stateRetrieval" type="stateRetrievalType" minOccurs="0"/>
- <xs:element name="shutdown" type="shutdownType" minOccurs="0"/>
- <xs:element name="serialization" type="serializationType" minOccurs="0"/>
- <xs:element name="replication" type="replicationType" minOccurs="0"/>
- <xs:element name="invalidation" type="invalidationType" minOccurs="0"/>
- <xs:element name="jmxStatistics" type="jmxStatisticsType" minOccurs="0"/>
- <xs:element name="transport" type="transportType" minOccurs="0"/>
- <xs:element name="eviction" type="evictionType" minOccurs="0"/>
- <xs:element name="loaders" type="loadersType" minOccurs="0"/>
+ <xs:element name="locking" type="lockingType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="transaction" type="transactionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="startup" type="startupType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="stateRetrieval" type="stateRetrievalType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="shutdown" type="shutdownType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="serialization" type="serializationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="replication" type="replicationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="invalidation" type="invalidationType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="jmxStatistics" type="jmxStatisticsType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="listeners" type="listenersType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="transport" type="transportType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="eviction" type="evictionType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="loaders" type="loadersType" minOccurs="0" maxOccurs="1"/>
<xs:element name="customInterceptors" type="customInterceptorsType" minOccurs="0"/>
</xs:all>
</xs:complexType>
@@ -95,17 +96,17 @@
<xs:element name="sync" type="syncType" minOccurs="0" maxOccurs="1"/>
<xs:element name="async" type="asyncType" minOccurs="0" maxOccurs="1"/>
</xs:choice>
- <xs:element name="buddy" minOccurs="0">
+ <xs:element name="buddy" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all minOccurs="0">
- <xs:element name="dataGravitation">
+ <xs:element name="dataGravitation" maxOccurs="1">
<xs:complexType>
<xs:attribute name="auto" type="booleanType"/>
<xs:attribute name="removeOnFind" type="booleanType"/>
<xs:attribute name="searchBackupTrees" type="booleanType"/>
</xs:complexType>
</xs:element>
- <xs:element name="locator">
+ <xs:element name="locator" maxOccurs="1">
<xs:complexType>
<xs:all>
<xs:element name="properties" type="xs:string" maxOccurs="1"/>
@@ -133,6 +134,10 @@
<xs:attribute name="enabled" type="booleanType"/>
</xs:complexType>
+ <xs:complexType name="listenersType">
+ <xs:attribute name="asyncPoolSize" type="positiveInteger"/>
+ </xs:complexType>
+
<xs:complexType name="transportType">
<xs:sequence>
<xs:element name="jgroupsConfig" type="xs:anyType" minOccurs="0" maxOccurs="1"/>
@@ -154,7 +159,7 @@
<xs:complexType name="evictionType">
<xs:sequence>
- <xs:element name="default" type="evictionRegionType" minOccurs="0"/>
+ <xs:element name="default" type="evictionRegionType" minOccurs="0" maxOccurs="1"/>
<xs:element name="region" minOccurs="0" maxOccurs="unbounded" type="evictionRegionType"/>
</xs:sequence>
<xs:attribute name="wakeUpInterval" type="positiveInteger" use="required"/>
@@ -173,7 +178,7 @@
<xs:complexType name="loadersType">
<xs:sequence>
- <xs:element name="preload" maxOccurs="1">
+ <xs:element name="preload" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
@@ -188,10 +193,10 @@
<xs:complexType>
<xs:all>
<xs:element name="properties"/>
- <xs:element name="singletonStore" minOccurs="0">
+ <xs:element name="singletonStore" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:all>
- <xs:element name="properties" type="xs:string"/>
+ <xs:element name="properties" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:all>
<xs:attribute name="enabled" type="booleanType"/>
<xs:attribute name="class" type="xs:string"/>
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-04 15:56:43 UTC (rev 6499)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-04 15:57:29 UTC (rev 6500)
@@ -46,6 +46,7 @@
{
System.out.println("file = " + file);
parser.parseFile(BASE_DIR_FOR_CONFIG + File.separator + file);
+ System.out.println("Processed file = " + file);
for (Exception e : handler.exceptionList) e.printStackTrace();
assert handler.noErrors() : "error during parsing (file " + file + ")";
}
16 years, 5 months
JBoss Cache SVN: r6499 - core/trunk/src/main/java/org/jboss/cache/config/parsing.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-04 11:56:43 -0400 (Mon, 04 Aug 2008)
New Revision: 6499
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
Log:
now It is possible to override the schema with one specified through a custom porperty
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-08-04 14:42:47 UTC (rev 6498)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-08-04 15:56:43 UTC (rev 6499)
@@ -50,10 +50,12 @@
* Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.Configuration} object.
* By default this class uses a validating parser (configurable).
* <p/>
- * In order to make the parser non-validating by default, the follwing system property is expected:
- * <b>-Djbosscache.config.validate=false</b>
- * <p/>
- * Implementation note: this class is stateful and one instance should be used for parsing a single configuration file.
+ * Following system properties can be used for customizing parser behavior:
+ * <ul>
+ * <li> <b>-Djbosscache.config.validate=false</b> will make the parser non-validating </li>
+ * <li> <b>-Djbosscache.config.schemaLocation=url</b> allows one to specify a validation schema that would override the one specified in the the xml document </li>
+ * </ul>
+ * This class is stateful and one instance should be used for parsing a single configuration file.
*
* @author Mircea.Markus(a)jboss.com
* @since 3.0
@@ -63,6 +65,7 @@
private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
+ public static final String SCHEMA_LOCATION_SYSTEM_PROPERTY = "jbosscache.config.schemaLocation";
/**
* the resulting configuration.
@@ -71,6 +74,7 @@
private Element root;
private ErrorHandler errorHandler;
private boolean isValidating;
+ private String schemaLocation;
/**
* If validation is on (default) one can specify an error handler for handling validation errors.
@@ -80,6 +84,7 @@
{
this.errorHandler = errorHandler;
isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
+ schemaLocation = System.getProperty(SCHEMA_LOCATION_SYSTEM_PROPERTY);
}
/**
@@ -387,6 +392,15 @@
docBuilderFactory.setValidating(true);
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+ if (schemaLocation != null)
+ {
+ if (log.isTraceEnabled()) log.trace("Using the schema location set to: '" + schemaLocation + '\'');
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaLocation);
+ }
+ else if (log.isTraceEnabled())
+ {
+ log.trace("Validation is enabled, using the schema decalred in the .xml configuration file");
+ }
}
DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
parser.setErrorHandler(errorHandler);
16 years, 5 months
JBoss Cache SVN: r6498 - pojo/trunk/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-04 10:42:47 -0400 (Mon, 04 Aug 2008)
New Revision: 6498
Modified:
pojo/trunk/src/test/resources/log4j.xml
Log:
Reduced log levels
Modified: pojo/trunk/src/test/resources/log4j.xml
===================================================================
--- pojo/trunk/src/test/resources/log4j.xml 2008-08-04 14:22:30 UTC (rev 6497)
+++ pojo/trunk/src/test/resources/log4j.xml 2008-08-04 14:42:47 UTC (rev 6498)
@@ -63,7 +63,7 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="DEBUG"/>
+ <priority value="WARN"/>
</category>
<category name="org.jboss.tm">
16 years, 5 months