1 57 58 package org.apache.wsif.providers.ejb; 59 60 import java.security.AccessController ; 61 import java.security.PrivilegedAction ; 62 import java.util.Iterator ; 63 import java.util.List ; 64 65 import javax.wsdl.Binding; 66 import javax.wsdl.Definition; 67 import javax.wsdl.Port; 68 import javax.wsdl.Service; 69 70 import org.apache.wsif.WSIFException; 71 import org.apache.wsif.WSIFPort; 72 import org.apache.wsif.logging.Trc; 73 import org.apache.wsif.providers.WSIFDynamicTypeMap; 74 import org.apache.wsif.spi.WSIFProvider; 75 import org.apache.wsif.wsdl.extensions.ejb.EJBBinding; 76 77 85 public class WSIFDynamicProvider_EJB implements WSIFProvider { 86 87 private static final String ejb = "http://schemas.xmlsoap.org/wsdl/ejb/"; 88 private static String [] bindings = new String [0]; 89 private static String [] addresses = new String [0]; 90 private static boolean setUpBindings = false; 91 private static boolean setUpAddresses = false; 92 93 public WSIFDynamicProvider_EJB() { 94 Trc.entry(this); 95 if (!setUpBindings) { 96 setUpBindingNamespaceURIs(); 97 } 98 if (!setUpAddresses) { 99 setUpAddressNamespaceURIs(); 100 } 101 Trc.exit(); 102 } 103 104 108 public WSIFPort createDynamicWSIFPort( 109 Definition def, 110 Service service, 111 Port port, 112 WSIFDynamicTypeMap typeMap) 113 throws WSIFException { 114 Trc.entry(this, def, service, port, typeMap); 115 116 Binding binding = port.getBinding(); 118 List exs = binding.getExtensibilityElements(); 119 for (Iterator i = exs.iterator(); i.hasNext();) { 120 Object o = i.next(); 121 if (o instanceof EJBBinding) { 122 WSIFPort wp = new WSIFPort_EJB(def, port, typeMap); 124 Trc.exit(wp); 125 return wp; 126 } 127 } 128 129 Trc.exit(); 131 return null; 132 } 133 134 138 public String [] getBindingNamespaceURIs() { 139 Trc.entry(this); 140 Trc.exit(bindings); 141 return bindings; 142 } 143 144 148 public String [] getAddressNamespaceURIs() { 149 Trc.entry(this); 150 Trc.exit(addresses); 151 return addresses; 152 } 153 154 private void setUpBindingNamespaceURIs() { 155 Class cls = 158 (Class ) AccessController.doPrivileged(new PrivilegedAction () { 159 public Object run() { 160 try { 161 return Class.forName( 162 "javax.ejb.EJBHome", 163 true, 164 Thread.currentThread().getContextClassLoader()); 165 } catch (Throwable ignored) { 166 Trc.ignoredException(ignored); 167 } 168 return null; 169 } 170 }); 171 if (cls != null) { 172 bindings = new String [] { ejb }; 173 } 174 setUpBindings = true; 175 } 176 177 private void setUpAddressNamespaceURIs() { 178 Class cls = 181 (Class ) AccessController.doPrivileged(new PrivilegedAction () { 182 public Object run() { 183 try { 184 return Class.forName( 185 "javax.ejb.EJBHome", 186 true, 187 Thread.currentThread().getContextClassLoader()); 188 } catch (Throwable ignored) { 189 Trc.ignoredException(ignored); 190 } 191 return null; 192 } 193 }); 194 195 if (cls != null) { 196 addresses = new String [] { ejb }; 197 } 198 setUpAddresses = true; 199 } 200 } | Popular Tags |