1 57 58 package org.apache.wsif.providers.soap.apachesoap; 59 60 import java.security.AccessController ; 61 import java.security.PrivilegedAction ; 62 import java.util.Iterator ; 63 import java.util.List ; 64 import java.util.Vector ; 65 66 import javax.wsdl.Binding; 67 import javax.wsdl.Definition; 68 import javax.wsdl.Port; 69 import javax.wsdl.Service; 70 import javax.wsdl.extensions.soap.SOAPBinding; 71 72 import org.apache.wsif.WSIFException; 73 import org.apache.wsif.WSIFPort; 74 import org.apache.wsif.base.WSIFServiceImpl; 75 import org.apache.wsif.logging.Trc; 76 import org.apache.wsif.providers.WSIFDynamicTypeMap; 77 import org.apache.wsif.spi.WSIFProvider; 78 79 89 public class WSIFDynamicProvider_ApacheSOAP implements WSIFProvider { 90 protected String partSerializerName = null; 91 92 private static final String soap = "http://schemas.xmlsoap.org/wsdl/soap/"; 93 private static final String jms = "http://schemas.xmlsoap.org/wsdl/jms/"; 94 private static String [] bindings = new String [0]; 95 private static String [] addresses = new String [0]; 96 private static boolean setUpBindings = false; 97 private static boolean setUpAddresses = false; 98 99 public WSIFDynamicProvider_ApacheSOAP() { 100 Trc.entry(this); 101 if (!setUpBindings) { 102 setUpBindingNamespaceURIs(); 103 } 104 if (!setUpAddresses) { 105 setUpAddressNamespaceURIs(); 106 } 107 WSIFServiceImpl.addExtensionRegistry( 108 new org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry()); 109 Trc.exit(); 110 } 111 112 116 public WSIFPort createDynamicWSIFPort( 117 Definition def, 118 Service service, 119 Port port, 120 WSIFDynamicTypeMap typeMap) 121 throws WSIFException { 122 Trc.entry(this, def, service, port, typeMap); 123 124 Binding binding = port.getBinding(); 126 List exs = binding.getExtensibilityElements(); 127 for (Iterator i = exs.iterator(); i.hasNext();) { 128 Object o = i.next(); 129 if (o instanceof SOAPBinding) { 130 WSIFPort wp = 132 new WSIFPort_ApacheSOAP( 133 def, 134 service, 135 port, 136 typeMap, 137 partSerializerName); 138 Trc.exit(wp); 139 return wp; 140 } 141 } 142 143 Trc.exit(null); 145 return null; 146 } 147 148 152 public String getPartSerializerName() { 153 Trc.entry(this); 154 Trc.exit(partSerializerName); 155 return partSerializerName; 156 } 157 158 162 public void setPartSerializerName(String partSerializerName) { 163 Trc.entry(this, partSerializerName); 164 this.partSerializerName = partSerializerName; 165 Trc.exit(); 166 } 167 168 172 public String [] getBindingNamespaceURIs() { 173 Trc.entry(this); 174 Trc.exit(bindings); 175 return bindings; 176 } 177 178 182 public String [] getAddressNamespaceURIs() { 183 Trc.entry(this); 184 Trc.exit(addresses); 185 return addresses; 186 } 187 188 private void setUpBindingNamespaceURIs() { 189 Class cls = 192 (Class ) AccessController.doPrivileged(new PrivilegedAction () { 193 public Object run() { 194 try { 195 return Class.forName( 196 "org.apache.soap.Constants", 197 true, 198 Thread.currentThread().getContextClassLoader()); 199 } catch (Throwable ignored) { 200 Trc.ignoredException(ignored); 201 } 202 return null; 203 } 204 }); 205 if (cls != null) { 206 bindings = new String [] { soap }; 207 } 208 setUpBindings = true; 209 } 210 211 private void setUpAddressNamespaceURIs() { 212 Vector v = new Vector (); 213 Class cls = 216 (Class ) AccessController.doPrivileged(new PrivilegedAction () { 217 public Object run() { 218 try { 219 return Class.forName( 220 "javax.jms.Queue", 221 true, 222 Thread.currentThread().getContextClassLoader()); 223 } catch (Throwable ignored) { 224 Trc.ignoredException(ignored); 225 } 226 return null; 227 } 228 }); 229 if (cls != null) { 230 v.add(jms); 231 } 232 233 Class cls2 = 236 (Class ) AccessController.doPrivileged(new PrivilegedAction () { 237 public Object run() { 238 try { 239 return Class.forName( 240 "org.apache.soap.Constants", 241 true, 242 Thread.currentThread().getContextClassLoader()); 243 } catch (Throwable ignored) { 244 Trc.ignoredException(ignored); 245 } 246 return null; 247 } 248 }); 249 if (cls2 != null) { 250 v.add(soap); 251 } 252 addresses = null; 253 addresses = new String [v.size()]; 254 for (int i = 0; i < v.size(); i++) { 255 addresses[i] = (String ) v.elementAt(i); 256 } 257 setUpAddresses = true; 258 } 259 } | Popular Tags |