I believe it can be interesting for both lists
----- Original Message -----
From: "Juozas Baliuka" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 24, 2002 6:33 PM
Subject: [SUBMIT]simple utility to genarate proxy


> This code is forked from some persistence framework in jakarta-commons,
> It can be more meanngful to have it in BCEL project. It can be useful for
> persistence like EJB CMP, Didtributed object proxy, Tracing, Validating,
> Bean generating.........
> The same idea as java.reflect.Proxy, but can extend existing class.
>
> Usage :
>
>
>   // TODO: Paste it to some test
>
>      public void testEnhance()throws Throwable{
>
>        // IMPLEMENT INTERCEPTOR
>         MethodInterceptor interceptor =
>          new MethodInterceptor(){
>
>             public Object beforeInvoke( Object
obj,java.lang.reflect.Method
> method,
>             Object args[] )
>             throws java.lang.Throwable{
>                 System.out.println( "about to invoke "  + method);
>                 return null;
>             }
>
>             public boolean invokeSuper( Object
obj,java.lang.reflect.Method
> method,
>             Object args[], Object retValFromBefore )
>             throws java.lang.Throwable{
>                 return true;
>             }
>
>
>         public Object afterReturn(  Object obj,
java.lang.reflect.Method
> method,
>         Object args[],  Object retValFromBefore,
>         boolean invokedSuper, Object retValFromSuper,
>         java.lang.Throwable e )throws java.lang.Throwable{
>
>             System.out.println( "returned "  + retValFromSuper);
>
>             return retValFromSuper;//return the same as supper
>         }
>
>     };
>
>     //EXTEND VECTOR
>
>       java.util.Vector vector =
>          (java.util.Vector)Enhancer.enhance(
>          java.util.Vector.class,
>          new Class[]{java.util.List.class}, // implement some interfaces
>          interceptor,
>          java.util.Vector.class.getClassLoader()
>         );
>
>
>  //Call some methods :
>
>     String value = "VALUE";
>     vector.add(null);
>
>     vector.elements();
>     vector.size();
>     vector.add(value);
>     vector.remove(value);
>     vector.remove(value);
>     vector.contains(value);
>     vector.get(0);
>     vector.contains(value);
>     vector.toArray(new Object[]{});
>
> }
>
> Output :
>
>
>  about to invoke public synchronized boolean
> java.util.Vector.add(java.lang.Object)
> returned true
> about to invoke public java.util.Enumeration java.util.Vector.elements()
> returned java.util.Vector$1@2a3722
> about to invoke public synchronized int java.util.Vector.size()
> returned 1
> about to invoke public synchronized boolean
> java.util.Vector.add(java.lang.Object)
> returned true
> about to invoke public boolean java.util.Vector.remove(java.lang.Object)
> about to invoke public synchronized boolean
> java.util.Vector.removeElement(java.lang.Object)
> about to invoke public int java.util.Vector.indexOf(java.lang.Object)
> about to invoke public synchronized int
> java.util.Vector.indexOf(java.lang.Object,int)
> returned 1
> returned 1
> about to invoke public synchronized void
> java.util.Vector.removeElementAt(int)
> returned null
> returned true
> returned true
> about to invoke public boolean java.util.Vector.remove(java.lang.Object)
> about to invoke public synchronized boolean
> java.util.Vector.removeElement(java.lang.Object)
> about to invoke public int java.util.Vector.indexOf(java.lang.Object)
> about to invoke public synchronized int
> java.util.Vector.indexOf(java.lang.Object,int)
> returned -1
> returned -1
> returned false
> returned false
> about to invoke public boolean java.util.Vector.contains(java.lang.Object)
> about to invoke public synchronized int
> java.util.Vector.indexOf(java.lang.Object,int)
> returned -1
> returned false
> about to invoke public synchronized java.lang.Object
> java.util.Vector.get(int)
> returned null
> about to invoke public boolean java.util.Vector.contains(java.lang.Object)
> about to invoke public synchronized int
> java.util.Vector.indexOf(java.lang.Object,int)
> returned -1
> returned false
> about to invoke public synchronized java.lang.Object[]
> java.util.Vector.toArray(java.lang.Object[])
> returned [Ljava.lang.Object;@c88440
>
>
>
>
>
>
>
>
>
>
>


----------------------------------------------------------------------------
----


> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Attachment: MethodInterceptor.java
Description: Binary data

Attachment: ConstructionHandler.java
Description: Binary data

Attachment: Enhancer.java
Description: Binary data

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to