1 17 package org.apache.servicemix.jms; 18 19 import javax.jbi.servicedesc.ServiceEndpoint; 20 import javax.xml.namespace.QName ; 21 import javax.xml.parsers.DocumentBuilderFactory ; 22 23 import org.w3c.dom.Document ; 24 import org.w3c.dom.DocumentFragment ; 25 import org.w3c.dom.Element ; 26 import org.w3c.dom.Text ; 27 28 public class JmsExternalEndpoint implements ServiceEndpoint { 29 30 private JmsEndpoint endpoint; 31 32 public JmsExternalEndpoint(JmsEndpoint endpoint) { 33 this.endpoint = endpoint; 34 } 35 36 public DocumentFragment getAsReference(QName operationName) { 37 try { 38 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 39 dbf.setNamespaceAware(true); 40 Document doc = dbf.newDocumentBuilder().newDocument(); 41 DocumentFragment df = doc.createDocumentFragment(); 42 Element e = doc.createElementNS(JmsResolvedEndpoint.EPR_URI, JmsResolvedEndpoint.EPR_NAME); 43 Text t = doc.createTextNode(endpoint.getService() + "#" + endpoint.getEndpoint()); 44 e.appendChild(t); 45 df.appendChild(e); 46 return df; 47 } catch (Exception e) { 48 throw new RuntimeException ("Could not create reference", e); 49 } 50 } 51 52 public String getEndpointName() { 53 return endpoint.getEndpoint(); 54 } 55 56 public QName [] getInterfaces() { 57 if (endpoint.getInterfaceName() != null) { 58 return new QName [] { endpoint.getInterfaceName() }; 59 } 60 return null; 61 } 62 63 public QName getServiceName() { 64 return endpoint.getService(); 65 } 66 67 } 68 | Popular Tags |