@Test public void testTopicTypeIsDetectedFromComposite() throws JMSException { ForeignTopicAndQueue destination = new ForeignTopicAndQueue("destination"); destination.setQueue(false); JmsDestination result = transformer.transform(destination); assertNotNull(result); assertTrue(result instanceof JmsTopic); }
@Override public JmsDestination transform(Destination destination) throws JMSException { String queueName = null; String topicName = null; if (destination instanceof Queue) { queueName = ((Queue) destination).getQueueName(); } if (destination instanceof Topic) { topicName = ((Topic) destination).getTopicName(); } if (queueName == null && topicName == null) { throw new JMSException("Unresolvable destination: Both queue and topic names are null: " + destination); } try { Method isQueueMethod = destination.getClass().getMethod("isQueue"); Method isTopicMethod = destination.getClass().getMethod("isTopic"); Boolean isQueue = (Boolean) isQueueMethod.invoke(destination); Boolean isTopic = (Boolean) isTopicMethod.invoke(destination); if (isQueue) { return new JmsQueue(queueName); } else if (isTopic) { return new JmsTopic(topicName); } else { throw new JMSException("Unresolvable destination: Neither Queue nor Topic: " + destination); } } catch (Exception e) { throw new JMSException("Unresolvable destination: " + e.getMessage() + ": " + destination); } }
JmsDefaultUnresolvedDestinationTransformer implements JmsUnresolvedDestinationTransformer { @Override public JmsDestination transform(Destination destination) throws JMSException { String queueName = null; String topicName = null; if (destination instanceof Queue) { queueName = ((Queue) destination).getQueueName(); } if (destination instanceof Topic) { topicName = ((Topic) destination).getTopicName(); } if (queueName == null && topicName == null) { throw new JMSException("Unresolvable destination: Both queue and topic names are null: " + destination); } try { Method isQueueMethod = destination.getClass().getMethod("isQueue"); Method isTopicMethod = destination.getClass().getMethod("isTopic"); Boolean isQueue = (Boolean) isQueueMethod.invoke(destination); Boolean isTopic = (Boolean) isTopicMethod.invoke(destination); if (isQueue) { return new JmsQueue(queueName); } else if (isTopic) { return new JmsTopic(topicName); } else { throw new JMSException("Unresolvable destination: Neither Queue nor Topic: " + destination); } } catch (Exception e) { throw new JMSException("Unresolvable destination: " + e.getMessage() + ": " + destination); } } }
JmsDefaultUnresolvedDestinationTransformer implements JmsUnresolvedDestinationTransformer { @Override public JmsDestination transform(Destination destination) throws JMSException { String queueName = null; String topicName = null; if (destination instanceof Queue) { queueName = ((Queue) destination).getQueueName(); } if (destination instanceof Topic) { topicName = ((Topic) destination).getTopicName(); } if (queueName == null && topicName == null) { throw new JMSException("Unresolvable destination: Both queue and topic names are null: " + destination); } try { Method isQueueMethod = destination.getClass().getMethod("isQueue"); Method isTopicMethod = destination.getClass().getMethod("isTopic"); Boolean isQueue = (Boolean) isQueueMethod.invoke(destination); Boolean isTopic = (Boolean) isTopicMethod.invoke(destination); if (isQueue) { return new JmsQueue(queueName); } else if (isTopic) { return new JmsTopic(topicName); } else { throw new JMSException("Unresolvable destination: Neither Queue nor Topic: " + destination); } } catch (Exception e) { throw new JMSException("Unresolvable destination: " + e.getMessage() + ": " + destination); } }  }
JmsDefaultUnresolvedDestinationTransformer implements JmsUnresolvedDestinationTransformer { @Override public JmsDestination transform(Destination destination) throws JMSException { String queueName = null; String topicName = null; if (destination instanceof Queue) { queueName = ((Queue) destination).getQueueName(); } if (destination instanceof Topic) { topicName = ((Topic) destination).getTopicName(); } if (queueName == null && topicName == null) { throw new JMSException("Unresolvable destination: Both queue and topic names are null: " + destination); } try { Method isQueueMethod = destination.getClass().getMethod("isQueue"); Method isTopicMethod = destination.getClass().getMethod("isTopic"); Boolean isQueue = (Boolean) isQueueMethod.invoke(destination); Boolean isTopic = (Boolean) isTopicMethod.invoke(destination); if (isQueue) { return new JmsQueue(queueName); } else if (isTopic) { return new JmsTopic(topicName); } else { throw new JMSException("Unresolvable destination: Neither Queue nor Topic: " + destination); } } catch (Exception e) { throw new JMSException("Unresolvable destination: " + e.getMessage() + ": " + destination); } }  @Override JmsDestination transform(Destination destination); @Override JmsDestination transform(String destination); }
JmsDefaultUnresolvedDestinationTransformer implements JmsUnresolvedDestinationTransformer { @Override public JmsDestination transform(Destination destination) throws JMSException { String queueName = null; String topicName = null; if (destination instanceof Queue) { queueName = ((Queue) destination).getQueueName(); } if (destination instanceof Topic) { topicName = ((Topic) destination).getTopicName(); } if (queueName == null && topicName == null) { throw new JMSException("Unresolvable destination: Both queue and topic names are null: " + destination); } try { Method isQueueMethod = destination.getClass().getMethod("isQueue"); Method isTopicMethod = destination.getClass().getMethod("isTopic"); Boolean isQueue = (Boolean) isQueueMethod.invoke(destination); Boolean isTopic = (Boolean) isTopicMethod.invoke(destination); if (isQueue) { return new JmsQueue(queueName); } else if (isTopic) { return new JmsTopic(topicName); } else { throw new JMSException("Unresolvable destination: Neither Queue nor Topic: " + destination); } } catch (Exception e) { throw new JMSException("Unresolvable destination: " + e.getMessage() + ": " + destination); } }  @Override JmsDestination transform(Destination destination); @Override JmsDestination transform(String destination);  }