You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DefaultMessageHandler.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*******************************************************************************
  2. * Copyright (c) 2005 Contributors.
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://eclipse.org/legal/epl-v10.html
  8. *
  9. * Contributors:
  10. * Alexandre Vasseur initial implementation
  11. *******************************************************************************/
  12. package org.aspectj.weaver.loadtime;
  13. import org.aspectj.bridge.AbortException;
  14. import org.aspectj.bridge.IMessage;
  15. import org.aspectj.bridge.IMessageHandler;
  16. /**
  17. * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
  18. */
  19. public class DefaultMessageHandler implements IMessageHandler {
  20. boolean isVerbose = false;
  21. boolean isDebug = false;
  22. boolean showWeaveInfo = false;
  23. boolean showWarn = true;
  24. public boolean handleMessage(IMessage message) throws AbortException {
  25. if (isIgnoring(message.getKind())) {
  26. return false;
  27. } else {
  28. /*
  29. * TODO maw We ship this class but don't use or document it. Changed
  30. * to use stderr instead of stdout to allow improvements to LTW tests.
  31. * Currently many pass whether or not LTW occurs because they are
  32. * already woven. Some changed to check for appropriate weaving messages
  33. * as well as absence of warnings or errors.
  34. */
  35. return SYSTEM_ERR.handleMessage(message);
  36. // if (message.getKind().isSameOrLessThan(IMessage.INFO)) {
  37. // return SYSTEM_OUT.handleMessage(message);
  38. // } else {
  39. // return SYSTEM_ERR.handleMessage(message);
  40. // }
  41. }
  42. }
  43. public boolean isIgnoring(IMessage.Kind kind) {
  44. if (kind.equals(IMessage.WEAVEINFO)) {
  45. return !showWeaveInfo;
  46. }
  47. if (kind.isSameOrLessThan(IMessage.INFO)) {
  48. return !isVerbose;
  49. }
  50. if (kind.isSameOrLessThan(IMessage.DEBUG)) {
  51. return !isDebug;
  52. }
  53. return !showWarn;
  54. }
  55. public void dontIgnore(IMessage.Kind kind) {
  56. if (kind.equals(IMessage.WEAVEINFO)) {
  57. showWeaveInfo = true;
  58. } else if (kind.equals(IMessage.DEBUG)) {
  59. isVerbose = true;
  60. } else if (kind.equals(IMessage.WARNING)) {
  61. showWarn = false;
  62. }
  63. }
  64. public void ignore(IMessage.Kind kind) {
  65. if (kind.equals(IMessage.WEAVEINFO)) {
  66. showWeaveInfo = false;
  67. } else if (kind.equals(IMessage.DEBUG)) {
  68. isVerbose = false;
  69. } else if (kind.equals(IMessage.WARNING)) {
  70. showWarn = true;
  71. }
  72. }
  73. }