answered
2016-12-02 10:35:40 +0800
mikrobe 100 ● 1 ● 5 Since my domain model consists of hundreds of generated classes, use of ProxyHelper.addIgnoreProxyClass(Class type) is quite cumbersome and I cannot either configure zk.xml.
So I found a trick that could, if ZKoss developers like it, be added to the distributed ProxyHelper.
I replaced ProxyHelper class with my own one that extends it with a method that allows to specify a Superclass to ignore. The method checkImmutable will additionally compare the parameter type's superclasses against that Superclass. Here it is the change:
public class ProxyHelper {
...
private static Map<Class<?>, Boolean> _ignoredSuperClasses = new ConcurrentHashMap<Class<?>, Boolean>();
...
public static void addIgnoredProxySuperClass(Class<?> type) {
_ignoredSuperClasses.put(type, Boolean.TRUE);
}
...
private static boolean checkImmutable(Class<?> type) {
if (_ignoredClasses.containsKey(type))
return true;
if (Modifier.isFinal(type.getModifiers())) {
_ignoredClasses.put(type, Boolean.TRUE);
return true;
}
Class c = type;
while (c != null) {
if(_ignoredSuperClasses.containsKey(c))
return true;
c = c.getSuperclass();
}
return false;
}
...
}
Now I can use it in my WepappInit listener adding my domain model's superclass
ProxyHelper.addIgnoredProxySuperClass(AbstractDomainFacade.class);