Search in sources :

Example 11 with Signature

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);
}
Also used : Signature(org.aspectj.lang.Signature) BaseActionLoader(org.sakuli.loader.BaseActionLoader) JoinPoint(org.aspectj.lang.JoinPoint) Test(org.testng.annotations.Test)

Example 12 with Signature

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);
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Signature(org.aspectj.lang.Signature) MethodSignature(org.aspectj.lang.reflect.MethodSignature)

Example 13 with Signature

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;
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) Signature(org.aspectj.lang.Signature) MethodSignature(org.aspectj.lang.reflect.MethodSignature)

Example 14 with Signature

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));
}
Also used : MethodSignature(org.aspectj.lang.reflect.MethodSignature) HashMap(java.util.HashMap) Signature(org.aspectj.lang.Signature) MethodSignature(org.aspectj.lang.reflect.MethodSignature)

Example 15 with Signature

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;
}
Also used : AfterOperationFailedEvent(kieker.common.record.flow.trace.operation.AfterOperationFailedEvent) AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent) Signature(org.aspectj.lang.Signature) MethodSignature(org.aspectj.lang.reflect.MethodSignature) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata) EntryLevelBeforeOperationEvent(org.iobserve.common.record.EntryLevelBeforeOperationEvent) BeforeOperationEvent(kieker.common.record.flow.trace.operation.BeforeOperationEvent) Around(org.aspectj.lang.annotation.Around)

Aggregations

Signature (org.aspectj.lang.Signature)28 MethodSignature (org.aspectj.lang.reflect.MethodSignature)17 Method (java.lang.reflect.Method)12 Around (org.aspectj.lang.annotation.Around)6 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)4 JoinPoint (org.aspectj.lang.JoinPoint)3 CodeSignature (org.aspectj.lang.reflect.CodeSignature)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Test (org.testng.annotations.Test)2 DataSource (com.ikoori.vip.common.annotion.DataSource)1 BussinessLog (com.ikoori.vip.common.annotion.log.BussinessLog)1 AbstractDictMap (com.ikoori.vip.common.constant.dictmap.base.AbstractDictMap)1 ShiroUser (com.ikoori.vip.server.core.shiro.ShiroUser)1 RequestLockable (com.jim.framework.annotationlock.annotation.RequestLockable)1 DynamicDataSource (com.junliang.spring.config.DynamicDataSource)1 User (gemma.gsec.model.User)1 AnnotationFormatError (java.lang.annotation.AnnotationFormatError)1 Executable (java.lang.reflect.Executable)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1