1 7 package org.jboss.jms.serverless; 8 9 import org.jboss.logging.Logger; 10 import javax.jms.Topic ; 11 import javax.jms.JMSException ; 12 import javax.jms.Destination ; 13 14 21 public class Destinations { 22 23 private Destinations() { 24 } 25 26 35 public static Destination createDestination(String s) throws JMSException { 36 37 39 if (s == null) { 40 throw new JMSException ("null destination string representation"); 41 } 42 43 if (s.startsWith("GroupTopic[") && s.endsWith("]")) { 44 String name = s.substring("GroupTopic[".length(), s.length() - 1); 45 return new GroupTopic(name); 46 } 47 else if (s.startsWith("GroupQueue[") && s.endsWith("]")) { 48 String name = s.substring("GroupQueue[".length(), s.length() - 1); 49 return new GroupQueue(name); 50 } 51 throw new JMSException ("invalid destination string representation: "+s); 52 53 } 54 55 59 public static String stringRepresentation(Destination d) throws JMSException { 60 61 if (d instanceof GroupTopic) { 62 String name = ((GroupTopic)d).getTopicName(); 63 return "GroupTopic["+name+"]"; 64 } 65 else if (d instanceof GroupQueue) { 66 String name = ((GroupQueue)d).getQueueName(); 67 return "GroupQueue["+name+"]"; 68 } 69 throw new JMSException ("Unsupported destination: "+d); 70 } 71 72 } 73 | Popular Tags |