1 16 17 package org.apache.axis.configuration; 18 19 import org.apache.axis.AxisEngine; 20 import org.apache.axis.ConfigurationException; 21 import org.apache.axis.EngineConfiguration; 22 import org.apache.axis.Handler; 23 import org.apache.axis.encoding.TypeMapping; 24 import org.apache.axis.encoding.TypeMappingRegistry; 25 import org.apache.axis.encoding.TypeMappingRegistryImpl; 26 import org.apache.axis.handlers.soap.SOAPService; 27 28 import javax.xml.namespace.QName ; 29 import java.util.ArrayList ; 30 import java.util.HashMap ; 31 import java.util.Hashtable ; 32 import java.util.Iterator ; 33 import java.util.List ; 34 35 48 public class SimpleProvider implements EngineConfiguration 49 { 50 51 HashMap handlers = new HashMap (); 52 53 HashMap transports = new HashMap (); 54 55 HashMap services = new HashMap (); 56 57 58 Hashtable globalOptions = null; 59 Handler globalRequest = null; 60 Handler globalResponse = null; 61 List roles = new ArrayList (); 62 63 64 TypeMappingRegistry tmr = null; 65 66 67 EngineConfiguration defaultConfiguration = null; 68 private AxisEngine engine; 69 70 73 public SimpleProvider() { 74 } 75 76 80 public SimpleProvider(EngineConfiguration defaultConfiguration) { 81 this.defaultConfiguration = defaultConfiguration; 82 } 83 84 89 public SimpleProvider(TypeMappingRegistry typeMappingRegistry) { 90 this.tmr = typeMappingRegistry; 91 } 92 93 97 public void configureEngine(AxisEngine engine) throws ConfigurationException 98 { 99 this.engine = engine; 100 101 if (defaultConfiguration != null) 102 defaultConfiguration.configureEngine(engine); 103 104 for (Iterator i = services.values().iterator(); i.hasNext(); ) { 105 ((SOAPService)i.next()).setEngine(engine); 106 } 107 } 108 109 112 public void writeEngineConfig(AxisEngine engine) throws ConfigurationException 113 { 114 } 115 116 119 public Hashtable getGlobalOptions() throws ConfigurationException { 120 if (globalOptions != null) 121 return globalOptions; 122 123 if (defaultConfiguration != null) 124 return defaultConfiguration.getGlobalOptions(); 125 126 return null; 127 } 128 129 134 public void setGlobalOptions(Hashtable options) { 135 globalOptions = options; 136 } 137 138 141 public Handler getGlobalRequest() throws ConfigurationException { 142 if (globalRequest != null) 143 return globalRequest; 144 145 if (defaultConfiguration != null) 146 return defaultConfiguration.getGlobalRequest(); 147 148 return null; 149 } 150 151 156 public void setGlobalRequest(Handler globalRequest) { 157 this.globalRequest = globalRequest; 158 } 159 160 163 public Handler getGlobalResponse() throws ConfigurationException { 164 if (globalResponse != null) 165 return globalResponse; 166 167 if (defaultConfiguration != null) 168 return defaultConfiguration.getGlobalResponse(); 169 170 return null; 171 } 172 173 178 public void setGlobalResponse(Handler globalResponse) { 179 this.globalResponse = globalResponse; 180 } 181 182 188 public TypeMappingRegistry getTypeMappingRegistry() throws ConfigurationException { 189 if (tmr != null) 190 return tmr; 191 192 if (defaultConfiguration != null) 193 return defaultConfiguration.getTypeMappingRegistry(); 194 195 tmr = new TypeMappingRegistryImpl(); 198 return tmr; 199 } 200 201 public TypeMapping getTypeMapping(String encodingStyle) throws ConfigurationException { 202 return (TypeMapping)getTypeMappingRegistry().getTypeMapping(encodingStyle); 203 } 204 205 public Handler getTransport(QName qname) throws ConfigurationException { 206 Handler transport = (Handler)transports.get(qname); 207 if ((defaultConfiguration != null) && (transport == null)) 208 transport = defaultConfiguration.getTransport(qname); 209 return transport; 210 } 211 212 public SOAPService getService(QName qname) throws ConfigurationException { 213 SOAPService service = (SOAPService)services.get(qname); 214 if ((defaultConfiguration != null) && (service == null)) 215 service = defaultConfiguration.getService(qname); 216 return service; 217 } 218 219 225 public SOAPService getServiceByNamespaceURI(String namespace) 226 throws ConfigurationException { 227 SOAPService service = (SOAPService)services.get(new QName ("",namespace)); 228 if ((service == null) && (defaultConfiguration != null)) 229 service = defaultConfiguration.getServiceByNamespaceURI(namespace); 230 return service; 231 } 232 233 public Handler getHandler(QName qname) throws ConfigurationException { 234 Handler handler = (Handler)handlers.get(qname); 235 if ((defaultConfiguration != null) && (handler == null)) 236 handler = defaultConfiguration.getHandler(qname); 237 return handler; 238 } 239 240 public void deployService(QName qname, SOAPService service) 241 { 242 services.put(qname, service); 243 if (engine != null) 244 service.setEngine(engine); 245 } 246 247 public void deployService(String name, SOAPService service) 248 { 249 deployService(new QName (null, name), service); 250 } 251 252 public void deployTransport(QName qname, Handler transport) 253 { 254 transports.put(qname, transport); 255 } 256 257 public void deployTransport(String name, Handler transport) 258 { 259 deployTransport(new QName (null, name), transport); 260 } 261 262 265 public Iterator getDeployedServices() throws ConfigurationException { 266 ArrayList serviceDescs = new ArrayList (); 267 Iterator i = services.values().iterator(); 268 while (i.hasNext()) { 269 SOAPService service = (SOAPService)i.next(); 270 serviceDescs.add(service.getServiceDescription()); 271 } 272 return serviceDescs.iterator(); 273 } 274 275 283 public void setRoles(List roles) { 284 this.roles = roles; 285 } 286 287 292 public void addRole(String role) { 293 roles.add(role); 294 } 295 296 301 public void removeRole(String role) { 302 roles.remove(role); 303 } 304 305 311 public List getRoles() { 312 return roles; 313 } 314 } 315 | Popular Tags |