org.objectweb.jac.aspects.tracing
Class SimpleCountingWrapper

java.lang.Object
  extended byorg.objectweb.jac.core.Wrapper
      extended byorg.objectweb.jac.aspects.tracing.SimpleCountingWrapper
All Implemented Interfaces:
Advice, ConstructorInterceptor, Interceptor, MethodInterceptor, Serializable
Direct Known Subclasses:
OptimizedCountingWrapper

public class SimpleCountingWrapper
extends Wrapper

This simple counter must wrap the methods of which calls have to be counted.

In some cases, optimizations can be achieved by grouping counts. See OptimizedCountingWrapper.

See Also:
OptimizedCountingWrapper, Serialized Form

Field Summary
 
Fields inherited from class org.objectweb.jac.core.Wrapper
ac, cr
 
Constructor Summary
SimpleCountingWrapper(AspectComponent ac, Counter counter)
          Creates a new wrapper that uses the given counter.
 
Method Summary
 Object construct(ConstructorInvocation invocation)
           
 int getCounter()
          Role method: get the counter value.
 Object incr(Interaction interaction)
          This wrapping method increments the counter when the wrapped method is called.
 Object invoke(MethodInvocation invocation)
           
 void printCounter()
          Prints the counter in System.out.
 void setCounter(int value)
          Role method: set the counter value.
 
Methods inherited from class org.objectweb.jac.core.Wrapper
attr, attrdef, defines, getAspectComponent, getAspectComponentName, getExceptionHandlers, proceed, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleCountingWrapper

public SimpleCountingWrapper(AspectComponent ac,
                             Counter counter)
Creates a new wrapper that uses the given counter.

Parameters:
counter - the counter
Method Detail

incr

public Object incr(Interaction interaction)
This wrapping method increments the counter when the wrapped method is called.

Returns:
the return value of the wrapped method

setCounter

public void setCounter(int value)
Role method: set the counter value.

Parameters:
value - the new counter value
See Also:
getCounter(), incr(Interaction)

getCounter

public int getCounter()
Role method: get the counter value.

Returns:
the counter value
See Also:
setCounter(int), incr(Interaction)

printCounter

public void printCounter()
Prints the counter in System.out.


invoke

public Object invoke(MethodInvocation invocation)
              throws Throwable
Specified by:
invoke in interface MethodInterceptor
Overrides:
invoke in class Wrapper
Throws:
Throwable

construct

public Object construct(ConstructorInvocation invocation)
                 throws Throwable
Specified by:
construct in interface ConstructorInterceptor
Overrides:
construct in class Wrapper
Throws:
Throwable