[jboss-user] [Javassist] - Create a proxy of proxy
Bozhidar Bozhanov
do-not-reply at jboss.com
Mon Apr 12 04:20:16 EDT 2010
Bozhidar Bozhanov [http://community.jboss.org/people/Glammy] created the discussion
"Create a proxy of proxy"
To view the discussion, visit: http://community.jboss.org/message/536818#536818
--------------------------------------------------------------
I'm using the following code to create a proxy:
public Object createProxiedInstance(Object originalInstance) throws Exception {
Class<?> originalClass = instance.getClass();
ProxyFactory factory = new ProxyFactory();
factory.setSuperclass(originalClass);
factory.setHandler(new MethodHandler() {..});
Class<T> proxyClass = factory.createClass();
return proxyClass.newInstance();
}
It works fine if a pass a normal object. However, if I pass an object that is already a proxy (created by the same method, but with a different method handler), I get:
javassist.bytecode.DuplicateMemberException: duplicate method: setHandler in com.mypackage.Bean_$$_javassist_0_$$_javassist_1
I could work this around by combining the method handler of the original proy and the one of the new proxy, but is there a way to make proxies of proxies, as if the proxies were normal objects?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536818#536818]
Start a new discussion in Javassist at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100412/3876954f/attachment.html
More information about the jboss-user
mailing list