Package org.fusesource.ide.jmx.commons.messages

Examples of org.fusesource.ide.jmx.commons.messages.IMessage


        exchange = Exchanges.unmarshalNoNamespaceXmlString(xml);
      }
      if (exchange == null) {
        exchange = new Exchange();
      }
      IMessage in = exchange.getIn();
      in.setToNode(traceMessage.getToNode());
      in.setUuid(traceMessage.getUid());
      Date timestamp = traceMessage.getTimestamp();
      if (timestamp != null) {
        in.setTimestamp(timestamp);
        long time = timestamp.getTime();
        long relative = 0;
        boolean first = false;
        if (firstExchangeTimeMs == null) {
          firstExchangeTimeMs = time;
          first = true;
        } else {
          relative = time - firstExchangeTimeMs;
        }
        long elapsed = relative - lastTime;
        lastTime = relative;
        in.setRelativeTime(relative);
        if (!first) {
          in.setElapsedTime(elapsed);
        }
      }
      exchange.setId(traceMessage.getExchangeId());
     
      return exchange;
View Full Code Here


          }
         
          if (part.getClass().getName().equals("org.fusesource.ide.jmx.commons.views.messages.MessagesView")) {
            // special handling for message view selections
            if (firstSelection != null) {
              IMessage in = Exchanges.asMessage(firstSelection);
              if (in != null) {
                String toNode = in.getToNode();
                if (toNode != null) {
                  selectNodeId(toNode, in.getEndpointUri());
                }
              }
            }
            return;
          }
         
          if (firstSelection != null) {
            updateselection(firstSelection);
          }
         
//          if (firstSelection == null) {
//            setSelectedObjectOnly(null);
//          }
         
          AbstractNode node = AbstractNodes.getSelectedNode(selection);
          if (node != null && !(part instanceof RiderEditor)) {
            //Activator.getLogger().debug("Part is: " + part + " of type : " + part.getClass());
            if (node != DiagramView.this.node) {
              updateGraph(node, part);
            }
          } else {
            if (firstSelection instanceof Node) {
              updateGraph((Node) firstSelection, part);
            // this clause is needed because ConnectionHandlers are not descendants of Node
            } else if (firstSelection instanceof IConnectionWrapper) {
              viewer.setContentProvider(new NodeGraphContentProvider());
              setSelectedObjectOnly(firstSelection);
            } else if (firstSelection != null) {
              IMessage in = Exchanges.asMessage(firstSelection);
              if (in != null) {
                String toNode = in.getToNode();
                if (toNode != null) {
                  selectNodeId(toNode, in.getEndpointUri());
                }

              }
            }
          }
View Full Code Here

        for (int i = 0; i < size; i++) {
          String xml = browsable.browseMessageAsXml(i, true);
          if (xml != null) {
            Exchange exchange = Exchanges.unmarshalNoNamespaceXmlString(xml);
            if (exchange != null) {
              IMessage in = exchange.getIn();
              if (in != null) {
                in.setEndpointUri(getEndpointUri());
              }
              answer.add(exchange);
            }
          }
        }
View Full Code Here

      column = addColumnFunction(bounds, column, function, "Message Body");
    }

    SortedSet<String> headers = new TreeSet<String>();
    for (IExchange exchange : exchanges) {
      IMessage in = exchange.getIn();
      if (in != null) {
        headers.addAll(in.getHeaders().keySet());
      }
    }
    for (final String header : headers) {
      final Function1 function = new Function1() {
        @Override
        public Object apply(Object element) {
          if (element instanceof IExchange) {
            IExchange exchange = (IExchange) element;
            IMessage in = exchange.getIn();
            if (in != null) {
              return in.getHeaders().get(header);
            }
          }
          return null;
        }
      };
      column = addColumnFunction(bounds, column, function, header);
    }
    if (browser instanceof ITraceExchangeBrowser) {
      if (showToNode) {
        final Function1 function = new Function1() {
          @Override
          public Object apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getToNode();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Trace Node Id");
      }
      if (showTimestamp) {
        final Function1 function = new Function1() {
          @Override
          public Object apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getTimestamp();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Trace Timestamp");
      }
      if (showRelativeTime) {
        final Function1 function = new FunctionLong() {
          @Override
          public Long apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getRelativeTime();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Relative Time (ms)");
      }
      if (showElapsedTime) {
        final Function1 function = new FunctionLong() {
          @Override
          public Long apply(Object element) {
            IMessage message = Exchanges.asMessage(element);
            if (message != null) {
              return message.getElapsedTime();
            }
            return null;
          }
        };
        column = addColumnFunction(bounds, column, function, "Elapsed Time (ms)");
View Full Code Here

      List<String> fileNames = new ArrayList<String>();
      Iterator iter = selection.iterator();
      try {
        while (iter.hasNext()) {
          Object element = iter.next();
          IMessage message = Exchanges.toMessage(element);
          if (message != null) {
            // TODO - use a temporary directory then make the file
            // name based on the message ID?
            File file = File.createTempFile("message-", ".xml");
            Exchanges.marshal(message, file);
            fileNames.add(file.getAbsolutePath());
          }
        }
        event.data = fileNames.toArray(new String[fileNames.size()]);
      } catch (Exception e) {
        Activator.getLogger().warning(
            "Failed to create file from message: " + e, e);
      }
    } else if (PluginTransfer.getInstance().isSupportedType(event.dataType) && selection != null) {
      event.data = selection;
    } else if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType) && selection != null) {
      event.data = selection;
    } else {
      IMessage message = Exchanges.toMessage(selection.getFirstElement());
      if (message != null) {
        Object body = message.getBody();
        if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
          event.data = body;
        } else {
        }
      }
View Full Code Here

    this.target = target;
  }

  public void dropIFile(IFile resource) {
    try {
      IMessage message = fileToMessage(resource);
      if (message != null) {
        dropMessage(message);
      }
    } catch (Exception e) {
      Activator.showUserError("Failed to send message to " + target, "Failed to load resource " + resource
View Full Code Here

  public static IMessage fileToMessage(IFile resource) throws CoreException, JAXBException {
    IContentDescription contentDescription = resource.getContentDescription();
    String fileExtension = resource.getFileExtension();

    IMessage message;
    if (MessagesNamespaceXmlContentDescriber.isXmlFormat(resource)) {
      message = Exchanges.loadMessage(resource, resource.getContents());
    } else {

      // TODO deal with binary....
View Full Code Here

  }

  @Override
  public void dropFile(File file) {
    try {
      IMessage message = Exchanges.loadMessage(file);
      dropMessage(message);
    } catch (Exception e) {
      Activator.showUserError("Failed to send message to " + target, "Failed to load file " + file
          + " as a Message. ", e);
    }
View Full Code Here

TOP

Related Classes of org.fusesource.ide.jmx.commons.messages.IMessage

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.