|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.objectweb.jac.core.Wrapper
|
+--org.objectweb.jac.wrappers.LimiterWrapper
LimiterWrapper implements a wrapper that tests a
counter value before calling the wrappee object. If the counter is
not with the max and min limits, it raises the
LimiterException
Use this wrapper as follows:
LimiterWrapper lw = new LimiterWrapper(0, 100); a_stack.wrap(lw, "inc", "push"); a_stack.wrap(lw, "dec", "pop"); a_stack.wrap(lw, "testMax", "push"); a_stack.wrap(lw, "testMin", "pop");
Where a_stack is an instance of a class
Stack. When wrapping the stack, it will raise a
LimiterException if a push is done and that the
counter is greater or equal to 100 or if a pop is done and that the
counter is lower or equal to 0.
NOTE: this class cannot be used alone. Its instances must wrap some instances of other objects (possibly other wrappers).
Wrappee,
Wrapping.wrap(Wrappee,Wrapper,AbstractMethodItem),
LimiterException,
Serialized Form| Field Summary | |
protected int |
counter
Store the counter of the limiter. |
protected int |
max
Store the maximum bound of the limiter. |
protected int |
min
Store the minimum bound of the limiter. |
| Fields inherited from class org.objectweb.jac.core.Wrapper |
ac, cr |
| Constructor Summary | |
LimiterWrapper(AspectComponent ac,
int min,
int max)
Construct a new limiter and initialize the bounds. |
|
| Method Summary | |
Object |
construct(ConstructorInvocation invocation)
|
Object |
dec(Interaction interaction)
This wrapping method decrements the limiter counter and calls the wrappee method. |
int |
getCounter()
Return the current counter of the limiter. |
int |
getMax()
Return the max bound of the limiter. |
Object |
inc(Interaction interaction)
This wrapping method increments the limiter counter and calls the wrappee method. |
Object |
invoke(MethodInvocation invocation)
|
void |
setMax(int max)
Set the max bound of the limiter. |
Object |
testMax(Interaction interaction)
This wrapping method tests the counter of the limiter and raises the LimiterExeption when when it is over
the maximum value.
|
Object |
testMin(Interaction interaction)
This wrapping method tests the counter of the limiter and raises the LimiterExeption when when it is below
the minimum 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 |
| Field Detail |
protected int max
protected int min
protected int counter
| Constructor Detail |
public LimiterWrapper(AspectComponent ac,
int min,
int max)
min - the minimum counter value.max - the maximum counter value.| Method Detail |
public int getMax()
public void setMax(int max)
max - the new max boundpublic int getCounter()
public Object inc(Interaction interaction)
For instance, inc could wrap the
push method of a stack so that the counter is
incremented when a new element is placed on the top of the
stack.
NOTE: this method do not test the bounds. Use
testMax to do this.
testMax(Interaction)public Object dec(Interaction interaction)
For instance, dec could wrap the
pop method of a stack so that the counter is
incremented when an element is removed from it.
NOTE: this method do not test the bounds. Use
testMin to do this.
testMin(Interaction)
public Object testMax(Interaction interaction)
throws LimiterException
LimiterExeption when when it is over
the maximum value.
NOTE: this method must be used with the inc and
dec wrapping methods that mofify the counter
value.
LimiterExceptioninc(Interaction),
dec(Interaction)
public Object testMin(Interaction interaction)
throws LimiterException
LimiterExeption when when it is below
the minimum value.
NOTE: this method must be used with the inc and
dec wrapping methods that mofify the counter
value.
LimiterExceptioninc(Interaction),
dec(Interaction)
public Object invoke(MethodInvocation invocation)
throws Throwable
invoke in interface MethodInterceptorinvoke in class WrapperThrowable
public Object construct(ConstructorInvocation invocation)
throws Throwable
construct in interface ConstructorInterceptorconstruct in class WrapperThrowable
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||