Share

From this page you can share Proxy4J to a social bookmarking site or email a link to the page.
Social WebE-mail
Enter multiple addresses on separate lines or separate them with commas.
Proxy4J
(Your Name) has forwarded a page to you from Ajaxonomy
(Your Name) thought you would like to see this page from the Ajaxonomy web site.

Proxy4J

Tagged:  

Proxy4J is a Java library for creating proxies. The project has recently released a stable snapshot (I'm not going to consider it "1.0" until the remoting is done). I originally created Proxy4J as a spin-off from my development on Workhorse, mainly because I wasn't really satisfied with other libraries out there that do proxying (the Commons Proxy library was the closest I could find, but its inability to leverage Java 5+ made it a non-starter).

Proxy4J was designed to allow you to quickly create a proxy for any one of a number of common use cases:

  • Virtual Proxies. Also known as delegation proxies, these proxies simply pass the method invocation directly to the "real subject", which may have some indirection in how it is created or fetched (e.g. the classic lazy-loading proxy).
  • Invocation Handlers. These are a direct parallel to proxies in the JDK, with a slight twist to include type safety in the common case where only one interface is being proxied. Method calls on these proxies are passed to an invocation handler which decides how to handle the call.
  • Interceptors. These are proxies where one or more interceptors may get called prior to invoking the method on the "real subject". In Proxy4J interceptors are very granular and may be specified on a per-method basis.

Interceptors in particular are pretty slick: they allow you to keep a stack of MethodInterceptors (note that the library supports the AOP Alliance API), which are invoked in order prior to invoking the intercepted method. Proxy4J allows different underlying implementations, including CGLIB, Javassist, and the built-in proxying in the JDK itself.

Documentation for Proxy4J can be found here. You can also download the jar here.