1 57 58 package org.apache.wsif.providers.soap.apacheaxis; 59 60 import java.security.AccessController ; 61 import java.security.PrivilegedAction ; 62 import java.util.ArrayList ; 63 import java.util.Iterator ; 64 import java.util.List ; 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 85 public class WSIFDynamicProvider_ApacheAxis implements WSIFProvider { 86 87 private static final boolean axisAvailable = isAXISAvailable(); 88 private static final boolean jmsAvailable = isJMSAvailable(); 89 private static final String [] bindings = setUpBindingNamespaceURIs(); 90 private static final String [] addresses = setUpAddressNamespaceURIs(); 91 92 95 public WSIFDynamicProvider_ApacheAxis() { 96 Trc.entry(this); 97 if (axisAvailable && jmsAvailable) { 98 WSIFServiceImpl.addExtensionRegistry( 99 new org.apache.wsif.wsdl.extensions.jms.JMSExtensionRegistry()); 100 } 101 Trc.exit(); 102 } 103 104 108 public WSIFPort createDynamicWSIFPort( 109 Definition definition, 110 Service service, 111 Port port, 112 WSIFDynamicTypeMap wsifdynamictypemap) 113 throws WSIFException { 114 Trc.entry(this, definition, service, port, wsifdynamictypemap); 115 116 Binding binding = port.getBinding(); 117 List list = binding.getExtensibilityElements(); 118 119 WSIFPort wp = null; 120 for (Iterator i = list.iterator();(i.hasNext() && wp == null);) { 121 Object o = i.next(); 122 if (o instanceof SOAPBinding) { 123 wp = new WSIFPort_ApacheAxis( 124 definition, 125 port, 126 (SOAPBinding) o, 127 wsifdynamictypemap); 128 } 129 } 130 131 Trc.exit(wp); 132 return wp; 133 } 134 135 139 public String [] getBindingNamespaceURIs() { 140 Trc.entry(this); 141 Trc.exit(bindings); 142 return bindings; 143 } 144 145 149 public String [] getAddressNamespaceURIs() { 150 Trc.entry(this); 151 Trc.exit(addresses); 152 return addresses; 153 } 154 155 158 private static String [] setUpBindingNamespaceURIs() { 159 String [] bindings; 160 if (axisAvailable) { 161 bindings = 162 new String [] { WSIFAXISConstants.SOAP_BINDING_NAMESPACE }; 163 } else { 164 bindings = new String [0]; 165 } 166 Trc.event("available binding namespace URIs: ", bindings); 167 return bindings; 168 } 169 170 173 private static String [] setUpAddressNamespaceURIs() { 174 ArrayList l = new ArrayList (); 175 if (isAXISAvailable()) { 176 l.add(WSIFAXISConstants.SOAP_BINDING_NAMESPACE); 177 } 178 if (jmsAvailable) { 179 l.add(WSIFAXISConstants.JMS_TRANSPORT_URI); 180 } 181 String [] addresses = new String [l.size()]; 182 for (int i = 0; i < l.size(); i++) { 183 addresses[i] = (String ) l.get(i); 184 } 185 Trc.event("available address namespace URIs: ", addresses); 186 return addresses; 187 } 188 189 192 private static boolean isAXISAvailable() { 193 return isClassAvailable(WSIFAXISConstants.CLASS_IN_AXIS_JAR); 194 } 195 196 199 private static boolean isJMSAvailable() { 200 return isClassAvailable(WSIFAXISConstants.CLASS_IN_JMS_JAR); 201 } 202 203 206 private static boolean isClassAvailable(final String className) { 207 Class c = 208 (Class ) AccessController.doPrivileged(new PrivilegedAction () { 209 public Object run() { 210 try { 211 return Class.forName( 212 className, 213 true, 214 Thread.currentThread().getContextClassLoader()); 215 } catch (Throwable ignored) { 216 Trc.ignoredException(ignored); 217 } 218 return null; 219 } 220 }); 221 return c != null; 222 } 223 224 } | Popular Tags |