Class InvocationCounter


  • public class InvocationCounter
    extends Object
    Utility class that counts the number of invocations on one or more objects. It also counts the number of exceptions thrown by these invocations. The class uses dynamic proxies to implement this feature.

    This class is thread safe.

    • Constructor Detail

      • InvocationCounter

        public InvocationCounter()
    • Method Detail

      • createProxy

        public Object createProxy​(Object target)
        Create a new proxy. Every invocation of a method on this proxy increases the invocation count by one unit. If the invocation results in an exception, then the exception counter is also incremented. The returned proxy implements all interfaces of the target instance.
        Parameters:
        target - the target instance
        Returns:
        the proxy instance
      • getInvocationCount

        public int getInvocationCount()
        Get the number of invocations counted by this instance.
        Returns:
        the number of invocations
      • getExceptionCount

        public int getExceptionCount()
        Get the number of exceptions counted by this instance.
        Returns:
        the number of exceptions
      • reset

        public void reset()
        Reset all counters to zero.