JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.aspects.tracing
Class OptimizedCountingWrapper

java.lang.Object
  |
  +--org.objectweb.jac.core.Wrapper
        |
        +--org.objectweb.jac.aspects.tracing.SimpleCountingWrapper
              |
              +--org.objectweb.jac.aspects.tracing.OptimizedCountingWrapper
All Implemented Interfaces:
Serializable

public class OptimizedCountingWrapper
extends SimpleCountingWrapper

This counter must wrap the methods of which calls have to be counted. It extends the simple counting wrapper to provide 2 optimization methods when client methods call several times the method wrapped by incr. In these cases, the counter is direcly incremented by the number of times the incr method has to be called.

In order to avoid redundancy, incr must not be called if incrWithArg or incrWithField have already been called. To perform this contextual test, use the before and after running wrapper methods of the aspect component.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.objectweb.jac.core.Wrapper
ac
 
Constructor Summary
OptimizedCountingWrapper(AspectComponent ac, Counter c, int arg)
          Create the counter and parametrize it regarding the base program shape.
OptimizedCountingWrapper(AspectComponent ac, Counter c, String field)
          Create the counter and parametrize it regarding the base program shape.
 
Method Summary
 Object incrWithArg(Interaction interaction)
          This wrapping method increments the counter with the argument value when the wrapped method is called.
 Object incrWithField(Interaction interaction)
          This wrapping method increments the counter with the field when the wrapped method is called.
 
Methods inherited from class org.objectweb.jac.aspects.tracing.SimpleCountingWrapper
getCounter, incr, printCounter, setCounter
 
Methods inherited from class org.objectweb.jac.core.Wrapper
attr, attrdef, defines, getAspectComponent, getAspectComponentName, getExceptionHandlers, proceed, setAspectComponent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OptimizedCountingWrapper

public OptimizedCountingWrapper(AspectComponent ac,
                                Counter c,
                                String field)
Create the counter and parametrize it regarding the base program shape.

Parameters:
c - the used counter
field - the field that is used to optimize the counting

OptimizedCountingWrapper

public OptimizedCountingWrapper(AspectComponent ac,
                                Counter c,
                                int arg)
Create the counter and parametrize it regarding the base program shape.

Parameters:
c - the used counter
arg - the argument number that used to optimize the counting
Method Detail

incrWithField

public Object incrWithField(Interaction interaction)
This wrapping method increments the counter with the field when the wrapped method is called. It is an optimization for the incr method.

Returns:
the return value of the wrapped method
See Also:
SimpleCountingWrapper.incr(Interaction)

incrWithArg

public Object incrWithArg(Interaction interaction)
This wrapping method increments the counter with the argument value when the wrapped method is called. It is an optimization for the incr method.

Returns:
the return value of the wrapped method
See Also:
SimpleCountingWrapper.incr(Interaction)

Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli