Examples of XMLMessage


Examples of hermes.xml.XMLMessage

      }

      Set<XMLMessage> toRemove = new HashSet<XMLMessage>();

      for (Iterator<Entry> iter = xmlMessages.getEntry().iterator(); iter.hasNext();) {
        XMLMessage xmlMessage = null;
        Entry entry = iter.next();
        if (entry.getBytesMessage() != null) {
          xmlMessage = entry.getBytesMessage();
        } else if (entry.getTextMessage() != null) {
          xmlMessage = entry.getTextMessage();
        } else if (entry.getMapMessage() != null) {
          xmlMessage = entry.getMapMessage();
        } else if (entry.getObjectMessage() != null) {
          xmlMessage = entry.getObjectMessage();
        }

        if (xmlMessage != null) {
          if (messageIds.contains(xmlMessage.getJMSMessageID())) {
            iter.remove();
          }
        }
      }
View Full Code Here

Examples of hermes.xml.XMLMessage

    if (xmlMessages == null) {
      read() ;
    }
   
    for (int i = 0 ; i < xmlMessages.getEntry().size() ; i++) {
      XMLMessage xmlMessage = null;
      Entry entry = xmlMessages.getEntry().get(i) ;
      if (entry.getBytesMessage() != null) {
        xmlMessage = entry.getBytesMessage();
      } else if (entry.getTextMessage() != null) {
        xmlMessage = entry.getTextMessage();
      } else if (entry.getMapMessage() != null) {
        xmlMessage = entry.getMapMessage();
      } else if (entry.getObjectMessage() != null) {
        xmlMessage = entry.getObjectMessage();
      }

      // ikky but whatever.
     
      if (xmlMessage != null) {
        if (message.getJMSMessageID().equals(xmlMessage.getJMSMessageID())) {
          xmlMessages.getEntry().remove(i) ;
          MessageSet messageSet = xmlSupport.toMessageSet(Arrays.asList(message)) ;
          xmlMessages.getEntry().add(i, messageSet.getEntry().get(0)) ;
        }
      }
View Full Code Here

Examples of hermes.xml.XMLMessage

      MessageSet messageSet = factory.createMessageSet();

      for (Iterator iter = messages.iterator(); iter.hasNext();) {
        Message jmsMessage = (Message) iter.next();
        Entry entry = factory.createEntry();
        XMLMessage xmlMessage = createXMLMessage(factory, jmsMessage);

        if (xmlMessage instanceof XMLTextMessage) {
          entry.setType(XML_TEXT_MESSAGE);
          entry.setTextMessage((XMLTextMessage) xmlMessage);
View Full Code Here

Examples of hermes.xml.XMLMessage

  }

  public XMLMessage createXMLMessage(ObjectFactory factory, Message message) throws JMSException, IOException, EncoderException {
    try {
      XMLMessage rval = factory.createXMLMessage();

      if (message instanceof TextMessage) {
        rval = factory.createXMLTextMessage();

        XMLTextMessage textRval = (XMLTextMessage) rval;
        TextMessage textMessage = (TextMessage) message;

        if (isBase64EncodeTextMessages()) {
          byte[] bytes = base64EncoderTL.get().encode(textMessage.getText().getBytes());
          textRval.setText(new String(bytes, "ASCII"));
          textRval.setCodec(BASE64_CODEC);
        } else {
          textRval.setText(textMessage.getText());
        }
      } else if (message instanceof MapMessage) {
        rval = factory.createXMLMapMessage();

        XMLMapMessage mapRval = (XMLMapMessage) rval;
        MapMessage mapMessage = (MapMessage) message;

        for (Enumeration iter = mapMessage.getMapNames(); iter.hasMoreElements();) {
          String propertyName = (String) iter.nextElement();
          Object propertyValue = mapMessage.getObject(propertyName);
          Property xmlProperty = factory.createProperty();

          if (propertyValue != null) {
            xmlProperty.setValue(propertyValue.toString());
            xmlProperty.setType(propertyValue.getClass().getName());
          }
          xmlProperty.setName(propertyName);

          mapRval.getBodyProperty().add(xmlProperty);
        }
      } else if (message instanceof BytesMessage) {
        rval = factory.createXMLBytesMessage();

        XMLBytesMessage bytesRval = (XMLBytesMessage) rval;
        BytesMessage bytesMessage = (BytesMessage) message;
        ByteArrayOutputStream bosream = new ByteArrayOutputStream();

        bytesMessage.reset();

        try {
          for (;;) {
            bosream.write(bytesMessage.readByte());
          }
        } catch (MessageEOFException ex) {
          // NOP
        }

        bytesRval.setBytes(new String(base64EncoderTL.get().encode(bosream.toByteArray())));
      } else if (message instanceof ObjectMessage) {
        rval = factory.createXMLObjectMessage();

        XMLObjectMessage objectRval = (XMLObjectMessage) rval;
        ObjectMessage objectMessage = (ObjectMessage) message;

        ByteArrayOutputStream bostream = new ByteArrayOutputStream();
        ObjectOutputStream oostream = new ObjectOutputStream(bostream);

        oostream.writeObject(objectMessage.getObject());
        oostream.flush();
        byte b[] = base64EncoderTL.get().encode(bostream.toByteArray());
        String s = new String(b, "ASCII");
        objectRval.setObject(s);
      }

      if (message.getJMSReplyTo() != null) {
        rval.setJMSReplyTo(JMSUtils.getDestinationName(message.getJMSReplyTo()));
        rval.setJMSReplyToDomain(Domain.getDomain(message.getJMSReplyTo()).getId());
      }

      // try/catch each individually as we sometime find some JMS
      // providers
      // can barf
      try {
        rval.setJMSDeliveryMode(message.getJMSDeliveryMode());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSExpiration(message.getJMSExpiration());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSMessageID(message.getJMSMessageID());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSPriority(message.getJMSPriority());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSRedelivered(message.getJMSRedelivered());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      } catch (IllegalStateException ex) {
        // http://hermesjms.com/forum/viewtopic.php?f=4&t=346

        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSTimestamp(message.getJMSTimestamp());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSType(message.getJMSType());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        rval.setJMSCorrelationID(message.getJMSCorrelationID());
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      try {
        if (message.getJMSDestination() != null) {
          rval.setJMSDestination(JMSUtils.getDestinationName(message.getJMSDestination()));
          rval.setFromQueue(JMSUtils.isQueue(message.getJMSDestination()));
        }
      } catch (JMSException ex) {
        log.error(ex.getMessage(), ex);
      }

      for (final Enumeration iter = message.getPropertyNames(); iter.hasMoreElements();) {
        String propertyName = (String) iter.nextElement();

        if (!propertyName.startsWith("JMS")) {
          Object propertyValue = message.getObjectProperty(propertyName);
          Property property = factory.createProperty();

          property.setName(propertyName);

          if (propertyValue != null) {
            property.setValue(StringEscapeUtils.escapeXml(propertyValue.toString()));
            property.setType(propertyValue.getClass().getName());
          }

          rval.getHeaderProperty().add(property);
        }
      }

      return rval;
    } catch (Exception ex) {
View Full Code Here

Examples of org.apache.axis2.transport.testkit.message.XMLMessage

    protected XMLMessage prepareMessage() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement payload = factory.createOMElement(new QName("root"));
        Attachments attachments = new Attachments();
        attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
        return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
    }
View Full Code Here

Examples of org.apache.axis2.transport.testkit.message.XMLMessage

    protected XMLMessage prepareMessage() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement payload = factory.createOMElement(new QName("root"));
        Attachments attachments = new Attachments();
        attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
        return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
    }
View Full Code Here

Examples of org.apache.axis2.transport.testkit.message.XMLMessage

    protected XMLMessage prepareMessage() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement payload = factory.createOMElement(new QName("root"));
        Attachments attachments = new Attachments();
        attachments.addDataHandler(contentID, new DataHandler(new ByteArrayDataSource(attachmentContent, "application/octet-stream")));
        return new XMLMessage(payload, XMLMessage.Type.SWA, attachments);
    }
View Full Code Here

Examples of org.apache.axis2.transport.testkit.message.XMLMessage

        for (int i=0; i<1000; i++) {
            OMElement child = factory.createOMElement(new QName("child"));
            child.setText("text");
            root.addChild(child);
        }
        return new XMLMessage(root, XMLMessage.Type.SOAP11);
    }
View Full Code Here

Examples of org.apache.axis2.transport.testkit.message.XMLMessage

    @Override
    protected XMLMessage prepareMessage() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement orgElement = factory.createOMElement(new QName("root"));
        orgElement.setText(data.getText());
        return new XMLMessage(orgElement, xmlMessageType);
    }
View Full Code Here

Examples of org.apache.axis2.transport.testkit.message.XMLMessage

    @Override
    protected XMLMessage prepareRequest() throws Exception {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        OMElement orgElement = factory.createOMElement(new QName("root"));
        orgElement.setText(data.getText());
        return new XMLMessage(orgElement, xmlMessageType);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.