1 55 package org.jboss.axis.deployment.wsdd; 56 57 import org.apache.commons.discovery.ResourceNameIterator; 58 import org.apache.commons.discovery.resource.ClassLoaders; 59 import org.apache.commons.discovery.resource.names.DiscoverServiceNames; 60 import org.jboss.axis.EngineConfiguration; 61 import org.jboss.axis.Handler; 62 import org.jboss.axis.deployment.wsdd.providers.WSDDComProvider; 63 import org.jboss.axis.deployment.wsdd.providers.WSDDHandlerProvider; 64 import org.jboss.axis.deployment.wsdd.providers.WSDDJavaMsgProvider; 65 import org.jboss.axis.deployment.wsdd.providers.WSDDJavaRPCProvider; 66 import org.jboss.axis.utils.JavaUtils; 67 import org.jboss.axis.utils.Messages; 68 import org.jboss.logging.Logger; 69 70 import javax.xml.namespace.QName ; 71 import java.util.Hashtable ; 72 73 74 86 public abstract class WSDDProvider 87 { 88 private static Logger log = Logger.getLogger(WSDDProvider.class.getName()); 89 90 private static final String PLUGABLE_PROVIDER_FILENAME = 92 "org.jboss.axis.deployment.wsdd.Provider"; 93 94 97 private static Hashtable providers = new Hashtable (); 98 99 static 100 { 101 providers.put(WSDDConstants.QNAME_JAVARPC_PROVIDER, new WSDDJavaRPCProvider()); 102 providers.put(WSDDConstants.QNAME_JAVAMSG_PROVIDER, new WSDDJavaMsgProvider()); 103 providers.put(WSDDConstants.QNAME_HANDLER_PROVIDER, new WSDDHandlerProvider()); 104 providers.put(WSDDConstants.QNAME_COM_PROVIDER, new WSDDComProvider()); 105 try 106 { 107 loadPluggableProviders(); 108 } 109 catch (Throwable t) 110 { 111 String msg = t + JavaUtils.LS + JavaUtils.stackToString(t); 112 log.info(Messages.getMessage("exception01", msg)); 113 } 114 } 115 116 132 private static void loadPluggableProviders() 133 { 134 ClassLoader clzLoader = WSDDProvider.class.getClassLoader(); 135 ClassLoaders loaders = new ClassLoaders(); 136 loaders.put(clzLoader); 137 DiscoverServiceNames dsn = new DiscoverServiceNames(loaders); 138 ResourceNameIterator iter = dsn.findResourceNames(PLUGABLE_PROVIDER_FILENAME); 139 while (iter.hasNext()) 140 { 141 String className = iter.nextResourceName(); 142 try 143 { 144 Object o = Class.forName(className).newInstance(); 145 if (o instanceof WSDDProvider) 146 { 147 WSDDProvider provider = (WSDDProvider)o; 148 String providerName = provider.getName(); 149 QName q = new QName (WSDDConstants.URI_WSDD_JAVA, providerName); 150 providers.put(q, provider); 151 } 152 } 153 catch (Exception e) 154 { 155 String msg = e + JavaUtils.LS + JavaUtils.stackToString(e); 156 log.info(Messages.getMessage("exception01", msg)); 157 continue; 158 } 159 } 160 } 161 162 166 public static void registerProvider(QName uri, WSDDProvider prov) 167 { 168 providers.put(uri, prov); 169 } 170 171 174 public WSDDOperation[] getOperations() 175 { 176 return null; 177 } 178 179 183 public WSDDOperation getOperation(String name) 184 { 185 return null; 186 } 187 188 193 public static Handler getInstance(QName providerType, 194 WSDDService service, 195 EngineConfiguration registry) 196 throws Exception 197 { 198 if (providerType == null) 199 throw new WSDDException(Messages.getMessage("nullProvider00")); 200 201 WSDDProvider provider = (WSDDProvider)providers.get(providerType); 202 if (provider == null) 203 { 204 throw new WSDDException(Messages.getMessage("noMatchingProvider00", 205 providerType.toString())); 206 } 207 208 return provider.newProviderInstance(service, registry); 209 } 210 211 216 public abstract Handler newProviderInstance(WSDDService service, 217 EngineConfiguration registry) 218 throws Exception ; 219 220 public abstract String getName(); 221 } 222 | Popular Tags |