1 package org.objectweb.celtix.bus.configuration.wsdl; 2 3 import java.util.List ; 4 5 import javax.wsdl.Binding; 6 import javax.wsdl.Port; 7 import javax.wsdl.extensions.ExtensibilityElement; 8 import javax.wsdl.extensions.soap.SOAPAddress; 9 10 import org.objectweb.celtix.configuration.Configuration; 11 import org.objectweb.celtix.configuration.ConfigurationProvider; 12 import org.xmlsoap.schemas.wsdl.http.AddressType; 13 14 public class WsdlPortProvider implements ConfigurationProvider { 15 16 private final Port port; 17 18 public WsdlPortProvider(Port p) { 19 port = p; 20 } 21 22 23 public void init(Configuration configuration) { 24 } 26 27 public Object getObject(String name) { 28 if (null == port) { 29 return null; 30 } 31 if ("bindingId".equals(name)) { 32 return getBinding(); 33 } else if ("address".equals(name)) { 34 return getAddress(); 35 } 36 return null; 37 } 38 39 public boolean setObject(String name, Object value) { 40 return false; 42 } 43 44 public boolean save() { 45 return false; 47 } 48 49 private Object getBinding() { 50 Binding binding = port.getBinding(); 51 if (null == binding) { 52 return null; 54 } 55 56 List list = binding.getExtensibilityElements(); 57 if (list.isEmpty()) { 58 return null; 61 } 62 63 return ((ExtensibilityElement)list.get(0)).getElementType().getNamespaceURI(); 64 } 65 66 private Object getAddress() { 67 List <?> list = port.getExtensibilityElements(); 68 for (Object ep : list) { 69 ExtensibilityElement ext = (ExtensibilityElement)ep; 70 if (ext instanceof SOAPAddress) { 71 return ((SOAPAddress)ext).getLocationURI(); 72 } 73 if (ext instanceof AddressType) { 74 return ((AddressType)ext).getLocation(); 75 } 76 } 77 return null; 78 } 79 80 } 81 | Popular Tags |