Ejemplo n.º 1
0
 /**
  * Map method which will be used to populate the data from disconnected (@link MessageImpl) to
  * (@link Message) object.
  *
  * @param msg - JMS Message instance
  * @param msgImpl - Disconnected MessageImpl instance
  * @throws JMSException
  */
 public void map(Message msg, SimpleMessageImpl msgImpl) throws JMSException {
   if (msg == null) {
     throw new RuntimeException("RuntimeException: Message object is NULL.");
   } else if (msgImpl == null) {
     throw new RuntimeException("RuntimeException: MessageImpl object is NULL.");
   } else if (!msgImpl.validate()) {
     throw new RuntimeException(
         "RuntimeException: MessageImpl validation failed -->:" + (msgImpl.toString()));
   } else {
     switch (getMessageType(msg)) {
       case MessageImpl.TEXT_MESSAGE:
         populateHeader(msg, msgImpl);
         populateBody(msg, msgImpl, MessageImpl.TEXT_MESSAGE);
         break;
       case MessageImpl.OBJECT_MESSAGE:
         populateHeader(msg, msgImpl);
         populateBody(msg, msgImpl, MessageImpl.OBJECT_MESSAGE);
         break;
       case MessageImpl.STREAM_MESSAGE:
         populateHeader(msg, msgImpl);
         break;
       case MessageImpl.BYTES_MESSAGE:
         populateHeader(msg, msgImpl);
         break;
       case MessageImpl.MAP_MESSAGE:
         populateHeader(msg, msgImpl);
         break;
       default:
         throw new RuntimeException("INVALID JMS Message Type");
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * This method is used to populate only the Body information
  *
  * @param msg - JMS Message instance
  * @param msgImpl - Disconnected MessageImpl instance
  * @throws JMSException
  */
 private void populateBody(Message msg, SimpleMessageImpl msgImpl, int messageType)
     throws JMSException {
   if (msgImpl.getPayLoad() != null) {
     switch (messageType) {
       case MessageImpl.TEXT_MESSAGE:
         if (msgImpl.getPayLoad() != null && msgImpl.getPayLoad() instanceof String)
           ((TextMessage) msg).setText((String) msgImpl.getPayLoad());
         break;
       case MessageImpl.OBJECT_MESSAGE:
         ((ObjectMessage) msg).setObject(msgImpl.getPayLoad());
         break;
       case MessageImpl.MAP_MESSAGE:
       case MessageImpl.BYTES_MESSAGE:
       case MessageImpl.STREAM_MESSAGE:
         break;
       default:
         break;
     }
   }
 }
Ejemplo n.º 3
0
 /**
  * This method is used to populate only the Header information
  *
  * @param msg - JMS Message instance
  * @param msgImpl - Disconnected MessageImpl instance
  * @throws JMSException
  */
 private void populateHeader(Message msg, SimpleMessageImpl msgImpl) throws JMSException {
   Map<String, MessagePropertyImpl> bodyProps = msgImpl.getProperties();
   if (bodyProps != null && !bodyProps.isEmpty()) {
     for (Iterator iter = bodyProps.entrySet().iterator(); iter.hasNext(); ) {
       Entry entry = (Entry) iter.next();
       MessagePropertyImpl propertyImpl = (MessagePropertyImpl) entry.getValue();
       populateProperty(
           propertyImpl.getKey(), propertyImpl.getValue(), propertyImpl.getType(), msg);
       propertyImpl = null; // Clean up unnecessary objects.
     }
   }
   bodyProps = null; // Clean up unnecessary objects.
 }
Ejemplo n.º 4
0
 /**
  * Map method which will be used to populate the data from disconnected (@link MessageImpl) to
  * (@link Message) object.
  *
  * @param session - JMS (@link Session)
  * @param msgImpl - Disconnected MessageImpl instance
  * @throws JMSException
  */
 public Message map(Session session, SimpleMessageImpl msgImpl) throws JMSException {
   Message message = createMessage(session, msgImpl.getMessageType());
   map(message, msgImpl);
   return message;
 }