joaotab / proxytoys

Collection of useful Proxy tools for Java

Home Page:http://proxytoys.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status


Proxy Factories and Common Usage Patterns

Motivation

Have you ever developed code that uses java.lang.reflect.Proxy and thought:

"That CGLIB library sure is cool. I wish I could leverage both standard proxies and CGLIB proxies without changing my code".

With ProxyToys you can! ProxyToys is to proxy generation what Jakarta Commons Logging is to logging - an thin implementation neutral API for Proxy creation. Whether to use standard proxies or CGLIB is a one-line code change.

Features

API Compatible proxy factory providers:

  • Standard proxies of the JDK
  • CGLIB implementation

ProxyToys provides a collection of toys acting as factories for creating "special" proxies such as:

  • Decorators - for simple AOP-like chained method interception
  • Delegates - for method invocation on a delegate object, that might have different type
  • Dispatcher proxy - single proxy instance dispatching method calls to different object with separate types
  • Echo proxy - for tracing method calls
  • Failover objects - fails over to a next object in case of exception
  • Future objects - execute method calls asynchronously
  • Hot swapping proxy - allows implementation hiding that can be swapped, and mutual dependencies
  • Multicasting objects - for multicasting a method invocation to multiple objects
  • Null objects - for default implementations of classes that do nothing at all
  • Pool - for a pool implementation with proxied objects that return automatically to the pool
  • Privilege - execute method calls as privileged actions in a controlled environment

Dependencies

ProxyToys is a compact library. If you choose not to use the CGLIB features it requires no additional libraries.

About

Collection of useful Proxy tools for Java

http://proxytoys.github.io/

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Java 82.6%Language:HTML 15.7%Language:CSS 1.7%