use of com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation in project LinkAgent by shulieTech.
the class ScopedResultInterceptor method getResult.
@Override
public Object getResult(Advice advice) throws Throwable {
final InterceptorScopeInvocation transaction = getScope(advice).getCurrentInvocation();
Object result = advice.getReturnObj();
try {
final boolean success = transaction.tryEnter(policy);
if (success) {
return interceptor.getResult(advice);
} else {
if (logger.isDebugEnabled()) {
logger.debug("tryAfter() returns false: interceptorScopeTransaction: {}, executionPoint: {}. Skip interceptor {}", transaction, policy, interceptor.getClass());
}
}
} finally {
if (transaction.canLeave(policy)) {
transaction.leave(policy);
}
}
return result;
}
use of com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation in project LinkAgent by shulieTech.
the class ScopedAroundInterceptor method doAfter.
@Override
public void doAfter(Advice advice) throws Throwable {
final InterceptorScope scope = getScope(advice);
final InterceptorScopeInvocation transaction = scope.getCurrentInvocation();
boolean success = transaction.canLeave(policy);
try {
if (success) {
interceptor.doAfter(advice);
} else {
if (logger.isDebugEnabled()) {
logger.debug("tryAfter() returns false: interceptorScopeTransaction: {}, executionPoint: {}. Skip interceptor {}", transaction, policy, interceptor.getClass());
}
}
} finally {
if (success) {
transaction.leave(policy);
}
}
}
use of com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation in project LinkAgent by shulieTech.
the class ScopedAroundInterceptor method doException.
@Override
public void doException(Advice advice) throws Throwable {
final InterceptorScopeInvocation transaction = getScope(advice).getCurrentInvocation();
boolean success = transaction.canLeave(policy);
try {
if (success) {
interceptor.doException(advice);
} else {
if (logger.isDebugEnabled()) {
logger.debug("doException() returns false: interceptorScopeTransaction: {}, executionPoint: {}. Skip interceptor {}", transaction, policy, interceptor.getClass());
}
}
} finally {
if (success) {
transaction.leave(policy);
}
}
}
use of com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation in project LinkAgent by shulieTech.
the class ScopedAroundInterceptor method doBefore.
@Override
public void doBefore(Advice advice) throws Throwable {
final InterceptorScope scope = getScope(advice);
final InterceptorScopeInvocation transaction = scope.getCurrentInvocation();
final boolean success = transaction.tryEnter(policy);
if (success) {
interceptor.doBefore(advice);
} else {
if (logger.isDebugEnabled()) {
logger.debug("tryBefore() returns false: interceptorScopeTransaction: {}, executionPoint: {}. Skip interceptor {}", transaction, policy, interceptor.getClass());
}
}
}
use of com.shulie.instrument.simulator.api.scope.InterceptorScopeInvocation in project LinkAgent by shulieTech.
the class ScopedCutoffInterceptor method cutoff.
@Override
public CutOffResult cutoff(Advice advice) throws Throwable {
final InterceptorScopeInvocation transaction = getScope(advice).getCurrentInvocation();
CutOffResult result = CutOffResult.passed();
try {
final boolean success = transaction.tryEnter(policy);
if (success) {
return interceptor.cutoff(advice);
} else {
if (logger.isDebugEnabled()) {
logger.debug("tryBefore() returns false: interceptorScopeTransaction: {}, executionPoint: {}. Skip interceptor {}", transaction, policy, interceptor.getClass());
}
}
} finally {
if (transaction.canLeave(policy)) {
transaction.leave(policy);
}
}
return result;
}
Aggregations