Example usage for org.aspectj.lang JoinPoint METHOD_CALL

List of usage examples for org.aspectj.lang JoinPoint METHOD_CALL

Introduction

In this page you can find the example usage for org.aspectj.lang JoinPoint METHOD_CALL.

Prototype

String METHOD_CALL

To view the source code for org.aspectj.lang JoinPoint METHOD_CALL.

Click Source Link

Usage

From source file:org.cooperari.core.aspectj.AgentFacade.java

License:Apache License

/**
 * Handle weaver agent message.// w w  w .j av a2  s. co m
 * 
 * @param msg Message object.
 */
void handleMessage(IMessage msg) {

    if (CWorkspace.INSTANCE.isInitialized()) {
        if (_agentLog == null) {
            try {
                _agentLog = CWorkspace.INSTANCE.createLog(".", LOG_ID, CLog.Option.OMMIT_THREAD_INFO);
            } catch (Throwable e) {
                _agentLog = CLog.SYSTEM_OUT;
            }
        }
        _agentLog.message(msg.toString());
    }

    if (msg.getKind() == IMessage.WEAVEINFO) {
        try {
            Matcher matcher = WI_MSG_PATTERN.matcher(msg.getMessage());
            if (matcher.find()) {
                String kind = matcher.group(1);
                String desc = matcher.group(2);
                String signature;
                if (kind.equals(JoinPoint.SYNCHRONIZATION_LOCK)) {
                    signature = CYieldPoint.MONITOR_ENTER_SIGNATURE;
                } else if (kind.equals(JoinPoint.SYNCHRONIZATION_UNLOCK)) {
                    signature = CYieldPoint.MONITOR_EXIT_SIGNATURE;
                } else if (kind.equals(JoinPoint.METHOD_CALL)) {
                    signature = uniformize(desc);
                } else {
                    signature = kind + "(" + uniformize(desc) + ")";
                }
                if (_ignoreSet.contains(signature)) {
                    return;
                }
                String fileInfo = matcher.group(3);
                int lineInfo = Integer.parseInt(matcher.group(4));
                CYieldPointImpl yp = new CYieldPointImpl(signature, fileInfo, lineInfo);
                synchronized (this) {
                    _globalCoverageLog.recordDefinition(yp);
                }
            }
        } catch (Throwable e) {
            handleError(e);
        }
    }
    // else {
    //
    // }
}

From source file:org.cooperari.core.CYieldPointImpl.java

License:Apache License

@SuppressWarnings("javadoc")
private static String deriveSignature(JoinPoint.StaticPart jpsp) {
    String kind = jpsp.getKind(); // note that String is internalized
    if (kind == JoinPoint.SYNCHRONIZATION_LOCK) {
        return MONITOR_ENTER_SIGNATURE;
    }//from  ww  w  .j a  v a2  s . c  o  m
    if (kind == JoinPoint.SYNCHRONIZATION_UNLOCK) {
        return MONITOR_EXIT_SIGNATURE;
    }
    String s = jpsp.getSignature().toString();
    s = s.substring(s.indexOf(' ') + 1);
    s = s.replace("java.lang.", "").replace('$', '.');
    if (kind == JoinPoint.METHOD_CALL) {
        return s;
    }
    return kind + '(' + s + ')';
}