org.apache.aries.unittest.mocks
Class DefaultInvocationHandler

java.lang.Object
  extended by org.apache.aries.unittest.mocks.DefaultInvocationHandler
All Implemented Interfaces:
InvocationHandler

public class DefaultInvocationHandler
extends Object
implements InvocationHandler

This invocation handler is used by the Skeleton when nothing else is matched. If the return type is an interface it creates a dynamic proxy backed by the associated skeleton for return, if it is a class with a default constructor that will be returned.


Constructor Summary
DefaultInvocationHandler(Skeleton s)
          Creates an instance called by the specified skeleton.
 
Method Summary
 Object createProxy(Class<?>... returnTypes)
          Creates and returns a proxy backed by the associated skeleton, that implements the specified interfaces.
 Object invoke(Object target, Method method, Object[] arguments)
          Invoked when no ReturnType or MethodCall Handlers are defined.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultInvocationHandler

public DefaultInvocationHandler(Skeleton s)
Creates an instance called by the specified skeleton.

Parameters:
s - The caller.
Method Detail

invoke

public Object invoke(Object target,
                     Method method,
                     Object[] arguments)
              throws Throwable
Invoked when no ReturnType or MethodCall Handlers are defined.

Specified by:
invoke in interface InvocationHandler
Parameters:
target - The target object that was invoked.
method - The method that was invoked.
arguments - The arguments that were passed.
Returns:
A proxy or null.
Throws:
Throwable

createProxy

public Object createProxy(Class<?>... returnTypes)
Creates and returns a proxy backed by the associated skeleton, that implements the specified interfaces. Null is returned if the return type array contains non interfaces.

Parameters:
returnTypes - The classes.
Returns:
The proxy or null.


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.