KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > configuration > wsdl > WsdlPortProvider


1 package org.objectweb.celtix.bus.configuration.wsdl;
2
3 import java.util.List JavaDoc;
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         // not needed
25
}
26     
27     public Object JavaDoc getObject(String JavaDoc 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 JavaDoc name, Object JavaDoc value) {
40         // TODO Auto-generated method stub
41
return false;
42     }
43
44     public boolean save() {
45         //TODO:
46
return false;
47     }
48
49     private Object JavaDoc getBinding() {
50         Binding binding = port.getBinding();
51         if (null == binding) {
52             // TODO
53
return null;
54         }
55         
56         List JavaDoc list = binding.getExtensibilityElements();
57         if (list.isEmpty()) {
58             // TODO
59
// throw new WebServiceException("Could not get the extension element URI");
60
return null;
61         }
62       
63         return ((ExtensibilityElement)list.get(0)).getElementType().getNamespaceURI();
64     }
65     
66     private Object JavaDoc getAddress() {
67         List JavaDoc<?> list = port.getExtensibilityElements();
68         for (Object JavaDoc 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