JBoss Cache SVN: r6248 - in core/trunk/src: main/java/org/jboss/cache/config/parsing/element and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-07-11 09:58:16 -0400 (Fri, 11 Jul 2008)
New Revision: 6248
Modified:
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml
Log:
fail early if trying to set an attribute that does not exist on an configuration object
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-07-11 10:14:00 UTC (rev 6247)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-07-11 13:58:16 UTC (rev 6248)
@@ -426,7 +426,7 @@
return defaultValue;
}
- public static void setValues(Object target, Map<?, ?> attribs, boolean isXmlAttribs)
+ public static void setValues(Object target, Map<?, ?> attribs, boolean isXmlAttribs, boolean failOnMissingSetter)
{
Class objectClass = target.getClass();
@@ -491,6 +491,7 @@
{
m.invoke(target, parameter);
setterFound = true;
+ break;
}
catch (Exception e)
{
@@ -498,7 +499,7 @@
}
}
}
- if (!setterFound) throw new ConfigurationException("Couldn't find a setter method for parameter " + propName);
+ if (!setterFound && failOnMissingSetter) throw new ConfigurationException("Couldn't find a setter method for parameter " + propName);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-07-11 10:14:00 UTC (rev 6247)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-07-11 13:58:16 UTC (rev 6248)
@@ -99,7 +99,7 @@
handleRenamedAttributes(attributes);
Configuration c = new Configuration();
- XmlConfigHelper.setValues(c, attributes.stringAttribs, false);
+ XmlConfigHelper.setValues(c, attributes.stringAttribs, false, false);
// Special handling for XML elements -- we hard code the parsing
setXmlValues(c, attributes.xmlAttribs);
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java 2008-07-11 10:14:00 UTC (rev 6247)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java 2008-07-11 13:58:16 UTC (rev 6248)
@@ -106,7 +106,7 @@
throw new ConfigurationException("CommandInterceptor class is not properly loaded in classloader", e);
}
ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
- XmlConfigHelper.setValues(result, attributes.stringAttribs, false);
+ XmlConfigHelper.setValues(result, attributes.stringAttribs, false, true);
return result;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-07-11 10:14:00 UTC (rev 6247)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-07-11 13:58:16 UTC (rev 6248)
@@ -122,8 +122,8 @@
{
target.reset();
ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
- XmlConfigHelper.setValues(target, attributes.stringAttribs, false);
- XmlConfigHelper.setValues(target, attributes.xmlAttribs, true);
+ XmlConfigHelper.setValues(target, attributes.stringAttribs, false, true);
+ XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true);
target.validate();
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-07-11 10:14:00 UTC (rev 6247)
+++ core/trunk/src/test/java/org/jboss/cache/config/ConfigurationTransformerTest.java 2008-07-11 13:58:16 UTC (rev 6248)
@@ -50,8 +50,11 @@
public void testEqualityOnTransformedFiles() throws Exception
{
- String[] fileNames = {"buddy-replication-cache.xml", "cacheloader-enabled-cache.xml",
- "eviction-enabled-cache.xml", "local-cache.xml", "multiplexer-enabled-cache.xml",
+ String[] fileNames = {
+ "buddy-replication-cache.xml",
+ "cacheloader-enabled-cache.xml",
+ "eviction-enabled-cache.xml",
+ "local-cache.xml", "multiplexer-enabled-cache.xml",
"optimistically-locked-cache.xml", "total-replication-cache.xml", "clonable-config.xml",
"policyPerRegion-eviction.xml" , "default-test-config2x.xml"};
for (String file : fileNames)
@@ -60,6 +63,7 @@
String fileName = getFileName(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
convertor.parse(fileName, baos, XSLT_FILE);
+// System.out.println("result = \n" + baos);
XmlConfigurationParser newParser = new XmlConfigurationParser();
XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
Modified: core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml
===================================================================
--- core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml 2008-07-11 10:14:00 UTC (rev 6247)
+++ core/trunk/src/test/resources/configs/conf2x/eviction-enabled-cache.xml 2008-07-11 13:58:16 UTC (rev 6248)
@@ -66,7 +66,6 @@
</region>
<region name="/org/jboss/data" policyClass="org.jboss.cache.eviction.LFUPolicy">
<attribute name="maxNodes">5000</attribute>
- <attribute name="timeToLiveSeconds">1000</attribute>
</region>
<region name="/org/jboss/test/data">
<attribute name="maxNodes">5</attribute>
17 years, 5 months
JBoss Cache SVN: r6247 - in core/trunk/src: main/java/org/jboss/cache/config/parsing and 10 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-07-11 06:14:00 -0400 (Fri, 11 Jul 2008)
New Revision: 6247
Added:
core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/
core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/AaaCustomInterceptor.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/BbbCustomInterceptor.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/WrongCustomInterceptor.java
core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java
core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/resources/all-elements-file-3.x.xml
core/trunk/src/main/resources/jbosscache-config-3.0.xsd
core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
core/trunk/src/test/resources/configs/parser-test.xml
Log:
added custom interceptors support
Modified: core/trunk/src/main/java/org/jboss/cache/config/Configuration.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/config/Configuration.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -924,11 +924,19 @@
this.muxStackName = muxStackName;
}
+ /**
+ * Returns the {@link org.jboss.cache.config.CustomInterceptorConfig}, if any, associated with this configuration
+ * object. The custom interceptors will be added to the cache at startup in the sequence defined by this list.
+ * @return List of cutom interceptors, never null
+ */
public List<CustomInterceptorConfig> getCustomInterceptors()
{
- return customInterceptors;
+ return customInterceptors == null ? Collections.EMPTY_LIST : customInterceptors;
}
+ /**
+ * @see #getCustomInterceptors()
+ */
public void setCustomInterceptors(List<CustomInterceptorConfig> customInterceptors)
{
testImmutability("customInterceptors");
Modified: core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/config/CustomInterceptorConfig.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -1,83 +1,156 @@
package org.jboss.cache.config;
import net.jcip.annotations.Immutable;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
-import java.io.Serializable;
-import java.util.Properties;
-import java.util.Collections;
-import java.util.Map;
-
/**
* Holds information about the custom interceptors defined in the configuration file.
- * todo : As a tip on your CustomInterceptorConfig, you should consider extending ConfigurationComponent which gives you a lot of the basic stuff you need.
*
* @author Mircea.Markus(a)jboss.com
* @since 3.0
*/
-@Immutable
-public class CustomInterceptorConfig implements Cloneable, Serializable
+@Immutable
+public class CustomInterceptorConfig extends ConfigurationComponent
{
- private String interceptorClass;
+ private CommandInterceptor interceptor;
private boolean isFirst;
private boolean isLast;
private int index = -1;
private String afterClass;
private String beforeClass;
- private Map properties;
- public CustomInterceptorConfig(String interceptorClass, boolean first, boolean last, int index, String afterClass, String beforeClass, Properties props)
+ /**
+ * Builds a custom interceptor.
+ *
+ * @param interceptor interceptor instance, already initialized with all attributes specified in the configuration
+ * @param first true if you wan this to be the first interceptor in the chain
+ * @param last true if you wan this to be the last interceptor in the chain
+ * @param index an absolute position within the interceptor chain
+ * @param afterClass if you want this interceptor immediately after the specified class in the chain
+ * @param beforeClass immediately before the specified class in the chain
+ */
+ public CustomInterceptorConfig(CommandInterceptor interceptor, boolean first, boolean last, int index,
+ String afterClass, String beforeClass)
{
- this.interceptorClass = interceptorClass;
+ this.interceptor = interceptor;
isFirst = first;
isLast = last;
this.index = index;
this.afterClass = afterClass;
this.beforeClass = beforeClass;
- this.properties = Collections.unmodifiableMap(props);
}
- public String getInterceptorClass()
+ /**
+ * Constructs an interceptor config based on the supplied interceptor instance.
+ *
+ * @param interceptor
+ */
+ public CustomInterceptorConfig(CommandInterceptor interceptor)
{
- return interceptorClass;
+ this.interceptor = interceptor;
}
+ /**
+ * Shall this interceptor be the first one in the chain?
+ */
+ public void setFirst(boolean first)
+ {
+ testImmutability("first");
+ isFirst = first;
+ }
+
+ /**
+ * Shall this intercepto be the last one in the chain?
+ */
+ public void setLast(boolean last)
+ {
+ testImmutability("last");
+ isLast = last;
+ }
+
+ /**
+ * Put this interceptor at the specified index, after the default chain is built.
+ * If the index is not valid (negative or grater than the size of the chain)
+ * an {@link org.jboss.cache.config.ConfigurationException} is thrown at construction time.
+ */
+ public void setIndex(int index)
+ {
+ testImmutability("index");
+ this.index = index;
+ }
+
+ /**
+ * Adds the interceptor immediately after the first occurance of an interceptor having the given class.
+ * If the chain does not contain such an interceptor then this interceptor definition is ignored.
+ */
+ public void setAfterClass(String afterClass)
+ {
+ testImmutability("afterClass");
+ this.afterClass = afterClass;
+ }
+
+ /**
+ * Adds the interceptor immediately before the first occurance of an interceptor having the given class.
+ * If the chain does not contain such an interceptor then this interceptor definition is ignored.
+ */
+ public void setBeforeClass(String beforeClass)
+ {
+ testImmutability("beforeClass");
+ this.beforeClass = beforeClass;
+ }
+
+ /**
+ * Returns a the interceptor that we want to add to the chain.
+ */
+ public CommandInterceptor getInterceptor()
+ {
+ return interceptor;
+ }
+
+ /**
+ * @see #setFirst(boolean)
+ */
public boolean isFirst()
{
return isFirst;
}
+ /**
+ * @see #setLast(boolean)
+ */
public boolean isLast()
{
return isLast;
}
+ /**
+ * @see #getIndex()
+ */
public int getIndex()
{
return index;
}
+ /**
+ * @see #getAfterClass()
+ */
public String getAfterClass()
{
return afterClass;
}
+ /**
+ * @see #getBeforeClass()
+ */
public String getBeforeClass()
{
return beforeClass;
}
- /**
- * Returns an unmodifiable map of set properties.
- */
- public Map getProperties()
- {
- return properties;
- }
-
public String toString()
{
return "CustomInterceptorConfig{" +
- "interceptorClass='" + interceptorClass + '\'' +
+ "interceptor='" + interceptor + '\'' +
", isFirst=" + isFirst +
", isLast=" + isLast +
", index=" + index +
@@ -98,36 +171,32 @@
if (isLast != that.isLast) return false;
if (afterClass != null ? !afterClass.equals(that.afterClass) : that.afterClass != null) return false;
if (beforeClass != null ? !beforeClass.equals(that.beforeClass) : that.beforeClass != null) return false;
- if (interceptorClass != null ? !interceptorClass.equals(that.interceptorClass) : that.interceptorClass != null)
+ if (interceptor != null ? !interceptor.equals(that.interceptor) : that.interceptor != null)
return false;
- if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
-
return true;
}
public int hashCode()
{
int result;
- result = (interceptorClass != null ? interceptorClass.hashCode() : 0);
+ result = (interceptor != null ? interceptor.hashCode() : 0);
result = 31 * result + (isFirst ? 1 : 0);
result = 31 * result + (isLast ? 1 : 0);
result = 31 * result + index;
result = 31 * result + (afterClass != null ? afterClass.hashCode() : 0);
result = 31 * result + (beforeClass != null ? beforeClass.hashCode() : 0);
- result = 31 * result + (properties != null ? properties.hashCode() : 0);
return result;
}
@Override
- protected Object clone() throws CloneNotSupportedException
+ public CustomInterceptorConfig clone() throws CloneNotSupportedException
{
CustomInterceptorConfig dolly = (CustomInterceptorConfig) super.clone();
- dolly.interceptorClass = interceptorClass;
+ dolly.interceptor = interceptor;
dolly.isFirst = isFirst;
dolly.isLast = isLast;
dolly.afterClass = afterClass;
dolly.beforeClass = beforeClass;
- dolly.properties = properties;
return dolly;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -178,6 +178,7 @@
/**
* Use {@link #getWakeupIntervalSeconds()}.
+ * todo mmarkus remove all the references of this method from the code
*/
@Deprecated
public int getWakeupIntervalSeconds()
Modified: core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -155,14 +155,6 @@
}
/**
- * Convenience method, equivalent to calling <tt>getSubElement(element, "config");</tt>
- */
- public static Element getConfigSubElement(Element element)
- {
- return getSubElement(element, CONFIG_ATTR);
- }
-
- /**
* Returns a named sub-element of the current element passed in.
* <p/>
* None of the parameters should be null - otherwise the method may throw a NullPointerException.
@@ -471,6 +463,7 @@
throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
}
+ boolean setterFound = false;
// if we get here, we could not find a String or Element setter.
for (Method m : objectClass.getMethods())
{
@@ -497,6 +490,7 @@
try
{
m.invoke(target, parameter);
+ setterFound = true;
}
catch (Exception e)
{
@@ -504,6 +498,7 @@
}
}
}
+ if (!setterFound) throw new ConfigurationException("Couldn't find a setter method for parameter " + propName);
}
}
@@ -529,15 +524,14 @@
if (valueStr.length() == 0)
{
// This may be an XML element ...
- valueXml = getConfigSubElement(element);
+ valueXml = getSubElement(element, CONFIG_ATTR);
+ if (valueXml != null) xmlAttribs.put(name, valueXml);
}
-
- // add these to the maps.
-
- if (valueStr.length() > 0) stringAttribs.put(name, valueStr);
- if (valueXml != null) xmlAttribs.put(name, valueXml);
+ else
+ {
+ if (valueStr.length() > 0) stringAttribs.put(name, valueStr);
+ }
}
-
return new ParsedAttributes(stringAttribs, xmlAttribs);
}
}
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-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -27,6 +27,7 @@
import org.jboss.cache.config.parsing.element.BuddyElementParser;
import org.jboss.cache.config.parsing.element.EvictionElementParser;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
+import org.jboss.cache.config.parsing.element.CustomInterceptorsElementParser;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.util.FileLookup;
import org.w3c.dom.Document;
@@ -224,29 +225,9 @@
private void configureCustomInterceptors(Element element)
{
if (element == null) return; //this element might be missing
- NodeList interceptorNodes = element.getElementsByTagName("interceptor");
- List<CustomInterceptorConfig> interceptorConfigs = new ArrayList<CustomInterceptorConfig>(interceptorNodes.getLength());
- for (int i = 0; i < interceptorNodes.getLength(); i++)
- {
- Element interceptorElement = (Element) interceptorNodes.item(i);
- String interceptorClass = getAttributeValue(interceptorElement, "class");
- Properties props = XmlConfigHelper.readPropertiesContents(interceptorElement, "properties");
- Element position = getSingleElement("position", interceptorElement);
- String firstStr = getAttributeValue(position, "first");
- boolean first = existsAttribute(firstStr) && getBoolean(firstStr);
- String lastStr = getAttributeValue(position, "last");
- boolean last = existsAttribute(lastStr) && getBoolean(lastStr);
- String indexStr = getAttributeValue(position, "index");
- int index = existsAttribute(indexStr) ? getInt(indexStr) : -1;
- String before = getAttributeValue(position, "before");
- if (!existsAttribute(before)) before = null;
- String after = getAttributeValue(position, "after");
- if (!existsAttribute(after)) after = null;
- CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptorClass, first, last,
- index, after, before, props);
- interceptorConfigs.add(customInterceptorConfig);
- }
- config.setCustomInterceptors(interceptorConfigs);
+ CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser();
+ List<CustomInterceptorConfig> interceptorConfigList = parser.parseCustomInterceptors(element);
+ config.setCustomInterceptors(interceptorConfigList);
}
private void configureBuddyReplication(Element element)
Added: core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.config.parsing.element;
+
+import org.jboss.cache.config.CustomInterceptorConfig;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.cache.config.parsing.ParsedAttributes;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.util.Util;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility class for parsing 'buddy' element in the .xml configuration file.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class CustomInterceptorsElementParser extends XmlParserBase
+{
+ /**
+ * Iterates within the given element looking for custom interceptors.
+ *
+ * @param element should not be null
+ * @return a list which might be empty, never null
+ */
+ public List<CustomInterceptorConfig> parseCustomInterceptors(Element element)
+ {
+ NodeList interceptorNodes = element.getElementsByTagName("interceptor");
+ List<CustomInterceptorConfig> interceptorConfigs = new ArrayList<CustomInterceptorConfig>(interceptorNodes.getLength());
+ for (int i = 0; i < interceptorNodes.getLength(); i++)
+ {
+ boolean first = false;
+ boolean last = false;
+ int index = -1;
+ String after = null;
+ String before = null;
+
+ Element interceptorElement = (Element) interceptorNodes.item(i);
+ String position = getAttributeValue(interceptorElement, "position");
+ if (existsAttribute(position) && "first".equalsIgnoreCase(position))
+ {
+ first = true;
+ }
+ if (existsAttribute(position) && "last".equalsIgnoreCase(position))
+ {
+ last = true;
+ }
+ String indexStr = getAttributeValue(interceptorElement, "index");
+ index = existsAttribute(indexStr) ? getInt(indexStr) : -1;
+
+ before = getAttributeValue(interceptorElement, "before");
+ if (!existsAttribute(before)) before = null;
+ after = getAttributeValue(interceptorElement, "after");
+ if (!existsAttribute(after)) after = null;
+
+ CommandInterceptor interceptor = buildCommandInterceptor(interceptorElement);
+
+ CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptor, first, last, index, after, before);
+ interceptorConfigs.add(customInterceptorConfig);
+ }
+ return interceptorConfigs;
+ }
+
+ /**
+ * Builds the interceptor based on the interceptor class and also sets all its attributes.
+ */
+ private CommandInterceptor buildCommandInterceptor(Element element)
+ {
+ String interceptorClass = getAttributeValue(element, "class");
+ CommandInterceptor result;
+ try
+ {
+ result = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("CommandInterceptor class is not properly loaded in classloader", e);
+ }
+ ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
+ XmlConfigHelper.setValues(result, attributes.stringAttribs, false);
+ return result;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -9,10 +9,13 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.CustomInterceptorConfig;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.interceptors.*;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import java.util.List;
+
/**
* Factory class that builds an interceptor chain based on cache configuration.
*
@@ -138,10 +141,45 @@
if (optimistic) interceptorChain.appendIntereceptor(createInterceptor(OptimisticNodeInterceptor.class));
CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
interceptorChain.appendIntereceptor(callInterceptor);
- if (log.isTraceEnabled()) log.trace("Finished building interceptor chain.");
+ if (log.isTraceEnabled()) log.trace("Finished building default interceptor chain.");
+ buildCustomInterceptors(interceptorChain, configuration.getCustomInterceptors());
return interceptorChain;
}
+ private void buildCustomInterceptors(InterceptorChain interceptorChain, List<CustomInterceptorConfig> customInterceptors)
+ {
+ for (CustomInterceptorConfig config : customInterceptors)
+ {
+ if (interceptorChain.containsInstance(config.getInterceptor())) continue;
+ if (config.isFirst())
+ {
+ interceptorChain.addInterceptor(config.getInterceptor(),0);
+ }
+ if (config.isLast()) interceptorChain.appendIntereceptor(config.getInterceptor());
+ if (config.getIndex() >= 0) interceptorChain.addInterceptor(config.getInterceptor(), config.getIndex());
+ if (config.getAfterClass() != null)
+ {
+ List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClassName(config.getAfterClass());
+ if (withClassName.isEmpty())
+ {
+ throw new ConfigurationException("Cannot add after class: " + config.getAfterClass()
+ + " as no such iterceptor exists in the default chain");
+ }
+ interceptorChain.addAfterInterceptor(config.getInterceptor(), withClassName.get(0).getClass());
+ }
+ if (config.getBeforeClass() != null)
+ {
+ List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClassName(config.getBeforeClass());
+ if (withClassName.isEmpty())
+ {
+ throw new ConfigurationException("Cannot add before class: " + config.getAfterClass()
+ + " as no such iterceptor exists in the default chain");
+ }
+ interceptorChain.addBeforeInterceptor(config.getInterceptor(), withClassName.get(0).getClass());
+ }
+ }
+ }
+
@Override
@SuppressWarnings("unchecked")
protected <T> T construct(Class<T> componentType)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -21,6 +21,8 @@
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
+ * todo - if you add the same interceptor instance twice, things get really dirty.
+ * -- this should be treated as an missuse and an exception should be thrown
*/
public class InterceptorChain
{
@@ -175,7 +177,7 @@
*
* @return true if the interceptor was added; i.e. the afterInterceptor exists
*/
- public synchronized boolean addInterceptor(CommandInterceptor toAdd, Class<? extends CommandInterceptor> afterInterceptor)
+ public synchronized boolean addAfterInterceptor(CommandInterceptor toAdd, Class<? extends CommandInterceptor> afterInterceptor)
{
CommandInterceptor it = firstInChain;
while (it != null)
@@ -192,6 +194,33 @@
}
/**
+ * Adds a new interceptor in list after an interceptor of a given type.
+ *
+ * @return true if the interceptor was added; i.e. the afterInterceptor exists
+ */
+ public synchronized boolean addBeforeInterceptor(CommandInterceptor toAdd, Class<? extends CommandInterceptor> beforeInterceptor)
+ {
+ if (firstInChain.getClass().equals(beforeInterceptor))
+ {
+ toAdd.setNext(firstInChain);
+ firstInChain = toAdd;
+ return true;
+ }
+ CommandInterceptor it = firstInChain;
+ while (it.getNext() != null)
+ {
+ if (it.getNext().getClass().equals(beforeInterceptor))
+ {
+ toAdd.setNext(it.getNext());
+ it.setNext(toAdd);
+ return true;
+ }
+ it = it.getNext();
+ }
+ return false;
+ }
+
+ /**
* Appends at the end.
*/
public void appendIntereceptor(CommandInterceptor ci)
@@ -289,10 +318,39 @@
return result;
}
+ /**
+ * Returns all the interceptors that have the fully qualified name of their class equal with the supplied class name.
+ */
+ public List<CommandInterceptor> getInterceptorsWithClassName(String fqName)
+ {
+ CommandInterceptor iterator = firstInChain;
+ List<CommandInterceptor> result = new ArrayList<CommandInterceptor>(2);
+ while (iterator != null)
+ {
+ if (iterator.getClass().getName().equals(fqName)) result.add(iterator);
+ iterator = iterator.getNext();
+ }
+ return result;
+ }
+
public String toString()
{
return "InterceptorChain{\n" +
CachePrinter.printInterceptorChain(firstInChain) +
"\n}";
}
+
+ /**
+ * Checks whether the chain contains the supplied interceptor instance.
+ */
+ public boolean containsInstance(CommandInterceptor interceptor)
+ {
+ CommandInterceptor it = firstInChain;
+ while (it != null)
+ {
+ if (it == interceptor) return true;
+ it = it.getNext();
+ }
+ return false;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -132,7 +132,7 @@
public void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
{
- invoker.addInterceptor(i, afterInterceptor);
+ invoker.addAfterInterceptor(i, afterInterceptor);
}
public List<CommandInterceptor> getInterceptorChain()
Modified: core/trunk/src/main/resources/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-11 10:14:00 UTC (rev 6247)
@@ -17,7 +17,6 @@
<!-- either replication or invalidation tags will be present, not both -->
<replication>
<sync replTimeout="15421"/>
- <async useReplQueue="false" replQueueInterval="12" replQueueMaxElements="12345"/>
<buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
<dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
<locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
@@ -31,10 +30,9 @@
<!-- either replication or invalidation tags will be present, not both -->
<invalidation>
- <sync replTimeout="15421"/>
+ <async useReplQueue="false" replQueueInterval="12" replQueueMaxElements="12345"/>
</invalidation>
- <!-- todo mmarkus -->
<stateRetrieval timeout="1524" fetchInMemoryState="true"/>
<startup regionsInactiveOnStartup="true"/>
<shutdown hookBehavior="REGISTER"/>
@@ -103,24 +101,16 @@
<!-- this is new behavior added within 3.x only. it support configuring custom interceptors through configurations -->
<customInterceptors>
- <interceptor class="com.myCompany.MyInterceptor1">
- <properties>
- x=y
- i=10
- </properties>
- <position first="true"/>
+ <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor">
+ <attribute name="attrOne">value1</attribute>
+ <attribute name="attrTwo">value2</attribute>
+ <attribute name="attrThree">value3</attribute>
</interceptor>
- <interceptor class="com.myCompany.MyInterceptor2">
- <position last="true"/>
- </interceptor>
- <interceptor class="com.myCompany.MyInterceptor3">
- <position index="3"/>
- </interceptor>
- <interceptor class="com.myCompany.MyInterceptor4">
- <position before="org.jboss.cache.interceptors.CallInterceptor"/>
- </interceptor>
- <interceptor class="com.myCompany.MyInterceptor5">
- <position after="org.jboss.cache.interceptors.CallInterceptor"/>
- </interceptor>
+ <interceptor position="last" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
+ <interceptor index="3" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
+ <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
+ <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
</customInterceptors>
</jbosscache>
Modified: core/trunk/src/main/resources/jbosscache-config-3.0.xsd
===================================================================
--- core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/main/resources/jbosscache-config-3.0.xsd 2008-07-11 10:14:00 UTC (rev 6247)
@@ -167,15 +167,7 @@
<xs:complexType name="evictionRegionType">
<xs:sequence>
- <xs:element name="attribute" maxOccurs="unbounded">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="name" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
+ <xs:element name="attribute" maxOccurs="unbounded" type="attributeType"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="policyClass" type="xs:string"/>
@@ -225,22 +217,32 @@
<xs:sequence>
<xs:element name="interceptor" maxOccurs="unbounded">
<xs:complexType>
- <xs:all>
- <xs:element name="properties" minOccurs="0" maxOccurs="1"/>
- <xs:element name="position" minOccurs="0" maxOccurs="1">
- <xs:complexType>
- <xs:attribute name="first" type="booleanType"/>
- <xs:attribute name="last" type="booleanType"/>
- <xs:attribute name="index" type="positiveInteger"/>
- <xs:attribute name="before" type="xs:string"/>
- <xs:attribute name="after" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:all>
+ <xs:sequence>
+ <xs:element name="attribute" maxOccurs="unbounded" type="attributeType" minOccurs="0"/>
+ </xs:sequence>
<xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="position">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="first"/>
+ <xs:enumeration value="last"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="before" type="xs:string"/>
+ <xs:attribute name="after" type="xs:string"/>
+ <xs:attribute name="index" type="positiveInteger"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
+
+ <xs:complexType name="attributeType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="name" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
</xs:schema>
Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/CustomInterceptorsElementParserTest.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.config.parsing;
+
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.CustomInterceptorConfig;
+import org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor;
+import org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor;
+import org.jboss.cache.config.parsing.element.CustomInterceptorsElementParser;
+import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+
+import java.util.List;
+
+/**
+ * Tester class for {@link CustomInterceptorsElementParser}.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test (groups = "unit")
+public class CustomInterceptorsElementParserTest
+{
+ CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser();
+
+ /**
+ * Tests a correct configuration having all possible elements/attributes.
+ * @throws Exception
+ */
+ public void testFullConfiguration() throws Exception
+ {
+ String xml =
+ " <customInterceptors>\n" +
+ " <interceptor position=\"first\" class=\"org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor\">\n" +
+ " <attribute name=\"attrOne\">value1</attribute>\n" +
+ " <attribute name=\"attrTwo\">value2</attribute>\n" +
+ " <attribute name=\"attrThree\">value3</attribute>\n" +
+ " </interceptor>\n" +
+ " <interceptor position=\"last\" class=\"org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor\"/>\n" +
+ " <interceptor index=\"3\" class=\"org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor\"/>\n" +
+ " <interceptor before=\"org.jboss.cache.interceptors.CallInterceptor\"\n" +
+ " class=\"org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor\"/>\n" +
+ " <interceptor after=\"org.jboss.cache.interceptors.CallInterceptor\"\n" +
+ " class=\"org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor\"/>\n" +
+ " </customInterceptors>";
+ Element element = XmlConfigHelper.stringToElement(xml);
+ List<CustomInterceptorConfig> configs = parser.parseCustomInterceptors(element);
+ assert configs.size() == 5;
+ CustomInterceptorConfig one = configs.get(0);
+ assert one.isFirst();
+ assert one.getInterceptor() instanceof AaaCustomInterceptor;
+ assert ((AaaCustomInterceptor)one.getInterceptor()).getAttrOne().equals("value1");
+ assert ((AaaCustomInterceptor)one.getInterceptor()).getAttrTwo().equals("value2");
+ assert ((AaaCustomInterceptor)one.getInterceptor()).getAttrThree().equals("value3");
+
+ CustomInterceptorConfig two = configs.get(1);
+ assert !two.isFirst();
+ assert two.isLast();
+ assert two.getInterceptor() instanceof BbbCustomInterceptor;
+
+ CustomInterceptorConfig three = configs.get(2);
+ assert !three.isFirst();
+ assert !three.isLast();
+ assert three.getIndex() == 3;
+
+ CustomInterceptorConfig four = configs.get(3);
+ assert !four.isFirst();
+ assert !four.isLast();
+ assert four.getBeforeClass().equals("org.jboss.cache.interceptors.CallInterceptor");
+
+ CustomInterceptorConfig five = configs.get(4);
+ assert !five.isFirst();
+ assert !five.isLast();
+ assert five.getAfterClass().equals("org.jboss.cache.interceptors.CallInterceptor");
+ }
+
+ /**
+ * trying to specify an attribute that does not exist on the interceptor class.
+ */
+ public void testWrongAttribute() throws Exception
+ {
+ String xml =
+ " <customInterceptors>\n" +
+ " <interceptor position=\"first\" class=\"org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor\">\n" +
+ " <attribute name=\"nonexistenAttribute\">value3</attribute>\n" +
+ " </interceptor>\n" +
+ " </customInterceptors>";
+ Element el = XmlConfigHelper.stringToElement(xml);
+ try
+ {
+ parser.parseCustomInterceptors(el);
+ assert false: "exception expected";
+ } catch (ConfigurationException e)
+ {
+ //expected
+ }
+ }
+
+ /**
+ * If the interceptor class is incorrect (e.g. does not extend the CommandInterceptor base class) then parser should fail.
+ */
+ public void testBadInterceptorClass() throws Exception
+ {
+ String xml =
+ " <customInterceptors>\n" +
+ " <interceptor position=\"first\" class=\"org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor\">\n" +
+ " <attribute name=\"notExists\">value1</attribute>\n" +
+ " </interceptor>\n" +
+ " </customInterceptors>";
+ Element el = XmlConfigHelper.stringToElement(xml);
+ try
+ {
+ parser.parseCustomInterceptors(el);
+ assert false: "exception expected";
+ } catch (ConfigurationException e)
+ {
+ //expected
+ }
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/EvictionElementParserTest.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -112,7 +112,6 @@
" </region>\n" +
" <region name=\"/lfu\">\n" +
" <attribute name=\"maxNodes\">5000</attribute>\n" +
- " <attribute name=\"minNodes\">4000</attribute>\n" +
" <attribute name=\"timeToLive\">1000000</attribute>\n" +
" </region>\n" +
" </eviction>";
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationParserTest.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -1,6 +1,8 @@
package org.jboss.cache.config.parsing;
import org.jboss.cache.config.*;
+import org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor;
+import org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor;
import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.eviction.MRUConfiguration;
import org.jboss.cache.lock.IsolationLevel;
@@ -224,15 +226,13 @@
{
List<CustomInterceptorConfig> interceptorConfigs = config.getCustomInterceptors();
assert interceptorConfigs.size() == 5;
- assert interceptorConfigs.get(0).getInterceptorClass().equals("com.myCompany.MyInterceptor1");
- assert interceptorConfigs.get(1).getInterceptorClass().equals("com.myCompany.MyInterceptor2");
- assert interceptorConfigs.get(2).getInterceptorClass().equals("com.myCompany.MyInterceptor3");
- assert interceptorConfigs.get(3).getInterceptorClass().equals("com.myCompany.MyInterceptor4");
- assert interceptorConfigs.get(4).getInterceptorClass().equals("com.myCompany.MyInterceptor5");
+ assert interceptorConfigs.get(0).getInterceptor() instanceof AaaCustomInterceptor;
+ assert interceptorConfigs.get(1).getInterceptor() instanceof BbbCustomInterceptor;
+ assert interceptorConfigs.get(2).getInterceptor() instanceof AaaCustomInterceptor;
+ assert interceptorConfigs.get(3).getInterceptor() instanceof BbbCustomInterceptor;
+ assert interceptorConfigs.get(4).getInterceptor() instanceof AaaCustomInterceptor;
assert interceptorConfigs.get(0).isFirst();
assert !interceptorConfigs.get(0).isLast();
- assert interceptorConfigs.get(0).getProperties().get("x").equals("y");
- assert interceptorConfigs.get(0).getProperties().get("i").equals("10");
assert interceptorConfigs.get(1).isLast();
assert interceptorConfigs.get(2).getIndex() == 3;
assert interceptorConfigs.get(3).getBeforeClass().equals("org.jboss.cache.interceptors.CallInterceptor");
Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/AaaCustomInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/AaaCustomInterceptor.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/AaaCustomInterceptor.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.config.parsing.custominterceptors;
+
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+
+/**
+ * Used for testing custom interceptors construction.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class AaaCustomInterceptor extends CommandInterceptor
+{
+ private String attrOne;
+ private String attrTwo;
+ private String attrThree;
+
+ public String getAttrOne()
+ {
+ return attrOne;
+ }
+
+ public String getAttrTwo()
+ {
+ return attrTwo;
+ }
+
+ public String getAttrThree()
+ {
+ return attrThree;
+ }
+
+ public void setAttrOne(String attrOne)
+ {
+ this.attrOne = attrOne;
+ }
+
+ public void setAttrTwo(String attrTwo)
+ {
+ this.attrTwo = attrTwo;
+ }
+
+ public void setAttrThree(String attrThree)
+ {
+ this.attrThree = attrThree;
+ }
+}
+
Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/BbbCustomInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/BbbCustomInterceptor.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/BbbCustomInterceptor.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.config.parsing.custominterceptors;
+
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+
+/**
+ * Used for testing custom interceptors construction.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class BbbCustomInterceptor extends CommandInterceptor
+{
+}
Added: core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/WrongCustomInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/WrongCustomInterceptor.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/custominterceptors/WrongCustomInterceptor.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.config.parsing.custominterceptors;
+
+/**
+ * Used for testing custom interceptors construction.
+ * This is a incorrect interceptor implementation as it does not extend CommandInterceptor.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class WrongCustomInterceptor
+{
+}
Added: core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/factories/CustomInterceptorConstructionTest.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.factories;
+
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.CustomInterceptorConfig;
+import org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor;
+import org.jboss.cache.interceptors.MVCCLockingInterceptor;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests how custom interceptor construction is handled.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Test(groups = "functional")
+public class CustomInterceptorConstructionTest
+{
+ CacheSPI cache;
+ int defaultInterceptroCount;
+
+ @AfterMethod
+ public void tearDown()
+ {
+ if (cache != null)
+ {
+ cache.stop();
+ }
+ cache = null;
+ }
+
+ public void testAddFirst()
+ {
+ AaaCustomInterceptor interceptor = new AaaCustomInterceptor();
+ CustomInterceptorConfig config = new CustomInterceptorConfig(interceptor);
+ config.setFirst(true);
+ buildCache(config);
+ assert cache.getInterceptorChain().get(0).equals(interceptor);
+ assert cache.getInterceptorChain().size() == defaultInterceptroCount + 1;
+ }
+
+ public void testAddLast()
+ {
+ AaaCustomInterceptor interceptor = new AaaCustomInterceptor();
+ CustomInterceptorConfig config = new CustomInterceptorConfig(interceptor);
+ config.setLast(true);
+ buildCache(config);
+ List chain = cache.getInterceptorChain();
+ assert chain.get(chain.size() - 1).equals(interceptor);
+ assert cache.getInterceptorChain().size() == defaultInterceptroCount + 1;
+ }
+
+ public void testAddAfter()
+ {
+ AaaCustomInterceptor interceptor = new AaaCustomInterceptor();
+ CustomInterceptorConfig config = new CustomInterceptorConfig(interceptor);
+ config.setAfterClass(MVCCLockingInterceptor.class.getName());
+ buildCache(config);
+ List<CommandInterceptor> chain = cache.getInterceptorChain();
+ int occurenceCount = 0;
+ for (CommandInterceptor ci : chain)
+ {
+ if (ci instanceof MVCCLockingInterceptor)
+ {
+ assert ci.getNext().equals(interceptor);
+ occurenceCount++;
+ }
+ }
+ assert occurenceCount == 1;
+ assert cache.getInterceptorChain().size() == defaultInterceptroCount + 1;
+ }
+
+ public void testAddBefore()
+ {
+ AaaCustomInterceptor interceptor = new AaaCustomInterceptor();
+ CustomInterceptorConfig config = new CustomInterceptorConfig(interceptor);
+ config.setBeforeClass(MVCCLockingInterceptor.class.getName());
+ buildCache(config);
+ List<CommandInterceptor> chain = cache.getInterceptorChain();
+ int occurenceCount = 0;
+ for (CommandInterceptor ci : chain)
+ {
+ if (ci instanceof AaaCustomInterceptor)
+ {
+ assert ci.getNext() instanceof MVCCLockingInterceptor;
+ occurenceCount++;
+ }
+ }
+ assert occurenceCount == 1;
+ assert cache.getInterceptorChain().size() == defaultInterceptroCount + 1;
+ }
+
+ @Test (enabled = true)
+ public void testAddAtIndex()
+ {
+ AaaCustomInterceptor interceptor = new AaaCustomInterceptor();
+ CustomInterceptorConfig config = new CustomInterceptorConfig(interceptor);
+ config.setIndex(1);
+ buildCache(config);
+ List<CommandInterceptor> chain = cache.getInterceptorChain();
+ assert chain.get(1).equals(interceptor);
+ assert cache.getInterceptorChain().size() == defaultInterceptroCount + 1;
+ }
+
+ public void testAddAtInvalidIndex()
+ {
+ AaaCustomInterceptor interceptor = new AaaCustomInterceptor();
+ CustomInterceptorConfig config = new CustomInterceptorConfig(interceptor);
+ config.setIndex(1000);
+ try
+ {
+ buildCache(config);
+ assert false : "exception expected here";
+ } catch (Exception e)
+ {
+ //expected
+ }
+ }
+
+ private void buildCache(CustomInterceptorConfig interceptorConfig)
+ {
+ buildCache(Collections.singletonList(interceptorConfig));
+ }
+
+ private void buildCache(List<CustomInterceptorConfig> interceptorConfig)
+ {
+ Configuration config = new Configuration();
+ config.setCacheMode(Configuration.CacheMode.LOCAL);
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.MVCC);
+ CacheFactory cacheFactory2 = new DefaultCacheFactory();
+ CacheSPI tmpCacheSPI = (CacheSPI) cacheFactory2.createCache(config);
+ defaultInterceptroCount = tmpCacheSPI.getInterceptorChain().size();
+ tmpCacheSPI.stop();
+
+ CacheFactory cacheFactory = new DefaultCacheFactory();
+ config.setCustomInterceptors(interceptorConfig);
+ cache = (CacheSPI) cacheFactory.createCache(config, true);
+ }
+}
+
Modified: core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-07-11 10:14:00 UTC (rev 6247)
@@ -138,7 +138,7 @@
assert result.size() == chain.asList().size();
}
- public void removeInterceptorWithtType()
+ public void testRemoveInterceptorWithtType()
{
chain.addInterceptor(txInterceptor, 1);
chain.addInterceptor(invalidationInterceptor, 2);
@@ -158,16 +158,29 @@
assert pessimisticInterceptor.getNext() == null;
}
- public void addInterceptorWithType()
+ public void testAddInterceptorWithType()
{
- assert chain.addInterceptor(invalidationInterceptor, icInterceptor.getClass());
+ assert chain.addAfterInterceptor(invalidationInterceptor, icInterceptor.getClass());
assert icInterceptor.getNext().equals(invalidationInterceptor);
- chain.addInterceptor(txInterceptor, icInterceptor.getClass());
+ chain.addAfterInterceptor(txInterceptor, icInterceptor.getClass());
assert icInterceptor.getNext().equals(txInterceptor);
assert txInterceptor.getNext().equals(invalidationInterceptor);
}
+ public void testGetInterceptorsWithClassName()
+ {
+ chain.appendIntereceptor(invalidationInterceptor);
+ chain.appendIntereceptor(callInterceptor);
+ chain.appendIntereceptor(pessimisticInterceptor);
+ chain.appendIntereceptor(create(CallInterceptor.class));
+ assert chain.getInterceptorsWithClassName(InvocationContextInterceptor.class.getName()).size() == 1;
+ assert chain.getInterceptorsWithClassName(InvalidationInterceptor.class.getName()).size() == 1;
+ assert chain.getInterceptorsWithClassName(PessimisticLockInterceptor.class.getName()).size() == 1;
+ assert chain.getInterceptorsWithClassName(CallInterceptor.class.getName()).size() == 2;
+ assert chain.getInterceptorsWithClassName(CommandInterceptor.class.getName()).size() == 0;
+ }
+
private CommandInterceptor create(Class<? extends CommandInterceptor> toInstantiate)
{
try
Modified: core/trunk/src/test/resources/configs/parser-test.xml
===================================================================
--- core/trunk/src/test/resources/configs/parser-test.xml 2008-07-11 01:33:09 UTC (rev 6246)
+++ core/trunk/src/test/resources/configs/parser-test.xml 2008-07-11 10:14:00 UTC (rev 6247)
@@ -99,24 +99,16 @@
<!-- this is new behavior added within 3.x only. it support configuring custom interceptors through configurations -->
<customInterceptors>
- <interceptor class="com.myCompany.MyInterceptor1">
- <properties>
- x=y
- i=10
- </properties>
- <position first="true"/>
+ <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor">
+ <attribute name="attrOne">value1</attribute>
+ <attribute name="attrTwo">value2</attribute>
+ <attribute name="attrThree">value3</attribute>
</interceptor>
- <interceptor class="com.myCompany.MyInterceptor2">
- <position last="true"/>
- </interceptor>
- <interceptor class="com.myCompany.MyInterceptor3">
- <position index="3"/>
- </interceptor>
- <interceptor class="com.myCompany.MyInterceptor4">
- <position before="org.jboss.cache.interceptors.CallInterceptor"/>
- </interceptor>
- <interceptor class="com.myCompany.MyInterceptor5">
- <position after="org.jboss.cache.interceptors.CallInterceptor"/>
- </interceptor>
+ <interceptor position="last" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
+ <interceptor index="3" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
+ <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
+ <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
</customInterceptors>
</jbosscache>
17 years, 5 months
JBoss Cache SVN: r6246 - core/trunk/src/main/docs/Cache_Tutorial.
by jbosscache-commits@lists.jboss.org
Author: skittoli
Date: 2008-07-10 21:33:09 -0400 (Thu, 10 Jul 2008)
New Revision: 6246
Modified:
core/trunk/src/main/docs/Cache_Tutorial/pom.xml
Log:
edited pom.xml
Modified: core/trunk/src/main/docs/Cache_Tutorial/pom.xml
===================================================================
--- core/trunk/src/main/docs/Cache_Tutorial/pom.xml 2008-07-11 01:31:49 UTC (rev 6245)
+++ core/trunk/src/main/docs/Cache_Tutorial/pom.xml 2008-07-11 01:33:09 UTC (rev 6246)
@@ -32,7 +32,7 @@
</dependencies>
<configuration>
- <sourceDocumentName>Cache_Tutorial.xml</sourceDocumentName>
+ <sourceDocumentName>resolved.xml</sourceDocumentName>
<sourceDirectory>en-US</sourceDirectory>
<imageResource>
<directory>en-US</directory>
17 years, 5 months
JBoss Cache SVN: r6245 - in core/trunk/src/main/docs: Cache_User_Guide and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: skittoli
Date: 2008-07-10 21:31:49 -0400 (Thu, 10 Jul 2008)
New Revision: 6245
Removed:
core/trunk/src/main/docs/Cache_Tutorial/target/
core/trunk/src/main/docs/Cache_User_Guide/target/
core/trunk/src/main/docs/Frequently_Asked_Questions/target/
Modified:
core/trunk/src/main/docs/Cache_Tutorial/pom.xml
Log:
removed target dir
Modified: core/trunk/src/main/docs/Cache_Tutorial/pom.xml
===================================================================
--- core/trunk/src/main/docs/Cache_Tutorial/pom.xml 2008-07-10 16:42:50 UTC (rev 6244)
+++ core/trunk/src/main/docs/Cache_Tutorial/pom.xml 2008-07-11 01:31:49 UTC (rev 6245)
@@ -32,7 +32,7 @@
</dependencies>
<configuration>
- <sourceDocumentName>resolved.xml</sourceDocumentName>
+ <sourceDocumentName>Cache_Tutorial.xml</sourceDocumentName>
<sourceDirectory>en-US</sourceDirectory>
<imageResource>
<directory>en-US</directory>
17 years, 5 months
JBoss Cache SVN: r6244 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-10 12:42:50 -0400 (Thu, 10 Jul 2008)
New Revision: 6244
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java
Log:
Fixed stuff
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -470,7 +470,7 @@
// Yuck!
NodeSPI nodeSPI = peek(f, false, includeInvalidNodes);
if (nodeSPI == null) return null;
- return (InternalNode) ((NodeInvocationDelegate) nodeSPI).getDelegationTarget();
+ return ((NodeInvocationDelegate) nodeSPI).getDelegationTarget();
}
public void setBuddyFqnTransformer(BuddyFqnTransformer buddyFqnTransformer)
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -325,7 +325,7 @@
{
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
- if (!isValid()) sb.append(" (INVALID!) ");
+ if (!isValid()) sb.append(" (invalid) ");
if (isDeleted())
{
@@ -335,6 +335,12 @@
{
sb.append("[ ").append(fqn);
}
+
+ if (this instanceof VersionedNode)
+ {
+ sb.append(" version=").append(this.getVersion());
+ }
+
if (data != null)
{
synchronized (data)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -388,7 +388,7 @@
}
if (!n.isDataLoaded())
{
- if (trace) log.trace("must Load, uninitialized");
+ if (trace) log.trace("must load, uninitialized");
return true;
}
return false;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -35,7 +35,7 @@
this.node = node;
}
- public Object getDelegationTarget()
+ public InternalNode getDelegationTarget()
{
return node;
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -219,7 +219,7 @@
// TODO: warning, hack! There is a race condition here. Add a way to create nodes without attaching to a parent.
parent.removeChildDirect(fqn.getLastElement());
- in = (InternalNode) ((NodeInvocationDelegate) temp).getDelegationTarget();
+ in = ((NodeInvocationDelegate) temp).getDelegationTarget();
n = nodeFactory.createMvccNode(in);
n.setCreated(true);
context.putLookedUpNode(fqn, n);
@@ -274,7 +274,7 @@
if (parentLockNeeded && (needToCopyNode || needToCopyParent))
{
ReadCommittedNode parent = (ReadCommittedNode) ctx.lookUpNode(parentFqn);
- parent.addChildDirect(nodeFactory.createNodeInvocationDelegate((InternalNode) node.getDelegationTarget()));
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node.getDelegationTarget()));
}
// now deal with children.
@@ -306,7 +306,7 @@
{
rcn.markForUpdate(ctx, dataContainer, nodeFactory, allowWriteSkew);
ReadCommittedNode parent = (ReadCommittedNode) ctx.lookUpNode(fqn.getParent());
- parent.addChildDirect(nodeFactory.createNodeInvocationDelegate((InternalNode) rcn.getDelegationTarget()));
+ parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(rcn.getDelegationTarget()));
Map<Object, NodeSPI> children = rcn.getChildrenMapDirect();
if (children != null)
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -8,8 +8,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
/**
* A node delegate that encapsulates read committed semantics when writes are initiated, committed or rolled back.
@@ -49,10 +47,11 @@
changed = true;
backup = node;
- node = backup.copy();
+ InternalNode backupDelegationTarget = ((NodeReference) backup).getDelegate();
+ node = backupDelegationTarget.copy();
// TODO: Make sure this works with custom versions as well!
- DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
- node.setVersion(newVersion);
+// DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
+// node.setVersion(newVersion);
}
/**
@@ -77,6 +76,8 @@
{
NodeSPI parent = lookupParent(fqn, ctx, container);
parent.removeChildDirect(fqn.getLastElement());
+ setValid(false, false);
+ updateNode(ctx, container, nodeFactory);
}
else
{
@@ -135,8 +136,9 @@
protected void updateNode(InvocationContext ctx, DataContainer dataContainer, NodeFactory nf)
{
// swap refs
- ((NodeReference) backup).setDelegate(((NodeReference) node).getDelegate());
+ ((NodeReference) backup).setDelegate(node);
node = backup;
+
}
public void rollbackUpdate()
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -56,7 +56,10 @@
@Override
protected void updateNode(InvocationContext ctx, DataContainer dataContainer, NodeFactory nf)
{
- NodeSPI parent = lookupParent(getFqn(), ctx, dataContainer);
- parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ if (!deleted)
+ {
+ NodeSPI parent = lookupParent(getFqn(), ctx, dataContainer);
+ parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ }
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedMvccNodeValidityTest.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -1,6 +1,8 @@
package org.jboss.cache.api.nodevalidity;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
import org.testng.annotations.Test;
@Test(groups = {"functional", "mvcc"})
@@ -10,4 +12,11 @@
{
nodeLockingScheme = NodeLockingScheme.MVCC;
}
+
+ @Override
+ protected void nodeLockingSchemeSpecificSetup(Configuration c)
+ {
+ c.setNodeLockingScheme(nodeLockingScheme);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/LocalMvccNodeValidityTest.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -1,6 +1,8 @@
package org.jboss.cache.api.nodevalidity;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
import org.testng.annotations.Test;
@Test(groups = {"functional", "mvcc"})
@@ -10,4 +12,11 @@
{
nodeLockingScheme = NodeLockingScheme.MVCC;
}
+
+ @Override
+ protected void nodeLockingSchemeSpecificSetup(Configuration c)
+ {
+ c.setNodeLockingScheme(nodeLockingScheme);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java 2008-07-10 14:11:25 UTC (rev 6243)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/ReplicatedMvccNodeValidityTest.java 2008-07-10 16:42:50 UTC (rev 6244)
@@ -1,6 +1,8 @@
package org.jboss.cache.api.nodevalidity;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
import org.testng.annotations.Test;
@Test(groups = {"functional", "mvcc"})
@@ -10,4 +12,11 @@
{
nodeLockingScheme = NodeLockingScheme.MVCC;
}
+
+ @Override
+ protected void nodeLockingSchemeSpecificSetup(Configuration c)
+ {
+ c.setNodeLockingScheme(nodeLockingScheme);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
}
17 years, 5 months
JBoss Cache SVN: r6243 - in searchable/trunk/src: test/java/org/jboss/cache/search and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-10 10:11:25 -0400 (Thu, 10 Jul 2008)
New Revision: 6243
Added:
searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java
searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocumentId.java
searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvided.java
Removed:
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java
searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
Log:
Updated files from HS branch and refactored diffs in JBCS
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQuery.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -1,6 +1,8 @@
package org.jboss.cache.search;
import org.apache.lucene.search.Sort;
+import org.apache.lucene.search.Filter;
+import org.hibernate.search.FullTextFilter;
import java.util.List;
@@ -69,4 +71,31 @@
*/
void setSort(Sort s);
+
+ /**
+ * Enable a given filter by its name.
+ *
+ * @param name of filter.
+ * @return a FullTextFilter object.
+ */
+ public FullTextFilter enableFullTextFilter(String name);
+
+
+ /**
+ * Disable a given filter by its name.
+ *
+ * @param name of filter.
+ */
+ public void disableFullTextFilter(String name);
+
+ /**
+ * Takes in a lucene filter and sets it to the filter field in the class.
+ *
+ * @param f - lucene filter
+ */
+
+ public void setFilter(Filter f);
+
+
+
}
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -57,9 +57,9 @@
private int fetchSize;
private String[] indexProjection;
private ResultTransformer resultTransformer;
- private Criteria criteria;
CacheEntityLoader entityLoader;
+
public CacheQueryImpl(Query luceneQuery, SearchFactoryImpl searchFactory, Cache cache)
{
this.luceneQuery = luceneQuery;
@@ -74,7 +74,19 @@
this.classes = classes;
}
+ /**
+ * Takes in a lucene filter and sets it to the filter field in the class.
+ *
+ * @param f - lucene filter
+ */
+ public void setFilter(Filter f)
+ {
+ filter = f;
+ }
+
+
+
/**
* @return The result size of the query.
*/
@@ -247,7 +259,7 @@
try
{
hits = getHits(searcher);
- if(log.isTraceEnabled()) log.trace("Number of hits are " + hits.length());
+ if (log.isTraceEnabled()) log.trace("Number of hits are " + hits.length());
int first = first();
int max = max(first, hits);
@@ -337,7 +349,7 @@
{
searcherSimilarity = checkSimilarity(searcherSimilarity, builder);
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
- populateDirectories(directories, directoryProviders, searchFactoryImplementor);
+ populateDirectories(directories, directoryProviders);
}
classesAndSubclasses = null;
}
@@ -361,7 +373,7 @@
final DirectoryProvider[] directoryProviders = builder.getDirectoryProviderSelectionStrategy().getDirectoryProvidersForAllShards();
searcherSimilarity = checkSimilarity(searcherSimilarity, builder);
- populateDirectories(directories, directoryProviders, searchFactoryImplementor);
+ populateDirectories(directories, directoryProviders);
}
classesAndSubclasses = involvedClasses;
}
@@ -411,8 +423,8 @@
return similarity;
}
- private void populateDirectories(List<DirectoryProvider> directories, DirectoryProvider[] directoryProviders,
- SearchFactoryImplementor searchFactoryImplementor)
+ private void populateDirectories(List<DirectoryProvider> directories, DirectoryProvider[] directoryProviders)
+
{
for (DirectoryProvider provider : directoryProviders)
{
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/NodeModifiedTransactionContext.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -10,10 +10,10 @@
* This class implements the {@link org.hibernate.search.transaction.TransactionContext} interface. It
* retrieves transaction context information from the {@link org.jboss.cache.notifications.event.NodeModifiedEvent} that gets passed in.
* <p />
- * It is used by the {@link org.jboss.cache.search.SearchableListener} to pass transaction information to a Hibernate Search {@link org.hibernate.search.backend.Work} object.
+ * It is used by the {@link SearchableCoreListener} to pass transaction information to a Hibernate Search {@link org.hibernate.search.backend.Work} object.
* <p />
* @author Navin Surtani - navin(a)surtani.org
- * @see org.jboss.cache.search.SearchableListener
+ * @see SearchableCoreListener
*/
public class NodeModifiedTransactionContext implements TransactionContext
{
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/QueryResultIteratorImpl.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -13,11 +13,8 @@
*/
public class QueryResultIteratorImpl implements QueryResultIterator
{
- private Cache cache;
private int index = 0;
//private final int size;
- private Object next;
- private int nextObjectIndex = -1;
private List<CacheEntityId> idList;
private CacheEntityLoader entityLoader;
private int lowerLimit = 0;
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheCfgImpl.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -1,8 +1,9 @@
package org.jboss.cache.search;
-import org.hibernate.search.cfg.Cfg;
+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;
@@ -15,7 +16,7 @@
*
* @author Navin Surtani - navin(a)surtani.org
*/
-public class SearchableCacheCfgImpl implements Cfg
+public class SearchableCacheCfgImpl implements SearchConfiguration
{
protected Map<String, PersistentClass> classes;
private Properties properties;
@@ -61,4 +62,10 @@
return properties;
}
+ public ReflectionManager getReflectionManager()
+ {
+ //TODO: Am I meant to throw unsupported exception?
+ 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-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -1,8 +1,7 @@
package org.jboss.cache.search;
import org.hibernate.search.impl.SearchFactoryImpl;
-import org.hibernate.search.cfg.Cfg;
-import org.hibernate.search.annotations.ProvidedId;
+import org.hibernate.search.cfg.SearchConfiguration;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheStatus;
import org.apache.commons.logging.Log;
@@ -23,7 +22,7 @@
* Creates a searchable cache from a cache object and a class array, without the properties object.
*
* @param c - the Cache
- * @param classes - Class array to be added
+ * @param classes - Class array to be added
* @return a SearchableCache
*/
public SearchableCache createSearchableCache(Cache<?, ?> c, Class... classes)
@@ -60,7 +59,7 @@
}
// step 1: create hibernate search searchFactory
- Cfg cfg = new SearchableCacheCfgImpl(classes, properties);
+ SearchConfiguration cfg = new SearchableCacheCfgImpl(classes, properties);
// set classes in the cfg
SearchFactoryImpl searchFactory = new SearchFactoryImpl(cfg);
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCoreListener.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -18,7 +18,7 @@
* Listener class for changes made to the cache. This listener makes changes if it is a org.jboss.cache being used.
*/
@CacheListener
-public class SearchableCoreListener extends SearchableListener
+public class SearchableCoreListener
{
private SearchFactoryImpl searchFactory;
private static final Log log = LogFactory.getLog(SearchableCoreListener.class);
Deleted: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableListener.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -1,29 +0,0 @@
-package org.jboss.cache.search;
-
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.WorkType;
-import org.hibernate.search.impl.SearchFactoryImpl;
-import org.hibernate.search.transaction.TransactionContext;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.Fqn;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Map;
-
-/**
- * @author Navin Surtani - navin(a)surtani.org
- * <p/>
- * Abstract class that listens for changes made to the cache so that the Lucene indexes can be updated.
- */
-
-@CacheListener
-public abstract class SearchableListener
-{
- private static final Log log = LogFactory.getLog(SearchableListener.class);
-
-
-
-}
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-07-10 12:21:10 UTC (rev 6242)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchablePojoListener.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -14,7 +14,7 @@
// */
//
//@PojoCacheListener
-//public class SearchablePojoListener extends SearchableListener
+//public class SearchablePojoListener extends
//{
// private SearchFactoryImpl searchFactory;
// private static final Log log = LogFactory.getLog(SearchablePojoListener.class);
@@ -50,7 +50,7 @@
// public void updateLuceneIndexes(NodeModifiedEvent event) throws InvalidKeyException
// {
//
-// if (log.isTraceEnabled()) log.trace("You have entered the SearchableListener");
+// if (log.isTraceEnabled()) log.trace("You have entered the PojoListener for Searchable Cache");
// if (!event.isPre())
// {
// if (log.isTraceEnabled()) log.trace("event.isPre is false. Going to start updating indexes");
Added: searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/CacheEntityIdTest.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -0,0 +1,36 @@
+package org.jboss.cache.search;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.search.CacheEntityId;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+
+@Test
+public class CacheEntityIdTest
+{
+
+ @Test (expectedExceptions = NullPointerException.class)
+ public void testNullFqn()
+ {
+ CacheEntityId nullFqn = new CacheEntityId(null, "key");
+ }
+
+
+ @Test (expectedExceptions = NullPointerException.class)
+ public void testNullKey()
+ {
+ CacheEntityId nullKey = new CacheEntityId(Fqn.fromString("/a/b/c"), null);
+ }
+
+ @Test (expectedExceptions = NullPointerException.class)
+ public void testNullDocId()
+ {
+ CacheEntityId nulldoc = new CacheEntityId(null);
+ }
+
+
+
+}
Added: searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/NodeModifiedTransactionContextTest.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -0,0 +1,21 @@
+package org.jboss.cache.search;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+
+@Test
+public class NodeModifiedTransactionContextTest
+{
+
+ @Test (expectedExceptions = NullPointerException.class)
+ public void nullConstuctor()
+ {
+ NodeModifiedTransactionContext nmtc = new NodeModifiedTransactionContext(null);
+ }
+
+
+
+}
Added: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/BrokenAnnotationTest.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -0,0 +1,44 @@
+package org.jboss.cache.search.blackbox;
+
+import org.testng.annotations.Test;
+import org.jboss.cache.search.test.BrokenProvided;
+import org.jboss.cache.search.test.BrokenDocumentId;
+import org.jboss.cache.search.SearchableCache;
+import org.jboss.cache.search.SearchableCacheFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+@Test
+public class BrokenAnnotationTest
+{
+ @Test (expectedExceptions = IllegalArgumentException.class)
+ public void testProvided()
+ {
+ BrokenProvided provided = new BrokenProvided();
+ provided.setBoth("Cat", 5);
+
+ Cache cache = new DefaultCacheFactory().createCache();
+
+ SearchableCache searchable = new SearchableCacheFactory().createSearchableCache(cache, BrokenProvided.class);
+
+
+ }
+
+ @Test (expectedExceptions = IllegalArgumentException.class)
+ public void testDocumentId()
+ {
+ BrokenDocumentId provided = new BrokenDocumentId();
+ provided.setBoth("Cat", 5);
+
+ Cache cache = new DefaultCacheFactory().createCache();
+
+ SearchableCache searchable = new SearchableCacheFactory().createSearchableCache(cache, BrokenProvided.class);
+
+
+
+ }
+
+}
Added: searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocumentId.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocumentId.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenDocumentId.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -0,0 +1,27 @@
+package org.jboss.cache.search.test;
+
+import org.hibernate.search.annotations.ProvidedId;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+@ProvidedId
+@Indexed
+public class BrokenDocumentId
+{
+ @DocumentId
+ @Field
+ String name;
+
+ @Field
+ int age;
+
+ public void setBoth(String name, int age)
+ {
+ this.name = name;
+ this.age = age;
+ }
+}
Added: searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvided.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvided.java (rev 0)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/test/BrokenProvided.java 2008-07-10 14:11:25 UTC (rev 6243)
@@ -0,0 +1,26 @@
+package org.jboss.cache.search.test;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+
+/**
+ * @author Navin Surtani - navin(a)surtani.org
+ */
+@Indexed
+public class BrokenProvided
+{
+ @Field
+ public String name;
+
+ @Field
+ public int age;
+
+ public void setBoth(String name, int age)
+ {
+ this.name = name;
+ this.age = age;
+
+ }
+
+}
17 years, 5 months
JBoss Cache SVN: r6242 - core/trunk/src/test/java/org/jboss/cache/eviction.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-10 08:21:10 -0400 (Thu, 10 Jul 2008)
New Revision: 6242
Modified:
core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java
Log:
Fixed broken tests
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -28,6 +28,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.EvictionPolicyConfig;
import static org.testng.AssertJUnit.fail;
@@ -57,7 +58,9 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- regionManager = new RegionManagerImpl();
+ RegionManagerImpl rmi = new RegionManagerImpl();
+ rmi.injectDependencies(null, null, null, null, null, new RegionRegistry());
+ regionManager = rmi;
}
public void testFillUpRecycleQueue() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ElementSizeAlgorithmTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -10,6 +10,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -31,6 +32,7 @@
{
algo = new ElementSizeAlgorithm();
regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
ElementSizeConfiguration config = new ElementSizeConfiguration();
// We have to setCache maxElementsPerNode!!
config.setMaxElementsPerNode(0);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/FIFOAlgorithmTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -10,6 +10,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.BeforeMethod;
@@ -38,6 +39,7 @@
// We have to setCache maxNodes!!
config.setMaxNodes(0);
regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LFUAlgorithmTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -10,6 +10,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -34,6 +35,7 @@
algo = new LFUAlgorithm();
LFUConfiguration config = new LFUConfiguration();
regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
// doesn't this need a cache?!?? :-/
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -6,6 +6,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
@@ -33,9 +34,10 @@
config = new LRUConfiguration();
config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
// We have to setCache timeToLiveSeconds!!
- config.setTimeToLiveSeconds(0);
+ config.setTimeToLive(0);
regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/MRUAlgorithmTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -10,6 +10,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -35,6 +36,7 @@
config.setMaxNodes(0);
config.setEvictionPolicyClass(DummyEvictionPolicy.class.getName());
regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.getRegion("/a/b", true).setEvictionPolicy(config);
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionManagerTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -4,6 +4,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import org.jboss.cache.config.EvictionPolicyConfig;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.BeforeMethod;
@@ -41,6 +42,7 @@
public void testCreateRegion()
{
RegionManager regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
regionManager.getRegion(A_B_C, true).setEvictionPolicy(config);
@@ -55,6 +57,7 @@
{
RegionManager regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
regionManager.getRegion(A_B_C, true).setEvictionPolicy(config);
regionManager.getRegion(A_B, true).setEvictionPolicy(config);
@@ -80,6 +83,7 @@
public void testNoDefaultRegion()
{
RegionManager regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
regionManager.getRegion(A_B_C, true).setEvictionPolicy(config);
regionManager.getRegion(A_B, true).setEvictionPolicy(config);
@@ -90,6 +94,7 @@
public void testGetRegion()
{
RegionManager regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
regionManager.setUsingEvictions(true);
regionManager.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
regionManager.getRegion(A_BC, true).setEvictionPolicy(config);
@@ -105,6 +110,7 @@
Fqn A_B_C_D = Fqn.fromString("/a/b/c/d/");
RegionManager rm = new RegionManagerImpl();
+ ((RegionManagerImpl) rm).injectDependencies(null, null, null, null, null, new RegionRegistry());
rm.setUsingEvictions(true);
rm.getRegion(DEFAULT_REGION, true).setEvictionPolicy(config);
rm.getRegion(A_B_C_D_E, true).setEvictionPolicy(config);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-07-10 12:20:51 UTC (rev 6241)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/RegionTest.java 2008-07-10 12:21:10 UTC (rev 6242)
@@ -4,6 +4,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
+import org.jboss.cache.RegionRegistry;
import org.jboss.cache.config.EvictionConfig;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
@@ -17,15 +18,16 @@
@Test(groups = {"functional"})
public class RegionTest
{
- RegionManager regionManager_;
+ RegionManager regionManager;
EvictionAlgorithm algorithm;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
algorithm = new LRUAlgorithm();
- regionManager_ = new RegionManagerImpl();
- regionManager_.getRegion("/a/b", true).setEvictionPolicy(new DummyEvictionConfiguration());
+ regionManager = new RegionManagerImpl();
+ ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
+ regionManager.getRegion("/a/b", true).setEvictionPolicy(new DummyEvictionConfiguration());
}
public void testAddedQueue()
@@ -34,7 +36,7 @@
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager_.getRegion("/a/b", true);
+ Region region = regionManager.getRegion("/a/b", true);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.ADD_NODE_EVENT));
@@ -56,7 +58,7 @@
Fqn fqn2 = Fqn.fromString("/a/b/d");
Fqn fqn3 = Fqn.fromString("/a/b/e");
- Region region = regionManager_.getRegion("/a/b", true);
+ Region region = regionManager.getRegion("/a/b", true);
region.putNodeEvent(new EvictedEventNode(fqn1, NodeEventType.REMOVE_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn2, NodeEventType.ADD_NODE_EVENT));
region.putNodeEvent(new EvictedEventNode(fqn3, NodeEventType.VISIT_NODE_EVENT));
@@ -74,7 +76,7 @@
{
Fqn fqn2 = Fqn.fromString("/a/b/d");
- Region region = regionManager_.getRegion("/a/b", true);
+ Region region = regionManager.getRegion("/a/b", true);
// This should succeed, alhtough it will produce warning over the threshold.
for (int i = 0; i < EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT - 1; i++)
{
17 years, 5 months
JBoss Cache SVN: r6241 - core/trunk/src/main/java/org/jboss/cache/config.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-10 08:20:51 -0400 (Thu, 10 Jul 2008)
New Revision: 6241
Modified:
core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
Log:
Updated javadocs
Modified: core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-07-10 11:59:23 UTC (rev 6240)
+++ core/trunk/src/main/java/org/jboss/cache/config/EvictionConfig.java 2008-07-10 12:20:51 UTC (rev 6241)
@@ -84,13 +84,13 @@
/**
* Creates an EvictionRegionConfig for the
- * {@link org.jboss.cache.RegionManagerImpl.DEFAULT_REGION "_default_"} region using the
- * {@link #getDefaultEvictionPolicyClass(String) default eviction policy class}. Throws a
+ * {@link org.jboss.cache.RegionManagerImpl#DEFAULT_REGION "_default_"} region using the
+ * {@link #getDefaultEvictionPolicyClass()} default eviction policy class}. Throws a
* {@link ConfigurationException} if
* {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class}
* has not been set.
*
- * @return an EvictionRegionConfig whose FQN is {@link org.jboss.cache.RegionManagerImpl.DEFAULT_REGION}
+ * @return an EvictionRegionConfig whose FQN is {@link org.jboss.cache.RegionManagerImpl#DEFAULT_REGION}
* and whose EvictionPolicyConfig is the default config for the
* default eviction policy class.
* @throws ConfigurationException if a
17 years, 5 months
JBoss Cache SVN: r6240 - core/trunk/src/test/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-10 07:59:23 -0400 (Thu, 10 Jul 2008)
New Revision: 6240
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
Log:
Updated test to consider new interceptors
Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-07-10 11:59:05 UTC (rev 6239)
+++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainFactoryTest.java 2008-07-10 11:59:23 UTC (rev 6240)
@@ -7,6 +7,7 @@
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import static org.jboss.cache.config.Configuration.CacheMode.*;
+import static org.jboss.cache.config.Configuration.NodeLockingScheme.MVCC;
import static org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.interceptors.*;
@@ -23,7 +24,7 @@
import java.util.Iterator;
import java.util.List;
-@Test(groups = {"functional"})
+@Test(groups = "unit")
public class InterceptorChainFactoryTest extends InterceptorChainTestBase
{
CacheSPI cache = null;
@@ -67,6 +68,27 @@
}
+ public void testMvccConfig() throws Exception
+ {
+ cache.getConfiguration().setExposeManagementStatistics(false);
+ cache.getConfiguration().setNodeLockingScheme(MVCC);
+ InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
+ List<CommandInterceptor> list = chain.asList();
+ Iterator<CommandInterceptor> interceptors = list.iterator();
+
+ System.out.println("testMvccConfig interceptors are:\n" + list);
+ assertNotNull(list);
+ assertEquals(5, list.size());
+
+ assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
+ assertEquals(TxInterceptor.class, interceptors.next().getClass());
+ assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
+ assertEquals(MVCCLockingInterceptor.class, interceptors.next().getClass());
+ assertEquals(CallInterceptor.class, interceptors.next().getClass());
+
+ assertInterceptorLinkage(list);
+ }
+
public void testTxConfig() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
@@ -122,13 +144,44 @@
assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
assertEquals(ReplicationInterceptor.class, interceptors.next().getClass());
assertEquals(PessimisticLockInterceptor.class, interceptors.next().getClass());
+ assertEquals(LegacyCacheLoaderInterceptor.class, interceptors.next().getClass());
+ assertEquals(CacheStoreInterceptor.class, interceptors.next().getClass());
+ assertEquals(CallInterceptor.class, interceptors.next().getClass());
+
+ assertInterceptorLinkage(list);
+ }
+
+ public void testSharedCacheLoaderMvccConfig() throws Exception
+ {
+ cache.getConfiguration().setExposeManagementStatistics(false);
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(false, false));
+ cache.getConfiguration().setCacheMode(REPL_ASYNC);
+ cache.getConfiguration().setNodeLockingScheme(MVCC);
+ cache.getConfiguration().setFetchInMemoryState(false);
+ cache.create();
+ InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
+ List<CommandInterceptor> list = chain.asList();
+ Iterator<CommandInterceptor> interceptors = list.iterator();
+
+ System.out.println("testSharedCacheLoaderConfig interceptors are:\n" + list);
+ assertNotNull(list);
+
+ assertEquals(8, list.size());
+
+ assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
+ assertEquals(TxInterceptor.class, interceptors.next().getClass());
+ assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
+ assertEquals(ReplicationInterceptor.class, interceptors.next().getClass());
assertEquals(CacheLoaderInterceptor.class, interceptors.next().getClass());
+ assertEquals(MVCCLockingInterceptor.class, interceptors.next().getClass());
assertEquals(CacheStoreInterceptor.class, interceptors.next().getClass());
assertEquals(CallInterceptor.class, interceptors.next().getClass());
assertInterceptorLinkage(list);
}
+
public void testUnsharedCacheLoaderConfig() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
@@ -151,7 +204,37 @@
assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
assertEquals(ReplicationInterceptor.class, interceptors.next().getClass());
assertEquals(PessimisticLockInterceptor.class, interceptors.next().getClass());
+ assertEquals(LegacyCacheLoaderInterceptor.class, interceptors.next().getClass());
+ assertEquals(CacheStoreInterceptor.class, interceptors.next().getClass());
+ assertEquals(CallInterceptor.class, interceptors.next().getClass());
+
+ assertInterceptorLinkage(list);
+ }
+
+ public void testUnsharedCacheLoaderMvccConfig() throws Exception
+ {
+ cache.getConfiguration().setExposeManagementStatistics(false);
+ cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(false, true));
+ cache.getConfiguration().setCacheMode(REPL_ASYNC);
+ cache.getConfiguration().setNodeLockingScheme(MVCC);
+ cache.getConfiguration().setFetchInMemoryState(false);
+ cache.create();
+ InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
+ List<CommandInterceptor> list = chain.asList();
+ Iterator<CommandInterceptor> interceptors = list.iterator();
+
+ System.out.println("testUnsharedCacheLoaderConfig interceptors are:\n" + list);
+ assertNotNull(list);
+
+ assertEquals(8, list.size());
+
+ assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
+ assertEquals(TxInterceptor.class, interceptors.next().getClass());
+ assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
+ assertEquals(ReplicationInterceptor.class, interceptors.next().getClass());
assertEquals(CacheLoaderInterceptor.class, interceptors.next().getClass());
+ assertEquals(MVCCLockingInterceptor.class, interceptors.next().getClass());
assertEquals(CacheStoreInterceptor.class, interceptors.next().getClass());
assertEquals(CallInterceptor.class, interceptors.next().getClass());
@@ -246,7 +329,7 @@
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(OptimisticTxInterceptor.class, interceptors.next().getClass());
assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
- assertEquals(CacheLoaderInterceptor.class, interceptors.next().getClass());
+ assertEquals(LegacyCacheLoaderInterceptor.class, interceptors.next().getClass());
assertEquals(CacheStoreInterceptor.class, interceptors.next().getClass());
assertEquals(OptimisticLockingInterceptor.class, interceptors.next().getClass());
assertEquals(OptimisticValidatorInterceptor.class, interceptors.next().getClass());
@@ -272,7 +355,7 @@
assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
assertEquals(OptimisticTxInterceptor.class, interceptors.next().getClass());
assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
- assertEquals(ActivationInterceptor.class, interceptors.next().getClass());
+ assertEquals(LegacyActivationInterceptor.class, interceptors.next().getClass());
assertEquals(PassivationInterceptor.class, interceptors.next().getClass());
assertEquals(OptimisticLockingInterceptor.class, interceptors.next().getClass());
assertEquals(OptimisticValidatorInterceptor.class, interceptors.next().getClass());
@@ -283,6 +366,29 @@
assertInterceptorLinkage(list);
}
+ public void testPassivationMvccChain() throws Exception
+ {
+ cache.getConfiguration().setExposeManagementStatistics(false);
+ cache.getConfiguration().setNodeLockingScheme(MVCC);
+ cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(true, false));
+ cache.create();
+ InterceptorChain chain = getInterceptorChainFactory(cache).buildInterceptorChain();
+ List<CommandInterceptor> list = chain.asList();
+ Iterator<CommandInterceptor> interceptors = list.iterator();
+
+ assertEquals(7, list.size());
+
+ assertEquals(InvocationContextInterceptor.class, interceptors.next().getClass());
+ assertEquals(TxInterceptor.class, interceptors.next().getClass());
+ assertEquals(NotificationInterceptor.class, interceptors.next().getClass());
+ assertEquals(ActivationInterceptor.class, interceptors.next().getClass());
+ assertEquals(MVCCLockingInterceptor.class, interceptors.next().getClass());
+ assertEquals(PassivationInterceptor.class, interceptors.next().getClass());
+ assertEquals(CallInterceptor.class, interceptors.next().getClass());
+
+ assertInterceptorLinkage(list);
+ }
+
public void testInvalidationInterceptorChain() throws Exception
{
cache.getConfiguration().setExposeManagementStatistics(false);
17 years, 5 months
JBoss Cache SVN: r6239 - core/trunk/src/test/java/org/jboss/cache/notifications.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-10 07:59:05 -0400 (Thu, 10 Jul 2008)
New Revision: 6239
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
Log:
Added test annotation
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2008-07-10 11:19:53 UTC (rev 6238)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotificationThreadTest.java 2008-07-10 11:59:05 UTC (rev 6239)
@@ -7,14 +7,15 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertNotSame;
import static org.testng.AssertJUnit.assertSame;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
import java.util.LinkedList;
@@ -26,6 +27,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
+@Test(groups = "functional")
public class NotificationThreadTest extends AbstractCacheLoaderTestBase
{
private Cache<String, String> cache1, cache2;
17 years, 5 months