Different implementations of the ProxyFactory interface.

Currently are two implementations supported. One based on the {@linkplain java.lang.reflect JDK's reflection API} and the other one on the CGLIB library.

The usage of a special {@linkplain com.thoughtworks.proxy.ProxyFactory} is simple and easy:

ProxyFactory factory = new StandardProxyFactory();
List proxy = (List)factory.createProxy(new Class[]{List.class}, new SimpleInvoker(new ArrayList()));
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 {@linkplain java.util.List} interface. The proxy is backed up by a instance of an {@linkplain java.util.ArrayList}. The proxy ensures in this example, that the instance cannot just be casted to access the specific methods of the ArrayList like {@link java.util.ArrayList#ensureCapacity(int)}. Compare with the JDK's reflection API, there is not a real difference.