org.equilibriums.aop.utils.interceptor.stub
Class StubWithReturnValueInterceptor
java.lang.Object
org.equilibriums.aop.utils.interceptor.stub.StubWithReturnValueInterceptor
- All Implemented Interfaces:
- org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
public class StubWithReturnValueInterceptor
- extends Object
- implements org.aopalliance.intercept.MethodInterceptor
Will intercept a method call and follow rules defined below without calling
target method (wont call invocation.proceed() ).
-
1. Given method "void method1(...)", will do nothing no matter what
returnValue is set to.
-
2. Given method "String method2(...)" and returnValue is set to
"Hello World", will return "Hellow World" no matter what checkReturnValueType
is set to.
-
3. Given method "String method3(...)" and returnValue is set to "new Object",
will throw IllegalStateException if checkReturnValueType is true otherwise
will return "new Object".
-
4. Given method "Object method4(...)" and returnValue is set to
"Hello World", will return "Hellow World" no matter what checkReturnValueType
is set to.
For more on how to use this interceptor see Overview section of this Javadoc.
- Author:
- Tsolak Petrosian
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StubWithReturnValueInterceptor
public StubWithReturnValueInterceptor()
getReturnValue
public Object getReturnValue()
setReturnValue
public void setReturnValue(Object returnValue)
isCheckReturnValueType
public boolean isCheckReturnValueType()
setCheckReturnValueType
public void setCheckReturnValueType(boolean checkReturnValueType)
invoke
public Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
throws Throwable
- Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
- Throws:
Throwable
Copyright © 2011. All Rights Reserved.