[infinispan-commits] Infinispan SVN: r1543 - trunk/core/src/main/java/org/infinispan/util.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Wed Feb 24 09:03:48 EST 2010
Author: manik.surtani at jboss.com
Date: 2010-02-24 09:03:47 -0500 (Wed, 24 Feb 2010)
New Revision: 1543
Modified:
trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java
trunk/core/src/main/java/org/infinispan/util/Proxies.java
Log:
* Should not require that all module hooks exist
* Should scan superclass for interfaces when building dynamic proxy
Modified: trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java 2010-02-24 13:14:42 UTC (rev 1542)
+++ trunk/core/src/main/java/org/infinispan/util/ModuleProperties.java 2010-02-24 14:03:47 UTC (rev 1543)
@@ -114,7 +114,8 @@
try {
String lifecycleClassName = m.getValue().getLifecycleClassName();
Class<?> loadClass = Util.loadClass(lifecycleClassName);
- ModuleLifecycle ml = (ModuleLifecycle) Proxies.newCatchThrowableProxy((ModuleLifecycle) loadClass.newInstance());
+ Object proxy = Proxies.newCatchThrowableProxy((ModuleLifecycle) loadClass.newInstance());
+ ModuleLifecycle ml = (ModuleLifecycle) proxy;
lifecycles.add(ml);
} catch (Exception e) {
log.warn("Module " + m.getKey() + " loaded, but could not be initialized ", e);
@@ -138,16 +139,19 @@
protected void verify() {
if (getName() == null)
throw new ConfigurationException(
- "Module propertes does not specify module name. Module name should be specified using key "
+ "Module properties does not specify module name. Module name should be specified using key "
+ MODULE_NAME_KEY);
- if (getConfigurationClassName() == null)
- throw new ConfigurationException(
- "Module propertes does not specify module configuration class name. Module configuration class name should be specified using key "
- + MODULE_CONFIGURATION_CLASS);
-
- if (getLifecycleClassName() == null)
- throw new ConfigurationException(
- "Module propertes does not specify module lifecycle class name. Module lifecycle class name should be specified using key "
- + MODULE_LIFECYCLE);
+
+ // we should not *require* that every module supplies these...
+
+// if (getConfigurationClassName() == null)
+// throw new ConfigurationException(
+// "Module properties does not specify module configuration class name. Module configuration class name should be specified using key "
+// + MODULE_CONFIGURATION_CLASS);
+//
+// if (getLifecycleClassName() == null)
+// throw new ConfigurationException(
+// "Module properties does not specify module lifecycle class name. Module lifecycle class name should be specified using key "
+// + MODULE_LIFECYCLE);
}
}
Modified: trunk/core/src/main/java/org/infinispan/util/Proxies.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/util/Proxies.java 2010-02-24 13:14:42 UTC (rev 1542)
+++ trunk/core/src/main/java/org/infinispan/util/Proxies.java 2010-02-24 14:03:47 UTC (rev 1543)
@@ -22,6 +22,8 @@
package org.infinispan.util;
import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;
@@ -36,8 +38,17 @@
public static Object newCatchThrowableProxy(Object obj) {
return java.lang.reflect.Proxy.newProxyInstance(obj.getClass().getClassLoader(),
- obj.getClass().getInterfaces(), new CatchThrowableProxy(obj));
+ getInterfaces(obj.getClass()), new CatchThrowableProxy(obj));
}
+
+ private static Class[] getInterfaces(Class clazz) {
+ Class[] interfaces = clazz.getInterfaces();
+ if (interfaces.length > 0) return interfaces;
+ Class superclass = clazz.getSuperclass();
+ if (!superclass.equals(Object.class))
+ return superclass.getInterfaces();
+ return new Class[]{};
+ }
/**
* CatchThrowableProxy is a wrapper around interface that does not allow any exception to be
More information about the infinispan-commits
mailing list