org.mockejb.interceptor
Class InvocationRecorder

java.lang.Object
  extended byorg.mockejb.interceptor.InvocationRecorder
All Implemented Interfaces:
Interceptor

public class InvocationRecorder
extends java.lang.Object
implements Interceptor

Stores the information about all calls to the target object in the list. Clients can examine the list to see the parameters of the calls. Example of usage:

  InvocationRecorder recorder = new InvocationRecorder();
  aspectSystem.add( new ClassPointcut( SampleHelper.class, false), recorder);        
  InvocationContext dummyMethodInvocation = recorder.findByTargetMethod( "dummyMethod");
  assertNotNull(dummyMethodInvocation);
 

Author:
Alexander Ananiev

Constructor Summary
InvocationRecorder()
           
 
Method Summary
 void clear()
          Clears all currently stored invocations
 InvocationContext findByInterceptedMethod(java.lang.String methodPattern)
          Deprecated. Use findByProxyMethod instead
 InvocationContext findByProxyMethod(java.lang.String methodPattern)
          Finds the first invocation for a given proxy method pattern.
 InvocationContext findByTargetMethod(java.lang.String methodPattern)
          Finds the first invocation for a given target method pattern.
 java.util.List getMethodInvocationList()
          Returns the list of all invocations that happened since the recorder was added.
 boolean hasRecords()
          Returns true is it has at least one record
 void intercept(InvocationContext invocationContext)
          Performs pre and post invocation actions for the target object call.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InvocationRecorder

public InvocationRecorder()
Method Detail

intercept

public void intercept(InvocationContext invocationContext)
               throws java.lang.Exception
Description copied from interface: Interceptor
Performs pre and post invocation actions for the target object call.

Specified by:
intercept in interface Interceptor
Parameters:
invocationContext - provides the info about this call. Also calls interceptors in turn according to their order in the chain. invocationContext provides access to the return value and thrown exceptions of this call.
Throws:
java.lang.Exception

getMethodInvocationList

public java.util.List getMethodInvocationList()
Returns the list of all invocations that happened since the recorder was added.

Returns:
list of invocations

hasRecords

public boolean hasRecords()
Returns true is it has at least one record

Returns:
true if at least one recording was made

clear

public void clear()
Clears all currently stored invocations


findByTargetMethod

public InvocationContext findByTargetMethod(java.lang.String methodPattern)
Finds the first invocation for a given target method pattern.

Parameters:
methodPattern - regexp pattern to run against the string representation of a method
Returns:
invocation context or null if method not found

findByInterceptedMethod

public InvocationContext findByInterceptedMethod(java.lang.String methodPattern)
Deprecated. Use findByProxyMethod instead

Parameters:
methodPattern - regexp pattern to run against the string representation of a method
Returns:
invocation context or null if method not found

findByProxyMethod

public InvocationContext findByProxyMethod(java.lang.String methodPattern)
Finds the first invocation for a given proxy method pattern.

Parameters:
methodPattern - regexp pattern to run against the string representation of a method
Returns:
invocation context or null if method not found

toString

public java.lang.String toString()