1 55 56 package org.jboss.axis.configuration; 57 58 import org.jboss.axis.AxisEngine; 59 import org.jboss.axis.ConfigurationException; 60 import org.jboss.axis.EngineConfiguration; 61 import org.jboss.axis.Handler; 62 import org.jboss.axis.encoding.TypeMapping; 63 import org.jboss.axis.encoding.TypeMappingRegistry; 64 import org.jboss.axis.encoding.TypeMappingRegistryImpl; 65 import org.jboss.axis.handlers.soap.SOAPService; 66 67 import javax.xml.namespace.QName ; 68 import java.util.ArrayList ; 69 import java.util.HashMap ; 70 import java.util.Hashtable ; 71 import java.util.Iterator ; 72 73 86 public class SimpleProvider implements EngineConfiguration 87 { 88 91 HashMap handlers = new HashMap (); 92 95 HashMap transports = new HashMap (); 96 99 HashMap services = new HashMap (); 100 101 104 Hashtable globalOptions = null; 105 Handler globalRequest = null; 106 Handler globalResponse = null; 107 108 111 TypeMappingRegistry tmr = null; 112 113 116 EngineConfiguration defaultConfiguration = null; 117 private AxisEngine engine; 118 119 122 public SimpleProvider() 123 { 124 } 125 126 130 public SimpleProvider(EngineConfiguration defaultConfiguration) 131 { 132 this.defaultConfiguration = defaultConfiguration; 133 } 134 135 139 public void configureEngine(AxisEngine engine) throws ConfigurationException 140 { 141 this.engine = engine; 142 143 if (defaultConfiguration != null) 144 defaultConfiguration.configureEngine(engine); 145 146 for (Iterator i = services.values().iterator(); i.hasNext();) 147 { 148 ((SOAPService)i.next()).setEngine(engine); 149 } 150 } 151 152 155 public void writeEngineConfig(AxisEngine engine) throws ConfigurationException 156 { 157 } 158 159 162 public Hashtable getGlobalOptions() throws ConfigurationException 163 { 164 if (globalOptions != null) 165 return globalOptions; 166 167 if (defaultConfiguration != null) 168 return defaultConfiguration.getGlobalOptions(); 169 170 return null; 171 } 172 173 176 public Handler getGlobalResponse() throws ConfigurationException 177 { 178 if (globalResponse != null) 179 return globalResponse; 180 181 if (defaultConfiguration != null) 182 return defaultConfiguration.getGlobalResponse(); 183 184 return null; 185 } 186 187 190 public Handler getGlobalRequest() throws ConfigurationException 191 { 192 if (globalRequest != null) 193 return globalRequest; 194 195 if (defaultConfiguration != null) 196 return defaultConfiguration.getGlobalRequest(); 197 198 return null; 199 } 200 201 206 public TypeMappingRegistry getTypeMappingRegistry() throws ConfigurationException 207 { 208 if (tmr != null) 209 return tmr; 210 211 if (defaultConfiguration != null) 212 return defaultConfiguration.getTypeMappingRegistry(); 213 214 tmr = new TypeMappingRegistryImpl(); 217 return tmr; 218 } 219 220 public TypeMapping getTypeMapping(String encodingStyle) throws ConfigurationException 221 { 222 return (TypeMapping)getTypeMappingRegistry().getTypeMapping(encodingStyle); 223 } 224 225 public Handler getTransport(QName qname) throws ConfigurationException 226 { 227 Handler transport = (Handler)transports.get(qname); 228 if ((defaultConfiguration != null) && (transport == null)) 229 transport = defaultConfiguration.getTransport(qname); 230 return transport; 231 } 232 233 public SOAPService getService(QName qname) throws ConfigurationException 234 { 235 SOAPService service = (SOAPService)services.get(qname); 236 if ((defaultConfiguration != null) && (service == null)) 237 service = defaultConfiguration.getService(qname); 238 return service; 239 } 240 241 247 public SOAPService getServiceByNamespaceURI(String namespace) 248 throws ConfigurationException 249 { 250 SOAPService service = (SOAPService)services.get(new QName ("", namespace)); 251 if ((service == null) && (defaultConfiguration != null)) 252 service = defaultConfiguration.getServiceByNamespaceURI(namespace); 253 return service; 254 } 255 256 public Handler getHandler(QName qname) throws ConfigurationException 257 { 258 Handler handler = (Handler)handlers.get(qname); 259 if ((defaultConfiguration != null) && (handler == null)) 260 handler = defaultConfiguration.getHandler(qname); 261 return handler; 262 } 263 264 public void deployService(QName qname, SOAPService service) 265 { 266 services.put(qname, service); 267 if (engine != null) 268 service.setEngine(engine); 269 } 270 271 public void deployService(String name, SOAPService service) 272 { 273 deployService(new QName (null, name), service); 274 } 275 276 public void deployTransport(QName qname, Handler transport) 277 { 278 transports.put(qname, transport); 279 } 280 281 public void deployTransport(String name, Handler transport) 282 { 283 deployTransport(new QName (null, name), transport); 284 } 285 286 289 public Iterator getDeployedServices() throws ConfigurationException 290 { 291 ArrayList serviceDescs = new ArrayList (); 292 Iterator i = services.values().iterator(); 293 while (i.hasNext()) 294 { 295 SOAPService service = (SOAPService)i.next(); 296 serviceDescs.add(service.getServiceDescription()); 297 } 298 return serviceDescs.iterator(); 299 } 300 } 301 | Popular Tags |