[infinispan-commits] Infinispan SVN: r1108 - in trunk: core/src/main/java/org/infinispan/factories and 4 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Fri Nov 6 16:53:40 EST 2009
Author: vblagojevic at jboss.com
Date: 2009-11-06 16:53:40 -0500 (Fri, 06 Nov 2009)
New Revision: 1108
Added:
trunk/core/src/main/java/org/infinispan/factories/ModuleLifecycle.java
trunk/core/src/main/java/org/infinispan/util/Proxies.java
trunk/query/src/main/java/org/infinispan/query/impl/LifecycleManager.java
Modified:
trunk/core/src/main/java/org/infinispan/config/Configuration.java
trunk/core/src/main/java/org/infinispan/config/ModuleConfigurationResolverVisitor.java
trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java
trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java
trunk/core/src/main/java/org/infinispan/factories/GlobalComponentRegistry.java
trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java
trunk/query/src/main/resources/infinispan-module.properties
trunk/query/src/test/java/org/infinispan/query/config/QueryParsingTest.java
Log:
[ISPN-245] - Core module to delegate lifecycle events to sub-modules
Modified: trunk/core/src/main/java/org/infinispan/config/Configuration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/Configuration.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/core/src/main/java/org/infinispan/config/Configuration.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -1811,7 +1811,7 @@
/**
*
- * @configRef name="modules",desc="Configures custom modules"
+ * @configRef name="modules",desc="Modules configuration."
*/
@XmlAccessorType(XmlAccessType.FIELD)
public static class ModulesExtensionType extends AbstractNamedCacheConfigurationBean {
@@ -1849,6 +1849,10 @@
public void accept(ConfigurationBeanVisitor v) {
v.visitModulesExtentionsType(this);
}
+
+ public void addModuleConfigurationBean(ModuleConfigurationBean bean) {
+ moduleList.add(bean);
+ }
public List<ModuleConfigurationBean> getModuleConfigs() {
return moduleList;
@@ -1872,54 +1876,67 @@
}
}
+ /**
+ *
+ * @configRef name="module",desc="Configures a single custom module."
+ */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = ELEMENT_MODULE_NAME)
public static class ModuleConfigurationBean extends AbstractNamedCacheConfigurationBean {
-
- /** The serialVersionUID */
- private static final long serialVersionUID = -3590043692128929343L;
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -3590043692128929343L;
- @XmlAttribute(name = MODULE_IDENTIFIER)
- private String name;
+ /** @configRef desc="Name of the module" */
+ @XmlAttribute(name = MODULE_IDENTIFIER)
+ private String name;
- @XmlAttribute
- private String configClassName;
+ @XmlTransient
+ private String configClassName;
- @XmlTransient
- private AbstractConfigurationBean configBean;
+ @XmlTransient
+ private AbstractConfigurationBean configBean;
- @XmlAnyElement
- private Element child;
-
- public String getName() {
- return name;
- }
+ @XmlAnyElement
+ private Element child;
- @Override
- public ModuleConfigurationBean clone() throws CloneNotSupportedException {
- ModuleConfigurationBean dolly = (ModuleConfigurationBean) super.clone();
- return dolly;
- }
+ public String getName() {
+ return name;
+ }
- public Class<AbstractConfigurationBean> resolveConfigurationClass(String className)
- throws ClassNotFoundException {
- if(className!= null) {
- return Util.loadClass(className);
- }
- if(configClassName != null) {
- return Util.loadClass(configClassName);
- }
- throw new ClassNotFoundException("Class for module configuration bean is not specified");
- }
+ @Override
+ public ModuleConfigurationBean clone() throws CloneNotSupportedException {
+ ModuleConfigurationBean dolly = (ModuleConfigurationBean) super.clone();
+ return dolly;
+ }
- void setConfigurationBean(AbstractConfigurationBean configBean) {
- this.configBean = configBean;
- }
+ public Class<AbstractConfigurationBean> resolveConfigurationClass()
+ throws ClassNotFoundException {
+ if (configClassName != null) {
+ return Util.loadClass(configClassName);
+ }
+ throw new ClassNotFoundException("Class for module configuration bean is not specified");
+ }
- public AbstractConfigurationBean getConfigurationBean() {
- return configBean;
- }
+ void setConfigurationBean(AbstractConfigurationBean configBean) {
+ this.configBean = configBean;
+ }
+
+ public AbstractConfigurationBean getConfigurationBean() {
+ return configBean;
+ }
+
+ public String getConfigClassName() {
+ return configClassName;
+ }
+
+ public void setConfigClassName(String configClassName) {
+ this.configClassName = configClassName;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
/**
Modified: trunk/core/src/main/java/org/infinispan/config/ModuleConfigurationResolverVisitor.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/ModuleConfigurationResolverVisitor.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/core/src/main/java/org/infinispan/config/ModuleConfigurationResolverVisitor.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -59,7 +59,8 @@
try {
ModuleProperties props = ModuleProperties.loadModuleProperties(module.getName());
if (props != null) {
- Class<AbstractConfigurationBean> configurationClass = module.resolveConfigurationClass(props.getConfigurationClassName());
+ module.setConfigClassName(props.getConfigurationClassName());
+ Class<AbstractConfigurationBean> configurationClass = module.resolveConfigurationClass();
NodeList nodeList = root.getElementsByTagName(Configuration.ELEMENT_MODULE_NAME);
findModuleInXML:
Modified: trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/core/src/main/java/org/infinispan/factories/AbstractComponentRegistry.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -36,6 +36,7 @@
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.lifecycle.Lifecycle;
import org.infinispan.util.BeanUtils;
+import org.infinispan.util.ModuleProperties;
import org.infinispan.util.ReflectionUtil;
import org.infinispan.util.logging.Log;
@@ -93,7 +94,20 @@
// component and method containers
final Map<String, Component> componentLookup = new HashMap<String, Component>();
+
+ protected static List<ModuleLifecycle> moduleLifecycles;
+
+ static {
+ try {
+ moduleLifecycles = ModuleProperties.resolveModuleLifecycles();
+ } catch (Exception e) {
+ moduleLifecycles = Collections.emptyList();
+ }
+ }
+
+
+
volatile ComponentStatus state = ComponentStatus.INSTANTIATED;
/**
Modified: trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/core/src/main/java/org/infinispan/factories/ComponentRegistry.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -139,17 +139,35 @@
// able to locate this registry via the InboundInvocationHandler
globalComponents.registerNamedComponentRegistry(this, cacheName);
+ if (needToNotify) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheStarting(this, cacheName);
+ }
+ }
super.start();
if (needToNotify && state == ComponentStatus.RUNNING) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheStarted(this, cacheName);
+ }
cacheManagerNotifier.notifyCacheStarted(cacheName);
}
}
@Override
public void stop() {
- if (state.stopAllowed()) globalComponents.unregisterNamedComponentRegistry(cacheName);
+ if (state.stopAllowed())globalComponents.unregisterNamedComponentRegistry(cacheName);
boolean needToNotify = state == ComponentStatus.RUNNING || state == ComponentStatus.INITIALIZING;
+ if (needToNotify) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheStopping(this, cacheName);
+ }
+ }
super.stop();
- if (state == ComponentStatus.TERMINATED && needToNotify) cacheManagerNotifier.notifyCacheStopped(cacheName);
+ if (state == ComponentStatus.TERMINATED && needToNotify) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheStopped(this, cacheName);
+ }
+ cacheManagerNotifier.notifyCacheStopped(cacheName);
+ }
}
}
Modified: trunk/core/src/main/java/org/infinispan/factories/GlobalComponentRegistry.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/GlobalComponentRegistry.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/core/src/main/java/org/infinispan/factories/GlobalComponentRegistry.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -8,6 +8,7 @@
import org.infinispan.factories.scopes.Scope;
import org.infinispan.factories.scopes.Scopes;
import org.infinispan.jmx.CacheManagerJmxRegistration;
+import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.CacheManager;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -118,4 +119,34 @@
for (ComponentRegistry cr : namedComponents.values())
cr.rewire();
}
+
+ public void start() {
+ boolean needToNotify = state != ComponentStatus.RUNNING && state != ComponentStatus.INITIALIZING;
+ if (needToNotify) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheManagerStarting(this);
+ }
+ }
+ super.start();
+ if (needToNotify && state == ComponentStatus.RUNNING) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheManagerStarted(this);
+ }
+ }
+ }
+
+ public void stop() {
+ boolean needToNotify = state == ComponentStatus.RUNNING || state == ComponentStatus.INITIALIZING;
+ if (needToNotify) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheManagerStopping(this);
+ }
+ }
+ super.stop();
+ if (state == ComponentStatus.TERMINATED && needToNotify) {
+ for (ModuleLifecycle l : moduleLifecycles) {
+ l.cacheManagerStopped(this);
+ }
+ }
+ }
}
Added: trunk/core/src/main/java/org/infinispan/factories/ModuleLifecycle.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/factories/ModuleLifecycle.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/factories/ModuleLifecycle.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.infinispan.factories;
+
+/**
+ * ModuleLifecycle is an internal API hook for delegating lifecycle events to modules.
+ * <p>
+ *
+ * For example, the 'tree' module needs to register specific types with the Marshaller. The 'query'
+ * module needs to register an interceptor with the Cache if the Cache has enabled querying etc etc.
+ *
+ *
+ * @author Manik Surtani
+ * @since 4.0
+ */
+public interface ModuleLifecycle {
+ void cacheManagerStarting(GlobalComponentRegistry gcr);
+
+ void cacheManagerStarted(GlobalComponentRegistry gcr);
+
+ void cacheManagerStopping(GlobalComponentRegistry gcr);
+
+ void cacheManagerStopped(GlobalComponentRegistry gcr);
+
+ void cacheStarting(ComponentRegistry cr, String cacheName);
+
+ void cacheStarted(ComponentRegistry cr, String cacheName);
+
+ void cacheStopping(ComponentRegistry cr, String cacheName);
+
+ void cacheStopped(ComponentRegistry cr, String cacheName);
+}
Modified: trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -23,10 +23,16 @@
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
+import java.util.Map.Entry;
import org.infinispan.config.ConfigurationException;
+import org.infinispan.factories.ModuleLifecycle;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -47,7 +53,7 @@
public static final String MODULE_NAME_KEY = "infinispan.module.name";
public static final String MODULE_CONFIGURATION_CLASS = "infinispan.module.configurationClassName";
public static final String MODULE_LIFECYCLE = "infinispan.module.lifecycle";
-
+
protected static Enumeration<URL> getResources(String filename) throws IOException {
Enumeration<URL> result;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -60,10 +66,11 @@
}
public static ModuleProperties loadModuleProperties(String moduleName) throws IOException {
+
Enumeration<URL> resources = getResources(MODULE_PROPERTIES_FILENAME);
if (resources == null)
- throw new IOException("Could not find any " + MODULE_PROPERTIES_FILENAME
- + " files on classpath");
+ throw new IOException("Could not find " + MODULE_PROPERTIES_FILENAME
+ + " files on classpath for module " + moduleName);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
@@ -77,6 +84,42 @@
}
return null;
}
+
+ private static Map<String, ModuleProperties> loadModuleProperties() throws IOException {
+ Map<String, ModuleProperties> map = new HashMap<String, ModuleProperties>();
+ Enumeration<URL> resources = getResources(MODULE_PROPERTIES_FILENAME);
+ if (resources != null) {
+ while (resources.hasMoreElements()) {
+ URL url = null;
+ try {
+ url = resources.nextElement();
+ ModuleProperties props = new ModuleProperties();
+ props.load(url.openStream());
+ props.verify();
+ map.put(props.getName(), props);
+ } catch (Exception e) {
+ log.warn("Could not load module at URL " + url, e);
+ }
+ }
+ }
+ return map;
+ }
+
+ public static List<ModuleLifecycle> resolveModuleLifecycles() throws Exception {
+ List<ModuleLifecycle> lifecycles = new ArrayList<ModuleLifecycle>();
+ Map<String, ModuleProperties> p = ModuleProperties.loadModuleProperties();
+ for (Entry<String, ModuleProperties> m : p.entrySet()) {
+ try {
+ String lifecycleClassName = m.getValue().getLifecycleClassName();
+ Class<?> loadClass = Util.loadClass(lifecycleClassName);
+ ModuleLifecycle ml = (ModuleLifecycle) Proxies.newCatchThrowableProxy((ModuleLifecycle) loadClass.newInstance());
+ lifecycles.add(ml);
+ } catch (Exception e) {
+ log.warn("Module " + m.getKey() + " loaded, but could not be initialized ", e);
+ }
+ }
+ return lifecycles;
+ }
public String getName() {
return super.getProperty(MODULE_NAME_KEY);
Added: trunk/core/src/main/java/org/infinispan/util/Proxies.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/Proxies.java (rev 0)
+++ trunk/core/src/main/java/org/infinispan/util/Proxies.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.infinispan.util;
+
+import java.lang.reflect.Method;
+
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+/**
+ * Proxies is a collection of useful dynamic profixes. Internal use only.
+ *
+ * @author vladimir
+ * @since 4.0
+ */
+public class Proxies {
+
+ public static Object newCatchThrowableProxy(Object obj) {
+ return java.lang.reflect.Proxy.newProxyInstance(obj.getClass().getClassLoader(),
+ obj.getClass().getInterfaces(), new CatchThrowableProxy(obj));
+ }
+
+ /**
+ * CatchThrowableProxy is a wrapper around interface that does not allow any exception to be
+ * thrown when invoking methods on that interface. All exceptions are logged but not propagated
+ * to the caller.
+ *
+ *
+ */
+ static class CatchThrowableProxy implements java.lang.reflect.InvocationHandler {
+
+ private static final Log log = LogFactory.getLog(CatchThrowableProxy.class);
+
+ private Object obj;
+
+ public static Object newInstance(Object obj) {
+ return java.lang.reflect.Proxy.newProxyInstance(obj.getClass().getClassLoader(),
+ obj.getClass().getInterfaces(), new CatchThrowableProxy(obj));
+ }
+
+ private CatchThrowableProxy(Object obj) {
+ this.obj = obj;
+ }
+
+ public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
+ Object result = null;
+ try {
+ result = m.invoke(obj, args);
+ } catch (Throwable t) {
+ log.warn("Invocation of " + m.getName() + " threw an exception " + t.getCause() + ". Exception is ignored.");
+ } finally {
+ }
+ return result;
+ }
+ }
+}
+
Added: trunk/query/src/main/java/org/infinispan/query/impl/LifecycleManager.java
===================================================================
--- trunk/query/src/main/java/org/infinispan/query/impl/LifecycleManager.java (rev 0)
+++ trunk/query/src/main/java/org/infinispan/query/impl/LifecycleManager.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.infinispan.query.impl;
+
+import org.infinispan.factories.ComponentRegistry;
+import org.infinispan.factories.GlobalComponentRegistry;
+import org.infinispan.factories.ModuleLifecycle;
+
+public class LifecycleManager implements ModuleLifecycle {
+
+ @Override
+ public void cacheManagerStarted(GlobalComponentRegistry gcr) {
+ System.out.println("cacheManagerStarted");
+ }
+
+ @Override
+ public void cacheManagerStarting(GlobalComponentRegistry gcr) {
+ System.out.println("cacheManagerStarting");
+ }
+
+ @Override
+ public void cacheManagerStopped(GlobalComponentRegistry gcr) {
+ System.out.println("cacheManagerStopped");
+ }
+
+ @Override
+ public void cacheManagerStopping(GlobalComponentRegistry gcr) {
+ System.out.println("cacheManagerStopping");
+ }
+
+ @Override
+ public void cacheStarted(ComponentRegistry cr, String cacheName) {
+ System.out.println("cacheStarted");
+ }
+
+ @Override
+ public void cacheStarting(ComponentRegistry cr, String cacheName) {
+ System.out.println("cacheStarting");
+ }
+
+ @Override
+ public void cacheStopped(ComponentRegistry cr, String cacheName) {
+ System.out.println("cacheStopped " + cacheName);
+ }
+
+ @Override
+ public void cacheStopping(ComponentRegistry cr, String cacheName) {
+ System.out.println("cacheStopping " + cacheName);
+ }
+}
Modified: trunk/query/src/main/resources/infinispan-module.properties
===================================================================
--- trunk/query/src/main/resources/infinispan-module.properties 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/query/src/main/resources/infinispan-module.properties 2009-11-06 21:53:40 UTC (rev 1108)
@@ -1,3 +1,3 @@
infinispan.module.name=query
infinispan.module.configurationClassName=org.infinispan.query.config.QueryConfigurationBean
-infinispan.module.lifecycle=undefined
\ No newline at end of file
+infinispan.module.lifecycle=org.infinispan.query.impl.LifecycleManager
\ No newline at end of file
Modified: trunk/query/src/test/java/org/infinispan/query/config/QueryParsingTest.java
===================================================================
--- trunk/query/src/test/java/org/infinispan/query/config/QueryParsingTest.java 2009-11-06 08:56:31 UTC (rev 1107)
+++ trunk/query/src/test/java/org/infinispan/query/config/QueryParsingTest.java 2009-11-06 21:53:40 UTC (rev 1108)
@@ -3,18 +3,20 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import org.infinispan.Cache;
import org.infinispan.config.Configuration;
import org.infinispan.config.GlobalConfiguration;
import org.infinispan.config.InfinispanConfiguration;
import org.infinispan.config.Configuration.ModuleConfigurationBean;
+import org.infinispan.manager.CacheManager;
import org.infinispan.remoting.transport.jgroups.JGroupsTransport;
import org.infinispan.test.AbstractInfinispanTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
import org.testng.annotations.Test;
@Test(groups = "unit", testName = "config.parsing.QueryParsingTest")
public class QueryParsingTest extends AbstractInfinispanTest {
-
public void testQueryConfig() throws Exception {
String config = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"\n" +
@@ -34,20 +36,24 @@
" </default>\n" +
"</infinispan>";
- System.out.println(config);
+ System.out.println(config);
- InputStream is = new ByteArrayInputStream(config.getBytes());
- InputStream schema = InfinispanConfiguration.findSchemaInputStream();
- assert schema != null;
- InfinispanConfiguration c = InfinispanConfiguration.newInfinispanConfiguration(is,schema);
- GlobalConfiguration gc = c.parseGlobalConfiguration();
- assert gc.getTransportClass().equals(JGroupsTransport.class.getName());
- assert gc.getClusterName().equals("demoCluster");
+ InputStream is = new ByteArrayInputStream(config.getBytes());
+ InputStream schema = InfinispanConfiguration.findSchemaInputStream();
+ assert schema != null;
+ InfinispanConfiguration c = InfinispanConfiguration.newInfinispanConfiguration(is, schema);
+ GlobalConfiguration gc = c.parseGlobalConfiguration();
+ assert gc.getTransportClass().equals(JGroupsTransport.class.getName());
+ assert gc.getClusterName().equals("demoCluster");
- Configuration def = c.parseDefaultConfiguration();
- ModuleConfigurationBean extensionConfig = def.getModuleConfigurationBean("query");
- QueryConfigurationBean bean = (QueryConfigurationBean) extensionConfig.getConfigurationBean();
- assert bean.isEnabled();
- assert bean.isIndexLocalOnly();
- }
- }
\ No newline at end of file
+ Configuration def = c.parseDefaultConfiguration();
+ ModuleConfigurationBean extensionConfig = def.getModuleConfigurationBean("query");
+ QueryConfigurationBean bean = (QueryConfigurationBean) extensionConfig.getConfigurationBean();
+ assert bean.isEnabled();
+ assert bean.isIndexLocalOnly();
+
+ CacheManager cm = TestCacheManagerFactory.createClusteredCacheManager(def);
+ Cache<Object, Object> cache = cm.getCache("test");
+ cache.stop();
+ }
+}
\ No newline at end of file
More information about the infinispan-commits
mailing list