예제 #1
0
  @Override
  public void run() {
    LogEventBean event = view.getSelectedEvent();
    if (event == null) {
      return;
    }
    StringBuffer buf = new StringBuffer();
    String[] lines = Logs.getThrowableRep(event);
    if (lines != null && lines.length > 0) {
      for (int i = 0; i < lines.length; i++) {
        buf.append(lines[i]).append(NEW_LINE);
      }
    } else {
      // lets use the location of the
      String className = event.getClassName();
      String methodName = event.getMethodName();
      String fileName = event.getFileName();
      String lineNumber = event.getLineNumber();
      if (Strings.isBlank(className)
          || Strings.isBlank(methodName)
          || Strings.isBlank(fileName)
          || Strings.isBlank(lineNumber)) {
        return;
      }
      buf.append(event.getMessage()).append(NEW_LINE);
      buf.append("\tat " + className + "." + methodName + "(" + fileName + ":" + lineNumber + ")")
          .append(NEW_LINE);
      ;
    }

    // check that the user did not remove our console from the ConsoleView
    boolean stillRegistered = checkRegistration();
    if (!stillRegistered) {
      registerConsole();
    }

    console.clearConsole();
    console.getDocument().set(buf.toString());
    ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
  }
예제 #2
0
  public void dropMessage(IMessage message) {
    Map<String, Object> headers = message.getHeaders();
    Map<String, Object> cleanHeaders = new HashMap<String, Object>();
    Set<Entry<String, Object>> entrySet = headers.entrySet();
    for (Entry<String, Object> entry : entrySet) {
      String key = entry.getKey();
      Object value = entry.getValue();
      if (value != null && !ignoreSendHeaders.contains(key)) {
        if (Objects.equal("JMSReplyTo", key)) {
          value = JmsTypeConverters.toDestination(value);
        } else if (Objects.equal("JMSExpiration", key)) {
          value = JmsTypeConverters.toTimestamp(value);
        } else if (Objects.equal("JMSTimestamp", key)) {
          value = JmsTypeConverters.toTimestamp(value);
        } else if (Objects.equal("JMSDeliveryMode", key)) {
          value = JmsTypeConverters.toDeliveryMode(value);
        } else if (Objects.equal("JMSRedelivered", key)) {
          value = JmsTypeConverters.toBoolean(value);
        } else if (Objects.equal("JMSPriority", key)) {
          value = JmsTypeConverters.toInteger(value);
        }

        if (value != null) {
          cleanHeaders.put(key, value);
        }
      }
    }

    String body = Strings.getOrElse(message.getBody());

    try {
      // TODO store username/pwd on a queue basis?
      String userName = getBrokerNode().getUserName();
      String password = getBrokerNode().getPassword();
      if (userName != null && password != null) {
        destination.sendTextMessage(cleanHeaders, body, userName, password);
      } else {
        destination.sendTextMessage(cleanHeaders, body);
      }
    } catch (Exception e) {
      FabricPlugin.showUserError(
          "Send message to " + this + " failed", "Could not send message to " + this, e);
    }
  }
예제 #3
0
 public String getText() {
   if (text == null) {
     text = Strings.getOrElse(value, "");
   }
   return text;
 }
예제 #4
0
 @Override
 public String toString() {
   return "Exchange[" + Strings.join(", ", id) + " : " + in + "]";
 }