See: Description
| Interface | Description |
|---|---|
| InvokerReference |
Interface to access the
Invoker of the proxy. |
| Class | Description |
|---|---|
| AbstractProxyFactory |
An abstract implementation of a ProxyFactory.
|
| AbstractProxyFactory.CoincidentalInvocationHandlerAdapter |
Generic implementation of a invocation handler with a JDK compatible method and signature.
|
| CglibProxyFactory |
A
ProxyFactory based on CGLIB. |
| CglibProxyFactory.CGLIBInvocationHandlerAdapter |
The native invocation handler.
|
| CglibProxyFactory.ForeignPackageNamingPolicy | |
| StandardProxyFactory |
A
ProxyFactory based on a JDK. |
| StandardProxyFactory.StandardInvocationHandlerAdapter |
The native InvocationHandler implementation.
|
Different implementations of the ProxyFactory interface.
Currently are two implementations supported. One based on the JDK's reflection API and the other one on the CGLIB library.
The usage of a special ProxyFactory is simple and easy:
ProxyFactory factory = new StandardProxyFactory();
List<String> proxy = factory.createProxy(new SimpleInvoker(new ArrayList<String>()), List.class);
proxy.add("Hello World");
System.out.println("Size of list: " + proxy.size());
System.out.println("First element of list: " + proxy.get(0));
The example creates a proxy that implements the List interface. The proxy is backed up by a instance of an
ArrayList. The proxy ensures in this example,
that the instance cannot just be casted to access the specific methods
of the ArrayList like ArrayList.ensureCapacity(int).
Compare with the JDK's reflection API, there is not a real difference.