Commons Proxy: Dynamic Proxies Made EasyThe Proxy design pattern (GoF) allows you to provide “a surrogate or placeholder for another object to control access to it”. Proxies can be used in many ways, some of which are:
Commons Proxy supports dynamic proxy generation using proxy factories, object providers, invokers, and interceptors. Proxy FactoriesA ProxyFactory encapsulates all necessary proxying logic away from your code. Switching proxying techniques/technologies is as simple as using a different proxy factory implementation class. Commons Proxy provides several proxy factory implementation modules: Additionally, the core library provides a proxy factory implementation that delegates to instances discoverable using the Java ServiceLoader mechanism (including those provided by the listed modules). Proxy factories allow you to create three different types of proxy objects:
Object ProvidersObject providers provide the objects which will be the “target” of a proxy. There are two types of object providers: Core Object ProvidersA core object provider provides a core implementation object. Commons Proxy supports many different implementations including:
InvokersAn Invoker handles all method invocations using a single method. Commons Proxy provides a few invoker implementations:
InterceptorsCommons Proxy allows you to “intercept” a method invocation using an Interceptor. Interceptors provide rudimentary aspect-oriented programming (AOP) support, allowing you to alter the parameters/results of a method invocation without actually changing the implementation of the method itself. Commons Proxy provides a few interceptor implementations including:
SerializationThe proxies created by the provided proxy factories are Serializable in most cases. For more complex cases Commons Proxy provides basic support for the “serialization proxy” pattern. See org.apache.commons.proxy.serialization for details. StubbingThe StubBuilder class allows you to create a proxy with customized behavior specified by a typesafe DSL. The AnnotationBuilder variant provides a simple way to create Java annotation instances at runtime. ReleasesThe latest version is v1.0 (requires Java 1.4 or later). - Download now! For previous releases, see the Apache archive. SupportThe Commons mailing lists act as the main support forum. The user list is suitable for most library usage queries. The dev list is intended for the development discussion. Please remember that the lists are shared between all Commons components, so prefix your email subject with [proxy]. Issues may be reported via ASF JIRA. Please read the instructions carefully to submit a useful bug report or enhancement request. |