1 17 package org.apache.servicemix.jbi.servicedesc; 18 19 import javax.jbi.servicedesc.ServiceEndpoint; 20 import javax.xml.parsers.DocumentBuilder ; 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 27 public class EndpointReferenceBuilder { 28 29 public static final String JBI_NAMESPACE = "http://java.sun.com/jbi/end-point-reference"; 30 public static final String XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"; 31 32 public static DocumentFragment getReference(ServiceEndpoint endpoint) { 33 try { 34 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 35 dbf.setNamespaceAware(true); 36 DocumentBuilder db = dbf.newDocumentBuilder(); 37 Document doc = db.newDocument(); 38 DocumentFragment fragment = doc.createDocumentFragment(); 39 Element epr = doc.createElementNS(JBI_NAMESPACE, "jbi:end-point-reference"); 40 epr.setAttributeNS(XMLNS_NAMESPACE,"xmlns:sns", endpoint.getServiceName().getNamespaceURI()); 41 epr.setAttributeNS(JBI_NAMESPACE, "jbi:service-name", "sns:" + endpoint.getServiceName().getLocalPart()); 42 epr.setAttributeNS(JBI_NAMESPACE, "jbi:end-point-name", endpoint.getEndpointName()); 43 fragment.appendChild(epr); 44 return fragment; 45 } catch (Exception e) { 46 return null; 47 } 48 } 49 50 } 51 | Popular Tags |