package org.jboss.axis.configuration;
import org.jboss.axis.AxisEngine;
import org.jboss.axis.ConfigurationException;
import org.jboss.axis.EngineConfiguration;
import org.jboss.axis.Handler;
import org.jboss.axis.encoding.TypeMapping;
import org.jboss.axis.encoding.TypeMappingRegistry;
import org.jboss.axis.encoding.TypeMappingRegistryImpl;
import org.jboss.axis.handlers.soap.SOAPService;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
public class SimpleProvider implements EngineConfiguration
{
HashMap handlers = new HashMap();
HashMap transports = new HashMap();
HashMap services = new HashMap();
Hashtable globalOptions = null;
Handler globalRequest = null;
Handler globalResponse = null;
TypeMappingRegistry tmr = null;
EngineConfiguration defaultConfiguration = null;
private AxisEngine engine;
public SimpleProvider()
{
}
public SimpleProvider(EngineConfiguration defaultConfiguration)
{
this.defaultConfiguration = defaultConfiguration;
}
public void configureEngine(AxisEngine engine) throws ConfigurationException
{
this.engine = engine;
if (defaultConfiguration != null)
defaultConfiguration.configureEngine(engine);
for (Iterator i = services.values().iterator(); i.hasNext();)
{
((SOAPService)i.next()).setEngine(engine);
}
}
public void writeEngineConfig(AxisEngine engine) throws ConfigurationException
{
}
public Hashtable getGlobalOptions() throws ConfigurationException
{
if (globalOptions != null)
return globalOptions;
if (defaultConfiguration != null)
return defaultConfiguration.getGlobalOptions();
return null;
}
public Handler getGlobalResponse() throws ConfigurationException
{
if (globalResponse != null)
return globalResponse;
if (defaultConfiguration != null)
return defaultConfiguration.getGlobalResponse();
return null;
}
public Handler getGlobalRequest() throws ConfigurationException
{
if (globalRequest != null)
return globalRequest;
if (defaultConfiguration != null)
return defaultConfiguration.getGlobalRequest();
return null;
}
public TypeMappingRegistry getTypeMappingRegistry() throws ConfigurationException
{
if (tmr != null)
return tmr;
if (defaultConfiguration != null)
return defaultConfiguration.getTypeMappingRegistry();
tmr = new TypeMappingRegistryImpl();
return tmr;
}
public TypeMapping getTypeMapping(String encodingStyle) throws ConfigurationException
{
return (TypeMapping)getTypeMappingRegistry().getTypeMapping(encodingStyle);
}
public Handler getTransport(QName qname) throws ConfigurationException
{
Handler transport = (Handler)transports.get(qname);
if ((defaultConfiguration != null) && (transport == null))
transport = defaultConfiguration.getTransport(qname);
return transport;
}
public SOAPService getService(QName qname) throws ConfigurationException
{
SOAPService service = (SOAPService)services.get(qname);
if ((defaultConfiguration != null) && (service == null))
service = defaultConfiguration.getService(qname);
return service;
}
public SOAPService getServiceByNamespaceURI(String namespace)
throws ConfigurationException
{
SOAPService service = (SOAPService)services.get(new QName("", namespace));
if ((service == null) && (defaultConfiguration != null))
service = defaultConfiguration.getServiceByNamespaceURI(namespace);
return service;
}
public Handler getHandler(QName qname) throws ConfigurationException
{
Handler handler = (Handler)handlers.get(qname);
if ((defaultConfiguration != null) && (handler == null))
handler = defaultConfiguration.getHandler(qname);
return handler;
}
public void deployService(QName qname, SOAPService service)
{
services.put(qname, service);
if (engine != null)
service.setEngine(engine);
}
public void deployService(String name, SOAPService service)
{
deployService(new QName(null, name), service);
}
public void deployTransport(QName qname, Handler transport)
{
transports.put(qname, transport);
}
public void deployTransport(String name, Handler transport)
{
deployTransport(new QName(null, name), transport);
}
public Iterator getDeployedServices() throws ConfigurationException
{
ArrayList serviceDescs = new ArrayList();
Iterator i = services.values().iterator();
while (i.hasNext())
{
SOAPService service = (SOAPService)i.next();
serviceDescs.add(service.getServiceDescription());
}
return serviceDescs.iterator();
}
}