Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #5286
| From | Tom Anderson <twic@urchin.earth.li> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Create Dynamic Proxy for class instead of interface |
| Date | 2011-06-13 11:58 +0100 |
| Organization | Stack Usenet News Service |
| Message-ID | <alpine.DEB.2.00.1106131149420.6141@urchin.earth.li> (permalink) |
| References | <it2hld$h99$1@dont-email.me> |
On Sun, 12 Jun 2011, Stanimir Stamenkov wrote: > The Dynamic Proxy API [1] allows one to create proxy classes > implementing number of specified interfaces. I've wondered if it is > possible and how to create such a proxy class for a specified class and > not interface. I've found Javassit should provide such means, but > haven't really tried it yet: > > http://en.wikipedia.org/wiki/Javassist > > I basically want to create a proxy augmenting an existing object with > additional interface. Is the Javassist library the right tool for doing > this? Are there other similar tools? A number - i wrote a little list at one point: http://urchin.earth.li/~twic/Java_Bytecode_Libraries.html Having said that, while all of these can be used to do the bytecode editing you would need to construct such a proxy, i don't know if all of them include ready-made tools to do it. Probably not. Something else you probably want to know about is the instrumentation API: http://download.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html Essentially, you can use this to get all classes loaded by the JVM to go through some of your code to be modified before loading. That lets you actually rewrite existing classes as they load - no need for proxies, you can change the actual classes. This is commonly used by things like JPA and AOP implementations. tom -- FREQUENT VIOLENT BLOODY
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar
Create Dynamic Proxy for class instead of interface Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-12 17:15 +0300
Re: Create Dynamic Proxy for class instead of interface Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-12 17:40 +0300
Re: Create Dynamic Proxy for class instead of interface Robert Klemme <shortcutter@googlemail.com> - 2011-06-12 19:07 +0200
Re: Create Dynamic Proxy for class instead of interface Stanimir Stamenkov <s7an10@netscape.net> - 2011-06-12 20:42 +0300
Re: Create Dynamic Proxy for class instead of interface Tom Anderson <twic@urchin.earth.li> - 2011-06-13 11:58 +0100
csiph-web