[jboss-cvs] javassist/src/main/javassist/util/proxy ...

Shigeru Chiba chiba at is.titech.ac.jp
Tue Nov 7 03:44:07 EST 2006


  User: chiba   
  Date: 06/11/07 03:44:07

  Modified:    src/main/javassist/util/proxy  ProxyFactory.java
  Log:
  updated a javadoc comment
  
  Revision  Changes    Path
  1.22      +40 -2     javassist/src/main/javassist/util/proxy/ProxyFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProxyFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/javassist/src/main/javassist/util/proxy/ProxyFactory.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -b -r1.21 -r1.22
  --- ProxyFactory.java	7 Nov 2006 04:19:37 -0000	1.21
  +++ ProxyFactory.java	7 Nov 2006 08:44:07 -0000	1.22
  @@ -58,7 +58,6 @@
    *         return proceed.invoke(self, args);  // execute the original method.
    *     }
    * };
  - * f.setHandler(mi);
    * f.setFilter(new MethodFilter() {
    *     public boolean isHandled(Method m) {
    *         // ignore finalize()
  @@ -67,6 +66,7 @@
    * });
    * Class c = f.createClass();
    * Foo foo = (Foo)c.newInstance();
  + * ((ProxyObject)foo).setHandler(mi);
    * </pre></ul>
    *
    * <p>Then, the following method call will be forwarded to MethodHandler
  @@ -77,6 +77,15 @@
    * foo.bar();
    * </pre></ul>
    *
  + * <p>The last three lines of the code shown above can be replaced with a call to
  + * the helper method <code>create</code>, which generates a proxy class, instantiates
  + * it, and sets the method handler of the instance:
  + *
  + * <ul><pre>
  + *     :
  + * Foo foo = (Foo)f.create(new Class[0], new Object[0], mi);
  + * </pre></ul>
  + *
    * <p>To change the method handler during runtime,
    * execute the following code:
    *
  @@ -85,7 +94,20 @@
    * ((ProxyObject)foo).setHandler(mi2);
    * </pre></ul>
    *
  - * <p>Here is an example of method handler.  It does not execute
  + * <p>You can also specify the default method handler:
  + *
  + * <ul><pre>
  + * ProxyFactory f2 = new ProxyFactory();
  + * f2.setSuperclass(Foo.class);
  + * f2.setHandler(mi);            // set the default handler
  + * Class c2 = f2.createClass();
  + * </pre></ul>
  + *
  + * <p>The default handler is implicitly attached to an instance of the generated class
  + * <code>c2</code>.   Calling <code>setHandler</code> on the instance is not necessary
  + * unless another method handler must be attached to the instance. 
  + *
  + * <p>The following code is an example of method handler.  It does not execute
    * anything except invoking the original method:
    *
    * <ul><pre>
  @@ -439,6 +461,22 @@
        *
        * @param paramTypes    parameter types for a constructor.
        * @param args          arguments passed to a constructor.
  +     * @param mh            the method handler for the proxy class.
  +     */
  +    public Object create(Class[] paramTypes, Object[] args, MethodHandler mh)
  +        throws NoSuchMethodException, IllegalArgumentException,
  +               InstantiationException, IllegalAccessException, InvocationTargetException
  +    {
  +        Object obj = create(paramTypes, args);
  +        ((ProxyObject)obj).setHandler(mh);
  +        return obj;
  +    }
  +
  +    /**
  +     * Creates a proxy class and returns an instance of that class.
  +     *
  +     * @param paramTypes    parameter types for a constructor.
  +     * @param args          arguments passed to a constructor.
        */
       public Object create(Class[] paramTypes, Object[] args)
           throws NoSuchMethodException, IllegalArgumentException,
  
  
  



More information about the jboss-cvs-commits mailing list