Example usage for org.aspectj.bridge IMessage ABORT

List of usage examples for org.aspectj.bridge IMessage ABORT

Introduction

In this page you can find the example usage for org.aspectj.bridge IMessage ABORT.

Prototype

Kind ABORT

To view the source code for org.aspectj.bridge IMessage ABORT.

Click Source Link

Usage

From source file:AjcCompiler.java

License:Open Source License

/**
 * Hook into the maven logger./*  w w w  .j a  v a  2 s .c  om*/
 */
public boolean handleMessage(IMessage message) {
    if (message.getKind().equals(IMessage.WARNING) && !isIgnoring(IMessage.WARNING))
        log.warning(message.getMessage());
    else if (message.getKind().equals(IMessage.DEBUG) && !isIgnoring(IMessage.DEBUG))
        log.fine(message.getMessage());
    else if (message.getKind().equals(IMessage.ERROR) && !isIgnoring(IMessage.ERROR))
        log.severe(message.getMessage());
    else if (message.getKind().equals(IMessage.ABORT) && !isIgnoring(IMessage.ABORT))
        log.severe(message.getMessage());
    else if (message.getKind().equals(IMessage.FAIL) && !isIgnoring(IMessage.FAIL))
        log.severe(message.getMessage());
    else if (message.getKind().equals(IMessage.INFO) && !isIgnoring(IMessage.INFO))
        log.fine(message.getMessage());
    else if (message.getKind().equals(IMessage.WEAVEINFO) && !isIgnoring(IMessage.WEAVEINFO))
        log.info(message.getMessage());
    else if (message.getKind().equals(IMessage.TASKTAG) && !isIgnoring(IMessage.TASKTAG))
        log.fine(message.getMessage());
    return super.handleMessage(message);
}

From source file:de.zalando.mojo.aspectj.MavenMessageHandler.java

License:Open Source License

/**
 * Copies output from the supplied message onto the active Maven Log.
 * If the message type (i.e. {@code message.getKind()}) is listed in the showDetailsForMessageKindList List,
 * the message is prefixed with location details (Class, row/line number etc.) as well.
 * <p/>//from   w  w w .  j  a  v  a2  s  .  c  o  m
 * {@inheritDoc}
 */
public boolean handleMessage(final IMessage message) {

    // Compose the message text
    final StringBuilder builder = new StringBuilder(message.getMessage());
    if (isMessageDetailDesired(message)) {

        //
        // The AJC details are typically delivered on the format [fileName]:[lineNumber]
        // (i.e. /src/main/java/Clazz.java:16).
        //
        // Mimic this, and include the context of the message as well,
        // including guarding against NPEs.
        //
        final ISourceLocation sourceLocation = message.getSourceLocation();
        final String sourceFile = sourceLocation == null || sourceLocation.getSourceFile() == null
                ? "<unknown source file>"
                : sourceLocation.getSourceFile().getAbsolutePath();
        final String context = sourceLocation == null || sourceLocation.getContext() == null ? ""
                : sourceLocation.getContext() + "\n";
        final String line = sourceLocation == null ? "<no line information>" : "" + sourceLocation.getLine();

        builder.append("\n\t").append(sourceFile).append(":").append(line).append("\n").append(context);
    }

    final String messageText = builder.toString();

    if (isNotIgnored(message, IMessage.DEBUG) || isNotIgnored(message, IMessage.INFO)
            || isNotIgnored(message, IMessage.TASKTAG)) {

        // The DEBUG, INFO, and TASKTAG ajc message kinds are considered Maven Debug messages.
        log.debug(messageText);

    } else if (isNotIgnored(message, IMessage.WEAVEINFO)) {

        // The WEAVEINFO ajc message kind is considered Maven Info messages.
        log.info(messageText);

    } else if (isNotIgnored(message, IMessage.WARNING)) {

        // The WARNING ajc message kind is considered Maven Warn messages.
        log.warn(messageText);

    } else if (isNotIgnored(message, IMessage.ERROR) || isNotIgnored(message, IMessage.ABORT)
            || isNotIgnored(message, IMessage.FAIL)) {

        // We map ERROR, ABORT, and FAIL ajc message kinds to Maven Error messages.
        log.error(messageText);
    }

    // Delegate to normal handling.
    return super.handleMessage(message);
}

From source file:org.eclipse.ajdt.internal.core.ajde.CoreBuildMessageHandler.java

License:Open Source License

public boolean handleMessage(IMessage message) {
    if (!USE_LOG) {
        return true;
    }/*from   w w  w  . j av  a2  s .c o m*/
    IMessage.Kind kind = message.getKind();
    if (kind.equals(IMessage.ABORT)) {
        AJLog.log(AJLog.COMPILER, "AJC: Compiler error: " + message.getMessage()); //$NON-NLS-1$
        message.getThrown().printStackTrace();
    }
    if (isIgnoring(kind)) {
        return true;
    }
    AJLog.log(AJLog.COMPILER, "AJC: " + message); //$NON-NLS-1$
    return true;
}

From source file:org.eclipse.ajdt.internal.ui.ajde.UIMessageHandler.java

License:Open Source License

public boolean handleMessage(IMessage message) {
    IMessage.Kind kind = message.getKind();
    if (kind == IMessage.ABORT || message.getThrown() != null) {
        // an exception has been thrown by AspectJ, therefore
        // want to create an error dialog containing the information
        // and display it to the user
        AJDTErrorHandler.handleInternalError(UIMessages.ajErrorDialogTitle, message.getMessage(),
                message.getThrown());/*  w  ww. j a  va  2s. c o  m*/
        return true;
    }
    if (isIgnoring(kind)) {
        return true;
    }
    if (message.getSourceLocation() == null) {
        AJLog.log(AJLog.COMPILER_MESSAGES, message.getMessage()); //$NON-NLS-1$
        problems.add(new ProblemTracker(message.getMessage(), null, message.getKind()));
    } else {
        if (DebugTracing.DEBUG_COMPILER_MESSAGES) {
            // avoid constructing log string if trace is not active
            AJLog.log(AJLog.COMPILER_MESSAGES, "addSourcelineTask message=" //$NON-NLS-1$
                    + message.getMessage() + " file=" //$NON-NLS-1$
                    + message.getSourceLocation().getSourceFile().getPath() + " line=" //$NON-NLS-1$
                    + message.getSourceLocation().getLine());
        } else {
            AJLog.log(AJLog.COMPILER_MESSAGES, message.getMessage());
        }
        problems.add(new ProblemTracker(message.getMessage(), message.getSourceLocation(), message.getKind(),
                message.getDeclared(), message.getExtraSourceLocations(), message.getID(),
                message.getSourceStart(), message.getSourceEnd(), message.getThrown()));
    }
    return true;
}

From source file:org.eclipse.ajdt.ui.tests.ajde.UIMessageHandlerTest.java

License:Open Source License

/**
 * For an abort message we expect an error dialog to appear containing the
 * information//  w ww.  jav a  2  s  .com
 */
public void testHandleAbortWithMessageAndThrowable() throws Exception {
    IProject project = createPredefinedProject("Bean Example"); //$NON-NLS-1$
    AJDTErrorHandler.setShowErrorDialogs(false);
    String message = ""; //$NON-NLS-1$
    try {
        IBuildMessageHandler handler = AspectJPlugin.getDefault().getCompilerFactory()
                .getCompilerForProject(project).getMessageHandler();

        IMessage msg = new Message("fake abort", IMessage.ABORT, new AbortException("fake abort"), null); //$NON-NLS-1$ //$NON-NLS-2$
        handler.handleMessage(msg);
    } catch (RuntimeException re) {
        message = re.getMessage();
    }
    assertTrue("expected a runtime error with message 'fake abort' when " + //$NON-NLS-1$
            " testing error handling but didn't find one", //$NON-NLS-1$
            message.equals("org.aspectj.bridge.AbortException: fake abort")); //$NON-NLS-1$
}

From source file:org.springframework.aop.aspectj.AspectJWeaverMessageHandler.java

License:Apache License

@Override
public boolean handleMessage(IMessage message) throws AbortException {
    Kind messageKind = message.getKind();
    if (messageKind == IMessage.DEBUG) {
        if (logger.isDebugEnabled()) {
            logger.debug(makeMessageFor(message));
            return true;
        }/* ww w.  j  a  v a2  s. c o m*/
    } else if (messageKind == IMessage.INFO || messageKind == IMessage.WEAVEINFO) {
        if (logger.isInfoEnabled()) {
            logger.info(makeMessageFor(message));
            return true;
        }
    } else if (messageKind == IMessage.WARNING) {
        if (logger.isWarnEnabled()) {
            logger.warn(makeMessageFor(message));
            return true;
        }
    } else if (messageKind == IMessage.ERROR) {
        if (logger.isErrorEnabled()) {
            logger.error(makeMessageFor(message));
            return true;
        }
    } else if (messageKind == IMessage.ABORT) {
        if (logger.isFatalEnabled()) {
            logger.fatal(makeMessageFor(message));
            return true;
        }
    }
    return false;
}