org.milyn.reflect
Class MethodInvocationProxyHandler<T>

java.lang.Object
  extended by org.milyn.reflect.MethodInvocationProxyHandler<T>
All Implemented Interfaces:
InvocationHandler

public class MethodInvocationProxyHandler<T>
extends Object
implements InvocationHandler

Utility class for capturing method invocation statistics.

Useful for testing.

Note: Be careful how you use this class. It doesn't filter out recursive/internal method calls i.e. you could eat memory with this class if not careful. Ideally, it should only log external Object invocations.

Author:
tom.fennelly@gmail.com

Constructor Summary
MethodInvocationProxyHandler(T object)
           
 
Method Summary
 List<MethodCall> getCallList()
          Get the complete method call list.
 List<MethodCall> getCallList(String methodName)
          Get the call list for a specific method.
 Map<String,List<MethodCall>> getCallMap()
          Get the call map.
 T getObject()
           
 Object invoke(Object proxy, Method method, Object[] args)
           
 T newProxy(Class[] interfaces)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodInvocationProxyHandler

public MethodInvocationProxyHandler(T object)
Method Detail

getObject

public T getObject()

newProxy

public T newProxy(Class[] interfaces)

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

getCallList

public List<MethodCall> getCallList()
Get the complete method call list.

This is the list of method calls, ordered by the order in which the calls were made.

Returns:
Call list.

getCallList

public List<MethodCall> getCallList(String methodName)
Get the call list for a specific method.

Overloaded method calls are bundled together.

Parameters:
methodName - The method name.
Returns:
Call list.

getCallMap

public Map<String,List<MethodCall>> getCallMap()
Get the call map.

This is the call list sorted by method name. Overloaded method calls are bundled together.

Returns:
The call map.


Copyright © 2018. All rights reserved.