[infinispan-commits] Infinispan SVN: r568 - in trunk/core/src/main/java/org/infinispan: config/parsing and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Tue Jul 14 14:09:54 EDT 2009
Author: vblagojevic at jboss.com
Date: 2009-07-14 14:09:54 -0400 (Tue, 14 Jul 2009)
New Revision: 568
Modified:
trunk/core/src/main/java/org/infinispan/config/Configuration.java
trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java
trunk/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java
trunk/core/src/main/java/org/infinispan/config/GlobalConfiguration.java
trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java
trunk/core/src/main/java/org/infinispan/loaders/decorators/SingletonStoreConfig.java
Log:
schema creation final touches
Modified: trunk/core/src/main/java/org/infinispan/config/Configuration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/Configuration.java 2009-07-13 23:25:11 UTC (rev 567)
+++ trunk/core/src/main/java/org/infinispan/config/Configuration.java 2009-07-14 18:09:54 UTC (rev 568)
@@ -32,6 +32,7 @@
import org.infinispan.factories.annotations.Inject;
import org.infinispan.factories.annotations.NonVolatile;
import org.infinispan.factories.annotations.Start;
+import org.infinispan.config.parsing.CustomIntereceptorsSchemaWriter;
import org.infinispan.util.ReflectionUtil;
import org.infinispan.util.concurrent.IsolationLevel;
@@ -59,7 +60,9 @@
@ConfigurationElement(name = "eviction", parent = "default", description = ""),
@ConfigurationElement(name = "expiration", parent = "default", description = ""),
@ConfigurationElement(name = "unsafe", parent = "default", description = ""),
- @ConfigurationElement(name = "customInterceptors", parent = "default", customReader=CustomInterceptorConfigReader.class)
+ @ConfigurationElement(name = "customInterceptors", parent = "default",
+ customReader=CustomInterceptorConfigReader.class,
+ customWriter=CustomIntereceptorsSchemaWriter.class)
})
public class Configuration extends AbstractNamedCacheConfigurationBean {
private static final long serialVersionUID = 5553791890144997466L;
@@ -376,7 +379,7 @@
}
@ConfigurationAttribute(name = "mode",
- containingElement = "clustering")
+ containingElement = "clustering", allowedValues="LOCAL,REPL,INVALIDATION,DIST")
public void setCacheMode(String cacheMode) {
testImmutability("cacheMode");
if (cacheMode == null) throw new ConfigurationException("Cache mode cannot be null", "CacheMode");
@@ -416,7 +419,7 @@
}
@ConfigurationAttribute(name = "strategy",
- containingElement = "eviction")
+ containingElement = "eviction",allowedValues="NONE, FIFO, LRU")
public void setEvictionStrategy(String eStrategy){
testImmutability("evictionStrategy");
this.evictionStrategy = EvictionStrategy.valueOf(uc(eStrategy));
@@ -518,7 +521,8 @@
}
@ConfigurationAttribute(name = "isolationLevel",
- containingElement = "locking")
+ containingElement = "locking",
+ allowedValues="NONE,SERIALIZABLE,REPEATABLE_READ,READ_COMMITTED,READ_UNCOMMITTED")
public void setIsolationLevel(String isolationLevel) {
testImmutability("isolationLevel");
if (isolationLevel == null) throw new ConfigurationException("Isolation level cannot be null", "IsolationLevel");
Modified: trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java 2009-07-13 23:25:11 UTC (rev 567)
+++ trunk/core/src/main/java/org/infinispan/config/ConfigurationElement.java 2009-07-14 18:09:54 UTC (rev 568)
@@ -23,13 +23,14 @@
import java.lang.annotation.*;
import org.infinispan.config.parsing.ConfigurationElementReader;
+import org.infinispan.config.parsing.ConfigurationElementWriter;
/**
* Represents XML element from a valid Infinispan configuration file.
*
* @author Vladimir Blagojevic
- * @version $Id: ConfigurationElement.java,v 1.5 2008/05/23 11:11:02 belaban Exp $
+ * @version $Id$
*/
@Retention(RetentionPolicy.RUNTIME)
@@ -43,5 +44,7 @@
String description() default "";
Class <? extends ConfigurationElementReader> customReader() default ConfigurationElementReader.class;
+
+ Class <? extends ConfigurationElementWriter> customWriter() default ConfigurationElementWriter.class;
}
Modified: trunk/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java 2009-07-13 23:25:11 UTC (rev 567)
+++ trunk/core/src/main/java/org/infinispan/config/CustomInterceptorConfig.java 2009-07-14 18:09:54 UTC (rev 568)
@@ -21,6 +21,8 @@
*/
package org.infinispan.config;
+import java.util.Locale;
+
import net.jcip.annotations.Immutable;
import org.infinispan.interceptors.base.CommandInterceptor;
@@ -39,7 +41,13 @@
private int index = -1;
private String after;
private String before;
+ private Position position;
+ private String className;
+ public CustomInterceptorConfig() {
+ super();
+ }
+
/**
* Builds a custom interceptor configuration.
*
@@ -89,6 +97,24 @@
this.interceptor = interceptor;
}
+ public Position getPosition() {
+ return position;
+ }
+
+ public void setPosition(Position position) {
+ this.position = position;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ @ConfigurationAttribute(name = "class",
+ containingElement = "interceptor")
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
/**
* Shall this interceptor be the first one in the chain?
*/
@@ -105,6 +131,12 @@
testImmutability("last");
isLast = last;
}
+
+ @ConfigurationAttribute(name = "position",
+ containingElement = "interceptor")
+ public void setPosition(String pos) {
+ setPosition(Position.valueOf(uc(pos)));
+ }
/**
* Put this interceptor at the specified index, after the default chain is built. If the index is not valid (negative
@@ -158,9 +190,16 @@
/**
* Returns a the interceptor that we want to add to the chain.
*/
- public CommandInterceptor getInterceptor() {
+ public CommandInterceptor getInterceptor() {
return interceptor;
}
+
+ /**
+ * Returns a the interceptor that we want to add to the chain.
+ */
+ public void setInterceptor(CommandInterceptor interceptor) {
+ this.interceptor = interceptor;
+ }
/**
* @see #setFirst(boolean)
@@ -245,4 +284,12 @@
dolly.before = before;
return dolly;
}
+
+ protected String uc(String s) {
+ return s == null ? null : s.toUpperCase(Locale.ENGLISH);
+ }
+
+ enum Position {
+ FIRST,LAST;
+ }
}
Modified: trunk/core/src/main/java/org/infinispan/config/GlobalConfiguration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/GlobalConfiguration.java 2009-07-13 23:25:11 UTC (rev 567)
+++ trunk/core/src/main/java/org/infinispan/config/GlobalConfiguration.java 2009-07-14 18:09:54 UTC (rev 568)
@@ -230,6 +230,10 @@
this.transportProperties = toTypedProperties(transportProperties);
}
+ @ConfigurationProperties(elements = {
+ @ConfigurationProperty(name = "configurationString", parentElement = "transport"),
+ @ConfigurationProperty(name = "configurationFile", parentElement = "transport"),
+ @ConfigurationProperty(name = "configurationXml", parentElement = "transport") })
public void setTransportProperties(String transportPropertiesString) {
testImmutability("transportProperties");
this.transportProperties = toTypedProperties(transportPropertiesString);
Modified: trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java 2009-07-13 23:25:11 UTC (rev 567)
+++ trunk/core/src/main/java/org/infinispan/config/parsing/CustomInterceptorConfigReader.java 2009-07-14 18:09:54 UTC (rev 568)
@@ -49,56 +49,45 @@
public void process(Element e, AbstractConfigurationBean bean) {
NodeList interceptorNodes = e.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;
-
+ for (int i = 0; i < interceptorNodes.getLength(); i++) {
Element interceptorElement = (Element) interceptorNodes.item(i);
+ CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig();
String position = parser.getAttributeValue(interceptorElement, "position");
- if (parser.existsAttribute(position) && "first".equalsIgnoreCase(position)) {
- first = true;
+ if (parser.existsAttribute(position)) {
+ customInterceptorConfig.setPosition(position);
+ }
+ String indexStr = parser.getAttributeValue(interceptorElement, "index");
+ int index = parser.existsAttribute(indexStr) ? parser.getInt(indexStr) : -1;
+ customInterceptorConfig.setIndex(index);
+ String before = parser.getAttributeValue(interceptorElement, "before");
+ if (parser.existsAttribute(before)){
+ customInterceptorConfig.setBeforeInterceptor(before);
}
- if (parser.existsAttribute(position) && "last".equalsIgnoreCase(position)) {
- last = true;
+ String after = parser.getAttributeValue(interceptorElement, "after");
+ if (parser.existsAttribute(after)){
+ customInterceptorConfig.setAfterInterceptor(before);
+ }
+
+ String interceptorClass = parser.getAttributeValue(interceptorElement, "class");
+ if (!parser.existsAttribute(interceptorClass))
+ throw new ConfigurationException("Interceptor class cannot be empty!");
+
+ customInterceptorConfig.setClassName(interceptorClass);
+
+ CommandInterceptor interceptor;
+ try {
+ interceptor = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
+ } catch (Exception ex) {
+ throw new ConfigurationException(
+ "CommandInterceptor class is not properly loaded in classloader", ex);
}
- String indexStr = parser.getAttributeValue(interceptorElement, "index");
- index = parser.existsAttribute(indexStr) ? parser.getInt(indexStr) : -1;
-
- before = parser.getAttributeValue(interceptorElement, "before");
- if (!parser.existsAttribute(before))
- before = null;
- after = parser.getAttributeValue(interceptorElement, "after");
- if (!parser.existsAttribute(after))
- after = null;
-
- CommandInterceptor interceptor = buildCommandInterceptor(interceptorElement);
- CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptor,
- first, last, index, after, before);
+ Properties p = XmlConfigHelper.extractProperties(interceptorElement);
+ if (p != null)
+ XmlConfigHelper.setValues(interceptor, p, false, true);
+ customInterceptorConfig.setInterceptor(interceptor);
+
interceptorConfigs.add(customInterceptorConfig);
}
((Configuration) bean).setCustomInterceptors(interceptorConfigs);
- }
-
- /**
- * Builds the interceptor based on the interceptor class and also sets all its attributes.
- */
- private CommandInterceptor buildCommandInterceptor(Element element) {
- String interceptorClass = parser.getAttributeValue(element, "class");
- if (!parser.existsAttribute(interceptorClass))
- throw new ConfigurationException("Interceptor class cannot be empty!");
- CommandInterceptor result;
- try {
- result = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
- } catch (Exception e) {
- throw new ConfigurationException(
- "CommandInterceptor class is not properly loaded in classloader", e);
- }
- Properties p = XmlConfigHelper.extractProperties(element);
- if (p != null)
- XmlConfigHelper.setValues(result, p, false, true);
- return result;
- }
+ }
}
Modified: trunk/core/src/main/java/org/infinispan/loaders/decorators/SingletonStoreConfig.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/loaders/decorators/SingletonStoreConfig.java 2009-07-13 23:25:11 UTC (rev 567)
+++ trunk/core/src/main/java/org/infinispan/loaders/decorators/SingletonStoreConfig.java 2009-07-14 18:09:54 UTC (rev 568)
@@ -23,7 +23,7 @@
return singletonStoreEnabled;
}
- @ConfigurationAttribute(name = "singletonStoreEnabled",
+ @ConfigurationAttribute(name = "enabled",
containingElement = "singletonStore",
description="Switch to enable singleton store")
public void setSingletonStoreEnabled(boolean singletonStoreEnabled) {
More information about the infinispan-commits
mailing list