1 16 package org.apache.axis.deployment.wsdd; 17 18 import org.apache.axis.EngineConfiguration; 19 import org.apache.axis.Handler; 20 import org.apache.axis.components.logger.LogFactory; 21 import org.apache.axis.deployment.wsdd.providers.WSDDBsfProvider; 22 import org.apache.axis.deployment.wsdd.providers.WSDDComProvider; 23 import org.apache.axis.deployment.wsdd.providers.WSDDHandlerProvider; 24 import org.apache.axis.deployment.wsdd.providers.WSDDJavaCORBAProvider; 25 import org.apache.axis.deployment.wsdd.providers.WSDDJavaEJBProvider; 26 import org.apache.axis.deployment.wsdd.providers.WSDDJavaMsgProvider; 27 import org.apache.axis.deployment.wsdd.providers.WSDDJavaRMIProvider; 28 import org.apache.axis.deployment.wsdd.providers.WSDDJavaRPCProvider; 29 import org.apache.axis.utils.JavaUtils; 30 import org.apache.axis.utils.Messages; 31 import org.apache.commons.discovery.ResourceNameIterator; 32 import org.apache.commons.discovery.resource.ClassLoaders; 33 import org.apache.commons.discovery.resource.names.DiscoverServiceNames; 34 import org.apache.commons.logging.Log; 35 36 import javax.xml.namespace.QName ; 37 import java.util.Hashtable ; 38 39 40 52 public abstract class WSDDProvider 53 { 54 protected static Log log = 55 LogFactory.getLog(WSDDProvider.class.getName()); 56 57 private static final String PLUGABLE_PROVIDER_FILENAME = 59 "org.apache.axis.deployment.wsdd.Provider"; 60 61 62 private static Hashtable providers = new Hashtable (); 63 64 static { 65 providers.put(WSDDConstants.QNAME_JAVARPC_PROVIDER, new WSDDJavaRPCProvider()); 66 providers.put(WSDDConstants.QNAME_JAVAMSG_PROVIDER, new WSDDJavaMsgProvider()); 67 providers.put(WSDDConstants.QNAME_HANDLER_PROVIDER, new WSDDHandlerProvider()); 68 providers.put(WSDDConstants.QNAME_EJB_PROVIDER, new WSDDJavaEJBProvider()); 69 providers.put(WSDDConstants.QNAME_COM_PROVIDER, new WSDDComProvider()); 70 providers.put(WSDDConstants.QNAME_BSF_PROVIDER, new WSDDBsfProvider()); 71 providers.put(WSDDConstants.QNAME_CORBA_PROVIDER, new WSDDJavaCORBAProvider()); 72 providers.put(WSDDConstants.QNAME_RMI_PROVIDER, new WSDDJavaRMIProvider()); 73 try { 74 loadPluggableProviders(); 75 } catch (Throwable t){ 76 String msg=t + JavaUtils.LS + JavaUtils.stackToString(t); 77 log.info(Messages.getMessage("exception01",msg)); 78 } 79 } 80 81 97 private static void loadPluggableProviders() { 98 ClassLoader clzLoader = WSDDProvider.class.getClassLoader(); 99 ClassLoaders loaders = new ClassLoaders(); 100 loaders.put(clzLoader); 101 DiscoverServiceNames dsn = new DiscoverServiceNames(loaders); 102 ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); 103 while (iter.hasNext()) { 104 String className = iter.nextResourceName(); 105 try { 106 Object o = Class.forName(className).newInstance(); 107 if (o instanceof WSDDProvider) { 108 WSDDProvider provider = (WSDDProvider) o; 109 String providerName = provider.getName(); 110 QName q = new QName (WSDDConstants.URI_WSDD_JAVA, providerName); 111 providers.put(q, provider); 112 } 113 } catch (Exception e) { 114 String msg=e + JavaUtils.LS + JavaUtils.stackToString(e); 115 log.info(Messages.getMessage("exception01",msg)); 116 continue; 117 } 118 } 119 } 120 121 126 public static void registerProvider(QName uri, WSDDProvider prov) 127 { 128 providers.put(uri, prov); 129 } 130 131 135 public WSDDOperation[] getOperations() 136 { 137 return null; 138 } 139 140 145 public WSDDOperation getOperation(String name) 146 { 147 return null; 148 } 149 150 156 public static Handler getInstance(QName providerType, 157 WSDDService service, 158 EngineConfiguration registry) 159 throws Exception 160 { 161 if (providerType == null) 162 throw new WSDDException(Messages.getMessage("nullProvider00")); 163 164 WSDDProvider provider = (WSDDProvider)providers.get(providerType); 165 if (provider == null) { 166 throw new WSDDException(Messages.getMessage("noMatchingProvider00", 167 providerType.toString())); 168 } 169 170 return provider.newProviderInstance(service, registry); 171 } 172 173 179 public abstract Handler newProviderInstance(WSDDService service, 180 EngineConfiguration registry) 181 throws Exception ; 182 183 public abstract String getName(); 184 } 185 | Popular Tags |