01: package org.objectweb.celtix.bus.configuration.wsdl;
02:
03: import java.util.List;
04:
05: import javax.wsdl.Binding;
06: import javax.wsdl.Port;
07: import javax.wsdl.extensions.ExtensibilityElement;
08: import javax.wsdl.extensions.soap.SOAPAddress;
09:
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: public void init(Configuration configuration) {
23: // not needed
24: }
25:
26: public Object getObject(String name) {
27: if (null == port) {
28: return null;
29: }
30: if ("bindingId".equals(name)) {
31: return getBinding();
32: } else if ("address".equals(name)) {
33: return getAddress();
34: }
35: return null;
36: }
37:
38: public boolean setObject(String name, Object value) {
39: // TODO Auto-generated method stub
40: return false;
41: }
42:
43: public boolean save() {
44: //TODO:
45: return false;
46: }
47:
48: private Object getBinding() {
49: Binding binding = port.getBinding();
50: if (null == binding) {
51: // TODO
52: return null;
53: }
54:
55: List list = binding.getExtensibilityElements();
56: if (list.isEmpty()) {
57: // TODO
58: // throw new WebServiceException("Could not get the extension element URI");
59: return null;
60: }
61:
62: return ((ExtensibilityElement) list.get(0)).getElementType()
63: .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: }
|