use of org.aspectj.lang.Signature in project sakuli by ConSol.
the class ModifySahiTimerAspectTest method testDetermineDelay.
@Test
public void testDetermineDelay() throws Exception {
BaseActionLoader loader = BeanLoader.loadBaseActionLoader();
when(loader.getSahiProxyProperties().getRequestDelayMs()).thenReturn(500);
loader.getActionProperties().setTypeDelay(0.05);
JoinPoint joinPoint = mock(JoinPoint.class);
Signature signature = mock(Signature.class);
when(joinPoint.getSignature()).thenReturn(signature);
when(signature.getName()).thenReturn("pasteSomething");
assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 500);
when(signature.getName()).thenReturn("typeMasked");
when(joinPoint.getArgs()).thenReturn(new String[] { "1", "MOD" });
assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 550);
when(joinPoint.getArgs()).thenReturn(new String[] { "12characters", "MOD" });
assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 12 * 550);
}
use of org.aspectj.lang.Signature in project dq-easy-cloud by dq-open-cloud.
the class EcBaseAspectBO method buildBaseAspectData.
protected void buildBaseAspectData(final ProceedingJoinPoint pjp) {
this.joinPoint = pjp;
Signature signature = this.joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
this.targetMethod = methodSignature.getMethod();
Class<?> targetClass = this.joinPoint.getTarget().getClass();
this.buildTargetClass(targetClass).buildTargetMethod(targetMethod);
this.buildTargetClassName(targetClass.getName()).buildTargetMethodName(targetMethod.getName());
this.buildTargetParameterTypes(targetMethod.getParameterTypes());
this.buildTargetParameterValues(this.joinPoint.getArgs());
this.buildTargetReturnType(targetMethod.getReturnType()).buildTargetClass(targetClass);
}
use of org.aspectj.lang.Signature in project dq-easy-cloud by dq-open-cloud.
the class EcLockBO method buidDistributedLockDTOData.
public EcLockBO buidDistributedLockDTOData() {
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
targetMethod = methodSignature.getMethod();
Object[] args = joinPoint.getArgs();
// 构建注解
this.buildEcDistributedLock();
this.buildLockName(args);
this.buildLockTemplate();
this.buildDistributedLockResultProcessor();
return this;
}
use of org.aspectj.lang.Signature in project knox by apache.
the class KnoxShellTableHistoryAspect method saveKnoxShellTableCall.
private void saveKnoxShellTableCall(JoinPoint joinPoint, long builderId) {
final Signature signature = joinPoint.getSignature();
final boolean builderMethod = KNOX_SHELL_TYPE.equals(((MethodSignature) signature).getReturnType().getCanonicalName());
final Map<Object, Class<?>> params = new HashMap<>();
Arrays.stream(joinPoint.getArgs()).forEach(param -> params.put(param, param.getClass()));
KnoxShellTableCallHistory.getInstance().saveCall(builderId, new KnoxShellTableCall(signature.getDeclaringTypeName(), signature.getName(), builderMethod, params));
}
use of org.aspectj.lang.Signature in project iobserve-analysis by research-iobserve.
the class AbstractOperationExecutionWithParameterAspect method staticOperation.
@Around("monitoredOperation() && !this(java.lang.Object) && notWithinKieker()")
public Object staticOperation(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
// (Throwable)
if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isMonitoringEnabled()) {
return thisJoinPoint.proceed();
}
final Signature sig = thisJoinPoint.getSignature();
final String operationSignature = this.signatureToLongString(sig);
if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isProbeActivated(operationSignature)) {
return thisJoinPoint.proceed();
}
// common fields
TraceMetadata trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.getTrace();
final boolean newTrace = trace == null;
if (newTrace) {
trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.registerTrace();
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(trace);
}
final long traceId = trace.getTraceId();
final String clazz = sig.getDeclaringTypeName();
// measure before execution
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new BeforeOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz));
// execution of the called method
final Object retval;
try {
retval = thisJoinPoint.proceed();
} catch (final Throwable th) {
// NOPMD NOCS (catch throw might ok here)
// measure after failed execution
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString()));
throw th;
} finally {
if (newTrace) {
// close the trace
AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.unregisterTrace();
}
}
// measure after successful execution
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new AfterOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz));
return retval;
}
Aggregations