Package org.aspectj.bridge

Examples of org.aspectj.bridge.IMessageHolder


    final boolean verbose = flagInArgs("-verbose", args);
    final boolean timers = flagInArgs("-timers", args);
    if (null == this.clientHolder) {
      this.clientHolder = checkForCustomMessageHolder(args);
    }
    IMessageHolder holder = clientHolder;
    if (null == holder) {
      holder = ourHandler;
      if (verbose) {
        ourHandler.setInterceptor(MessagePrinter.VERBOSE);
      } else {
        ourHandler.ignore(IMessage.INFO);
        ourHandler.setInterceptor(MessagePrinter.TERSE);
      }
    }

    // make sure we handle out of memory gracefully...
    try {
      // byte[] b = new byte[100000000]; for testing OoME only!
      long stime = System.currentTimeMillis();
      // uncomment next line to pause before startup (attach jconsole)
      // try {Thread.sleep(5000); }catch(Exception e) {}
      run(args, holder);
      long etime = System.currentTimeMillis();
      if (timers) {
        System.out.println("Compiler took " + (etime - stime) + "ms");
      }
      holder.handleMessage(MessageUtil.info("Compiler took " + (etime - stime) + "ms"));
      // uncomment next line to pause at end (keeps jconsole alive!)
      // try { System.in.read(); } catch (Exception e) {}
    } catch (OutOfMemoryError outOfMemory) {
      IMessage outOfMemoryMessage = new Message(OUT_OF_MEMORY_MSG, null, true);
      holder.handleMessage(outOfMemoryMessage);
      systemExit(holder); // we can't reasonably continue from this point.
    } finally {
      CompilationAndWeavingContext.reset();
      Dump.reset();
    }
View Full Code Here


  /**
   * @param args
   */
  private IMessageHolder checkForCustomMessageHolder(String[] args) {
    IMessageHolder holder = null;
    final String customMessageHolder = parmInArgs(MESSAGE_HOLDER_OPTION, args);
    if (customMessageHolder != null) {
      try {
        holder = (IMessageHolder) Class.forName(customMessageHolder).newInstance();
      } catch (Exception ex) {
View Full Code Here

    }

    protected int spoon() throws BuildException {
        //if (version) version(null);
        int result = -1;
        final IMessageHolder holder;
        {
        MessageHandler handler = new MessageHandler();
        if (!verbose) {
          handler.ignore(IMessage.INFO);
        }
        final IMessageHandler delegate
          = verbose ? MessagePrinter.VERBOSE: MessagePrinter.TERSE;
      handler.setInterceptor(delegate);
      holder = handler;
        }
        try {
            String[] args = cmd.getCommandline();
            // XXX avoid rendering if not verbosely logging?
            log("Running  in-process using "
                + Ajc10.render(cmd.getCommandline()), Project.MSG_VERBOSE);
         
          Main main = new Main();
          main.run(args, holder);
          int errs = holder.numMessages(IMessage.ERROR, true);
          if (0 < errs) {
            result = 1;
          } else {
                result = 0;
            }
View Full Code Here

   * @throws BuildException if unable to create instance of className
   */
  public void setMessageHolderClass(String className) {
    try {
      Class mclass = Class.forName(className);
      IMessageHolder holder = (IMessageHolder) mclass.newInstance();
      setMessageHolder(holder);
    } catch (Throwable t) {
      String m = "unable to instantiate message holder: " + className;
      throw new BuildException(m, t);
    }
View Full Code Here

   */
  protected void executeInSameVM(String[] args) {
    if (null != maxMem) {
      log("maxMem ignored unless forked: " + maxMem, Project.MSG_WARN);
    }
    IMessageHolder holder = messageHolder;
    int numPreviousErrors;
    if (null == holder) {
      MessageHandler mhandler = new MessageHandler(true);
      final IMessageHandler delegate;
      delegate = new AntMessageHandler(this.logger, this.verbose, false);
      mhandler.setInterceptor(delegate);
      holder = mhandler;
      numPreviousErrors = 0;
    } else {
      numPreviousErrors = holder.numMessages(IMessage.ERROR, true);
    }
    {
      Main newmain = new Main();
      newmain.setHolder(holder);
      newmain.setCompletionRunner(new Runnable() {
        public void run() {
          doCompletionTasks();
        }
      });
      if (null != main) {
        MessageUtil.fail(holder, "still running prior main");
        return;
      }
      main = newmain;
    }
    main.runMain(args, false);
    if (failonerror) {
      int errs = holder.numMessages(IMessage.ERROR, false);
      errs -= numPreviousErrors;
      if (0 < errs) {
        String m = errs + " errors";
        MessageUtil.print(System.err, holder, "", MessageUtil.MESSAGE_ALL, MessageUtil.PICK_ERROR, true);
        throw new BuildException(m);
      }
    }
    // Throw BuildException if there are any fail or abort
    // messages.
    // The BuildException message text has a list of class names
    // for the exceptions found in the messages, or the
    // number of fail/abort messages found if there were
    // no exceptions for any of the fail/abort messages.
    // The interceptor message handler should have already
    // printed the messages, including any stack traces.
    // HACK: this ignores the Usage message
    {
      IMessage[] fails = holder.getMessages(IMessage.FAIL, true);
      if (!LangUtil.isEmpty(fails)) {
        StringBuffer sb = new StringBuffer();
        String prefix = "fail due to ";
        int numThrown = 0;
        for (int i = 0; i < fails.length; i++) {
View Full Code Here

    }

    protected int spoon() throws BuildException {
        //if (version) version(null);
        int result = -1;
        final IMessageHolder holder;
        {
        MessageHandler handler = new MessageHandler();
        if (!verbose) {
          handler.ignore(IMessage.INFO);
        }
        final IMessageHandler delegate
          = verbose ? MessagePrinter.VERBOSE: MessagePrinter.TERSE;
      handler.setInterceptor(delegate);
      holder = handler;
        }
        try {
            String[] args = cmd.getCommandline();
            // XXX avoid rendering if not verbosely logging?
            log("Running  in-process using "
                + Ajc10.render(cmd.getCommandline()), Project.MSG_VERBOSE);
         
          Main main = new Main();
          main.run(args, holder);
          int errs = holder.numMessages(IMessage.ERROR, true);
          if (0 < errs) {
            result = 1;
          } else {
                result = 0;
            }
View Full Code Here

     *         unless one of the args is -noExit.
     * and signal result (0 no exceptions/error, <0 exceptions, >0 compiler errors).
     */
    public void runMain(String[] args, boolean useSystemExit) {
        final boolean verbose = flagInArgs("-verbose", args);
        IMessageHolder holder = clientHolder;
        if (null == holder) {
            holder = ourHandler;
            if (verbose) {
                ourHandler.setInterceptor(MessagePrinter.VERBOSE);
            } else {
                ourHandler.ignore(IMessage.INFO);
                ourHandler.setInterceptor(MessagePrinter.TERSE);
            }
        }
       
        // make sure we handle out of memory gracefully...
        try {
          // byte[] b = new byte[100000000]; for testing OoME only!
          run(args, holder);
        } catch (OutOfMemoryError outOfMemory) {
          IMessage outOfMemoryMessage = new Message(OUT_OF_MEMORY_MSG,null,true);
          holder.handleMessage(outOfMemoryMessage);
          systemExit(holder)// we can't reasonably continue from this point.
        }

        boolean skipExit = false;
        if (useSystemExit && !LangUtil.isEmpty(args)) {  // sigh - pluck -noExit
View Full Code Here

TOP

Related Classes of org.aspectj.bridge.IMessageHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.