Class ProxyUtil


  • public final class ProxyUtil
    extends java.lang.Object
    A collection of utility methods dealing with proxy objects
    Version:
    $Revision: 1.3 $
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ProxyUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object createProxy​(java.lang.Class clazz)
      Create a proxy object that implements the interface specified by 'clazz'.
      static java.lang.Object createProxy​(java.lang.Class clazz, java.lang.Object[][] args)
      Create a proxy object that implements the interface specified by 'clazz'.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProxyUtil

        private ProxyUtil()
    • Method Detail

      • createProxy

        public static java.lang.Object createProxy​(java.lang.Class clazz)
        Create a proxy object that implements the interface specified by 'clazz'. All methods invoked on this object will return null.
        Parameters:
        clazz - The interface that the proxy will support
        Returns:
        The new proxy object.
      • createProxy

        public static java.lang.Object createProxy​(java.lang.Class clazz,
                                                   java.lang.Object[][] args)
        Create a proxy object that implements the interface specified by 'clazz'. Any methods specified in args will return the given result, any methods not specified here will return null.
         final Object args[][] = {
             {"getAutoCommit", Boolean.TRUE},
             {"getCatalog", "foobar"}
         };
         final Connection connection = ProxyUtil.createProxy(Connection.class, args);
         
        Calling getAutoCommit() on this object will return true. Calling getCatalog() on this object will return "foobar". Calling any other method will return null.
        Parameters:
        clazz - The interface that will be supported by the generated proxy
        args - methodname/object pairs
        Returns:
        The new proxy object