Package com.thoughtworks.proxy.factory

Different implementations of the ProxyFactory interface.

See:
          Description

Interface Summary
InvokerReference Interface to access the Invoker of the proxy.
 

Class Summary
CglibProxyFactory A ProxyFactory based on CGLIB.
StandardProxyFactory A ProxyFactory based on a JDK.
 

Package com.thoughtworks.proxy.factory Description

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.



Copyright © 2005-2010 Codehaus. All Rights Reserved.