Apache Commons Proxy 1.0

This is a Java-powered library for creating dynamic proxies
The library supports dynamic proxy generation using proxy factories, invokers, object providers and interceptors.

Proxy factories encapsulate all necessary proxying logic away from your code. Switching proxying techniques/technologies is as simple as using a different proxy factory implementation class. Currently, Commons Proxy provides proxy factory implementations using JDK proxies, CGLIB , and Javassist.

Object providers provide the objects which will be the "target" of a proxy.

An invoker handles all method invocations using a single method.

Commons Proxy allows to "intercept" a method invocation using Interceptors. Interceptors provide rudimentary aspect-oriented programming support, allowing you to alter the results/effects of a method invocation without actually changing the implementation of the method itself.

Main features:

  • Usage:
  • Deferred Initialization - the proxy acts as a "stand-in" for the actual implementation allowing it to be instantiated only when absolutely necessary.
  • Security - the proxy object can verify that the user actually has the permission to execute the method (a la EJB).
  • Logging - the proxy can log evey method invocation, providing valuable debugging information.
  • Performance Monitoring - the proxy can log each method invocation to a performance monitor allowing system administrators to see what parts of the system are potentially bogged down.
  • Proxy objects created using proxy factories:
  • Delegator Proxies - a proxy that merely delegates each method invocation to an object provided by an object provider .
  • Interceptor Proxies - a proxy that allows an Interceptor to intercept each method invocation as it makes its way to the target of the invocation.
  • Invoker Proxies - a proxy that uses an invoker to handle all method invocations.
  • Object Providers:
  • Constant - Always returns a specific object.
  • Bean - Merely instantiates an object of a specified class each time.
  • Cloning - Reflectively calls the public clone() method on a Cloneable object.
  • Hessian - Returns a Hessian -based service object.
  • Burlap - Returns a Burlap -based service object.
  • JAX-RPC - Returns a JAX-RPC -based service object.
  • Session Bean - Returns a reference to a Session EJB (stateless session beans only).
  • Singleton - Calls a nested provider at most once, returning that original value on all subsequent invocations.
  • Proxy invoker:
  • Null - Always returns a null (useful for the "Null Object" pattern)
  • Apache XML-RPC - Uses Apache XML-RPC to fulfill the method invocation
  • Duck Typing - Supports "duck typing" by adapting a class to an interface it does not implement.
  • Invocation Handler Adapter - Adapts the JDK InvocationHandler interface to the Commons ProxyInvoker interface.
  • Proxy interceptors:
  • Executor - Uses an Executor to execute the method in possibly another thread (only void methods are supported).
  • Logging - Logs all method invocations using the Apache Commons Logging API
  • Filtered - Optionally intercepts a method invocation based on a method filter
  • Method Interceptor Adapter - Adapts the AOP Alliance MethodInterceptor interface to the Commons ProxyInterceptor interface.

last updated on:
February 25th, 2010, 8:09 GMT
developed by:
Apache Software Foundation
license type:
Apache License
operating system(s):
Windows / Linux / Mac OS / BSD / Solaris
C: \ Networking Tools


In a hurry? Add it to your Download Basket!

user rating 1



Add your review!