org.apache.avalon.excalibur.proxy
Class DynamicProxy

java.lang.Object
  |
  +--org.apache.avalon.excalibur.proxy.DynamicProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public final class DynamicProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

This makes a dynamic proxy for an object. The object can be represented by one, some of all of it's interfaces. Amongst other things, it's an anti hackinge measure. Suitable armed code could have case an interface for a thing back to it's impl and used methods and properties that were not it's authors intention. Reflection too allows some powerful introspection things and some traversal even more things including private member vars by a serialisation trick... hence the transient.

Since:
4.0b5
Version:
CVS $Revision: 1.5 $ $Date: 2001/12/11 09:53:32 $
Author:
Peter Donald, Paul Hammant

Method Summary
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Invoke the specified method on underlying object.
static java.lang.Object newInstance(java.lang.Object object)
          Create a proxy object that has all of it's underlying interfaces implemented by proxy.
static java.lang.Object newInstance(java.lang.Object object, java.lang.Class[] interfaces)
          Create a proxy object that has specified interfaces implemented by proxy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newInstance

public static java.lang.Object newInstance(java.lang.Object object)
Create a proxy object that has all of it's underlying interfaces implemented by proxy.
Parameters:
object - the underling object to proxy
Returns:
the proxied object

newInstance

public static java.lang.Object newInstance(java.lang.Object object,
                                           java.lang.Class[] interfaces)
Create a proxy object that has specified interfaces implemented by proxy.
Parameters:
object - the underling object to proxy
Returns:
the proxied object

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Invoke the specified method on underlying object. This is called by proxy object.
Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Parameters:
proxy - the proxy object
method - the method invoked on proxy object
args - the arguments supplied to method
Returns:
the return value of method
Throws:
java.lang.Throwable - if an error occurs


Copyright © 2001 Apache Jakarta Project. All Rights Reserved.