Example usage for org.aspectj.lang ProceedingJoinPoint getSignature

List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature

Introduction

In this page you can find the example usage for org.aspectj.lang ProceedingJoinPoint getSignature.

Prototype

Signature getSignature();

Source Link

Document

getStaticPart().getSignature() returns the same object

Usage

From source file:kieker.monitoring.probe.aspectj.flow.constructorCallObject.AbstractAspect.java

License:Apache License

/**
 * This is an advice used around calls from static elements to constructors.
 *
 * @param thisJoinPoint//  w w w. j a v  a  2s  .c o  m
 *            The joint point of the callee.
 * @param thisEnclosingJoinPoint
 *            The joint point of the caller.
 *
 * @return The result of {@code proceed method} of the given joint point.
 *
 * @throws Throwable
 */
@Around("monitoredConstructor() && !this(java.lang.Object) && target(targetObject) && notWithinKieker()")
public Object static2constructor(final Object targetObject, final ProceedingJoinPoint thisJoinPoint,
        final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }
    final Signature calleeSig = thisJoinPoint.getSignature();
    final String callee = this.signatureToLongString(calleeSig);
    if (!CTRLINST.isProbeActivated(callee)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    // caller
    final Signature callerSig = thisEnclosingJoinPoint.getSignature();
    final String caller = this.signatureToLongString(callerSig);
    final String callerClazz = callerSig.getDeclaringTypeName();
    // callee
    final String calleeClazz = calleeSig.getDeclaringTypeName();
    final int calleeObjectId = System.identityHashCode(targetObject);
    // measure before call
    CTRLINST.newMonitoringRecord(new CallConstructorObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(),
            caller, callerClazz, callee, calleeClazz, 0, calleeObjectId));
    // call of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.constructorExecution.AbstractAspect.java

License:Apache License

/**
 * The advice used around the constructor executions.
 *
 * @param thisObject// w  w w  .  j av  a2  s  .c o  m
 * @param thisJoinPoint
 *
 * @return The result of the joint point's {@code proceed} method.
 *
 * @throws Throwable
 */
@Around("monitoredConstructor() && this(thisObject) && notWithinKieker()")
public Object constructor(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable)
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }
    final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!CTRLINST.isProbeActivated(operationSignature)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    final String clazz = thisObject.getClass().getName();
    // measure before execution
    CTRLINST.newMonitoringRecord(new BeforeConstructorEvent(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
        CTRLINST.newMonitoringRecord(new AfterConstructorFailedEvent(TIME.getTime(), traceId,
                trace.getNextOrderId(), operationSignature, clazz, th.toString()));
        throw th;
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    // measure after successful execution
    CTRLINST.newMonitoringRecord(new AfterConstructorEvent(TIME.getTime(), traceId, trace.getNextOrderId(),
            operationSignature, clazz));
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.constructorExecutionObject.AbstractAspect.java

License:Apache License

/**
 * The advice used around the constructor executions.
 *
 * @param thisObject// www .  ja  v a  2  s.  co  m
 * @param thisJoinPoint
 *
 * @return The result of the joint point's {@code proceed} method.
 *
 * @throws Throwable
 */
@Around("monitoredConstructor() && this(thisObject) && notWithinKieker()")
public Object constructor(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable)
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }
    final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!CTRLINST.isProbeActivated(operationSignature)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    final String clazz = thisObject.getClass().getName();
    final int objectId = System.identityHashCode(thisObject);
    // measure before execution
    CTRLINST.newMonitoringRecord(new BeforeConstructorObjectEvent(TIME.getTime(), traceId,
            trace.getNextOrderId(), operationSignature, clazz, objectId));
    // 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
        CTRLINST.newMonitoringRecord(new AfterConstructorFailedObjectEvent(TIME.getTime(), traceId,
                trace.getNextOrderId(), operationSignature, clazz, th.toString(), objectId));
        throw th;
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    // measure after successful execution
    CTRLINST.newMonitoringRecord(new AfterConstructorObjectEvent(TIME.getTime(), traceId,
            trace.getNextOrderId(), operationSignature, clazz, objectId));
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.constructorExecutionObjectInterface.AbstractAspect.java

License:Apache License

/**
 * The advice used around the constructor executions.
 *
 * @param thisObject// w ww  .j  a  v a2s.  co  m
 * @param thisJoinPoint
 *
 * @return The result of the joint point's {@code proceed} method.
 *
 * @throws Throwable
 */
@Around("monitoredConstructor() && this(thisObject) && notWithinKieker()")
public Object constructor(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable { // NOCS (Throwable)
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }
    final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!CTRLINST.isProbeActivated(operationSignature)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    final String clazz = thisObject.getClass().getName();
    final int objectId = System.identityHashCode(thisObject);
    // measure before execution
    CTRLINST.newMonitoringRecord(
            new BeforeConstructorObjectInterfaceEvent(TIME.getTime(), traceId, trace.getNextOrderId(),
                    operationSignature, clazz, objectId, AbstractAspect.getInterface(thisJoinPoint)));
    // 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
        CTRLINST.newMonitoringRecord(new AfterConstructorFailedObjectEvent(TIME.getTime(), traceId,
                trace.getNextOrderId(), operationSignature, clazz, th.toString(), objectId));
        throw th;
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    // measure after successful execution
    CTRLINST.newMonitoringRecord(new AfterConstructorObjectEvent(TIME.getTime(), traceId,
            trace.getNextOrderId(), operationSignature, clazz, objectId));
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.constructorExecutionObjectInterface.AbstractAspect.java

License:Apache License

private static final String getInterface(final ProceedingJoinPoint thisJoinPoint) {
    final Class<?>[] interfaces = thisJoinPoint.getSignature().getDeclaringType().getInterfaces();
    final StringBuilder sb = new StringBuilder();

    sb.append('[');
    if (interfaces.length == 0) {
        final Class<?> superClass = thisJoinPoint.getSignature().getDeclaringType().getSuperclass();
        if (superClass != null) {
            final String superClassName = superClass.getName();
            if (!"java.lang.Object".equals(superClassName)) {
                sb.append(superClassName);
            }//  w  w w.jav a  2 s .c  o m
        }
    } else {
        for (int idx = 0; idx < interfaces.length; idx++) {
            sb.append(interfaces[idx].getName());
            if (idx < (interfaces.length - 1)) {
                sb.append(", ");
            }
        }
    }
    sb.append(']');

    return sb.toString();
}

From source file:kieker.monitoring.probe.aspectj.flow.operationCall.AbstractAspect.java

License:Apache License

@Around("monitoredOperation() && this(thisObject) && target(targetObject) && notWithinKieker()")
public Object member2memberOperation(final Object thisObject, final Object targetObject,
        final ProceedingJoinPoint thisJoinPoint, final EnclosingStaticPart thisEnclosingJoinPoint)
        throws Throwable { // NOCS
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }//from   w w w. j a  va2s . c  o m
    final String callee = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!CTRLINST.isProbeActivated(callee)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    // caller
    final String caller = this.signatureToLongString(thisEnclosingJoinPoint.getSignature());
    final String callerClazz = thisObject.getClass().getName();
    // callee
    final String calleeClazz = targetObject.getClass().getName();
    // measure before call
    CTRLINST.newMonitoringRecord(new CallOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller,
            callerClazz, callee, calleeClazz));
    // call of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.operationCall.AbstractAspect.java

License:Apache License

@Around("monitoredOperation() && !this(java.lang.Object) && target(targetObject) && notWithinKieker()")
public Object static2memberOperation(final Object targetObject, final ProceedingJoinPoint thisJoinPoint,
        final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }/*from  w  w w .j a  v a  2 s .  c om*/
    final String callee = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!CTRLINST.isProbeActivated(callee)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    // caller
    final Signature callerSig = thisEnclosingJoinPoint.getSignature();
    final String caller = this.signatureToLongString(callerSig);
    final String callerClazz = callerSig.getDeclaringTypeName();
    // callee

    final String calleeClazz = targetObject.getClass().getName();
    // measure before call
    CTRLINST.newMonitoringRecord(new CallOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller,
            callerClazz, callee, calleeClazz));
    // call of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.operationCall.AbstractAspect.java

License:Apache License

@Around("monitoredOperation() && this(thisObject) && !target(java.lang.Object) && notWithinKieker()")
public Object member2staticOperation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint,
        final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }//from   w w w  .  j  a  v  a  2 s.c  o m
    final Signature calleeSig = thisJoinPoint.getSignature();
    final String callee = this.signatureToLongString(calleeSig);
    if (!CTRLINST.isProbeActivated(callee)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    // caller
    final String caller = this.signatureToLongString(thisEnclosingJoinPoint.getSignature());
    final String callerClazz = thisObject.getClass().getName();
    // callee
    final String calleeClazz = calleeSig.getDeclaringTypeName();
    // measure before call
    CTRLINST.newMonitoringRecord(new CallOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller,
            callerClazz, callee, calleeClazz));
    // call of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.operationCall.AbstractAspect.java

License:Apache License

@Around("monitoredOperation() && !this(java.lang.Object) && !target(java.lang.Object) && notWithinKieker()")
public Object static2staticOperation(final ProceedingJoinPoint thisJoinPoint,
        final EnclosingStaticPart thisEnclosingJoinPoint) throws Throwable { // NOCS
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }//w  w w  .j  a  v a  2  s . com
    final Signature calleeSig = thisJoinPoint.getSignature();
    final String callee = this.signatureToLongString(calleeSig);
    if (!CTRLINST.isProbeActivated(callee)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    // caller
    final Signature callerSig = thisEnclosingJoinPoint.getSignature();
    final String caller = this.signatureToLongString(callerSig);
    final String callerClazz = callerSig.getDeclaringTypeName();
    // callee
    final String calleeClazz = calleeSig.getDeclaringTypeName();
    // measure before call
    CTRLINST.newMonitoringRecord(new CallOperationEvent(TIME.getTime(), traceId, trace.getNextOrderId(), caller,
            callerClazz, callee, calleeClazz));
    // call of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    return retval;
}

From source file:kieker.monitoring.probe.aspectj.flow.operationCallObject.AbstractAspect.java

License:Apache License

@Around("monitoredOperation() && this(thisObject) && target(targetObject) && notWithinKieker()")
public Object member2memberOperation(final Object thisObject, final Object targetObject,
        final ProceedingJoinPoint thisJoinPoint, final EnclosingStaticPart thisEnclosingJoinPoint)
        throws Throwable { // NOCS
    if (!CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }//from  www.j  a v a2s  .  co m
    final String callee = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!CTRLINST.isProbeActivated(callee)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = TRACEREGISTRY.registerTrace();
        CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    // caller
    final String caller = this.signatureToLongString(thisEnclosingJoinPoint.getSignature());
    final String callerClazz = thisObject.getClass().getName();
    final int callerObject = System.identityHashCode(thisObject);
    // callee
    final String calleeClazz = targetObject.getClass().getName();
    final int calleeObject = System.identityHashCode(targetObject);
    // measure before call
    CTRLINST.newMonitoringRecord(new CallOperationObjectEvent(TIME.getTime(), traceId, trace.getNextOrderId(),
            caller, callerClazz, callee, calleeClazz, callerObject, calleeObject));
    // call of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } finally {
        if (newTrace) { // close the trace
            TRACEREGISTRY.unregisterTrace();
        }
    }
    return retval;
}