Skip to content
This repository has been archived by the owner on Sep 5, 2018. It is now read-only.

Commit

Permalink
support javassist proxy object
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jul 22, 2012
1 parent af96dfa commit 89f7096
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -349,7 +349,7 @@ public final void write(Object object) {


Class<?> clazz = object.getClass(); Class<?> clazz = object.getClass();
ObjectSerializer writer = getObjectWriter(clazz); ObjectSerializer writer = getObjectWriter(clazz);

try { try {
writer.write(this, object, null, null); writer.write(this, object, null, null);
} catch (IOException e) { } catch (IOException e) {
Expand Down Expand Up @@ -440,21 +440,25 @@ public ObjectSerializer getObjectWriter(Class<?> clazz) {
config.put(clazz, ClobSeriliazer.instance); config.put(clazz, ClobSeriliazer.instance);
} else { } else {
boolean isCglibProxy = false; boolean isCglibProxy = false;
boolean isJavassistProxy = false;
for (Class<?> item : clazz.getInterfaces()) { for (Class<?> item : clazz.getInterfaces()) {
if (item.getName().equals("net.sf.cglib.proxy.Factory")) { if (item.getName().equals("net.sf.cglib.proxy.Factory")) {
isCglibProxy = true; isCglibProxy = true;
break; break;
} else if (item.getName().equals("javassist.util.proxy.ProxyObject")) {
isJavassistProxy = true;
break;
} }
} }

if (isCglibProxy) { if (isCglibProxy || isJavassistProxy) {
Class<?> superClazz = clazz.getSuperclass(); Class<?> superClazz = clazz.getSuperclass();

ObjectSerializer superWriter = getObjectWriter(superClazz); ObjectSerializer superWriter = getObjectWriter(superClazz);
config.put(clazz, superWriter); config.put(clazz, superWriter);
return superWriter; return superWriter;
} }

if (Proxy.isProxyClass(clazz)) { if (Proxy.isProxyClass(clazz)) {
config.put(clazz, config.createJavaBeanSerializer(clazz)); config.put(clazz, config.createJavaBeanSerializer(clazz));
} else { } else {
Expand Down

0 comments on commit 89f7096

Please sign in to comment.