1 57 58 package org.apache.wsif.util.jms; 59 60 import java.util.ArrayList ; 61 import java.util.Arrays ; 62 63 import javax.jms.Destination ; 64 import javax.jms.Queue ; 65 import javax.jms.QueueConnectionFactory ; 66 import org.apache.wsif.WSIFException; 67 import org.apache.wsif.logging.Trc; 68 import org.apache.wsif.wsdl.extensions.jms.JMSAddress; 69 70 77 public abstract class WSIFJMSFinder { 78 public static final String STYLE_QUEUE = "queue"; 79 public static final String STYLE_TOPIC = "topic"; 80 81 protected static final ArrayList allStyles = 82 new ArrayList (Arrays.asList(new Object [] { STYLE_QUEUE, STYLE_TOPIC })); 83 84 private static final String MQ_URL_PREFIX = "mq://"; 85 86 abstract public QueueConnectionFactory getFactory(); 87 abstract public Destination getInitialDestination(); 88 abstract Queue findQueue(String name) throws WSIFException; 89 abstract String getStyle(); 90 91 public static WSIFJMSFinder newFinder(JMSAddress ja, String portName) throws WSIFException { 92 Trc.entry(null, ja); 93 boolean jndiSpecified = 94 ja.getInitCxtFact() != null 95 || ja.getJndiProvURL() != null 96 || ja.getDestStyle() != null 97 || ja.getJndiConnFactName() != null 98 || ja.getJndiDestName() != null 99 || ja.getJmsProvDestName() != null; 100 String implSpecURI = ja.getJmsImplSpecURI(); 101 102 if (jndiSpecified && implSpecURI != null) 103 throw new WSIFException( 104 "Cannot specify both JNDI attributes and " 105 + "jmsImplementationSpecificURL in the jms:address in port " 106 + portName); 107 108 if (!jndiSpecified && implSpecURI == null) 109 throw new WSIFException( 110 "Must specify either JNDI attributes or " 111 + "jmsImplementationSpecificURL in the jms:address in port " 112 + portName); 113 114 WSIFJMSFinder finder; 115 if (jndiSpecified) 116 finder = 117 new WSIFJMSFinderForJndi( 118 ja.getJmsVendorURI(), 119 ja.getInitCxtFact(), 120 ja.getJndiProvURL(), 121 ja.getDestStyle(), 122 ja.getJndiConnFactName(), 123 ja.getJndiDestName(), 124 portName); 125 else { 126 if (implSpecURI.startsWith(MQ_URL_PREFIX)) 127 finder = new WSIFJMSFinderForMq(ja.getJmsVendorURI(), implSpecURI); 128 else 129 throw new WSIFException( 130 "No jms implementation found for jmsImplementationSpecificURI '" 131 + implSpecURI 132 + "' for port " 133 + portName); 134 } 135 Trc.exit(finder); 136 return finder; 137 } 138 } | Popular Tags |