You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2002/01/23 18:57:08 UTC
cvs commit: xml-axis/java/test/wsdd TestUndeployment.java
gdaniels 02/01/23 09:57:08
Modified: java/src/org/apache/axis Tag: config-work AxisEngine.java
ConfigurationProvider.java
java/src/org/apache/axis/configuration Tag: config-work
FileProvider.java NullProvider.java
XMLStringProvider.java
java/src/org/apache/axis/deployment Tag: config-work
DeploymentRegistry.java
SimpleDeploymentManager.java
java/src/org/apache/axis/utils Tag: config-work Admin.java
java/test/wsdd Tag: config-work TestUndeployment.java
Log:
First bit of WSDD refactoring, checked in on the "config-work" branch
so that Glyn and I can share the work in here over the next few days,
and others can look at it without breaking the main branch.
Submitted by : Glyn Normington
Revision Changes Path
No revision
No revision
1.63.2.1 +44 -75 xml-axis/java/src/org/apache/axis/AxisEngine.java
Index: AxisEngine.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
retrieving revision 1.63
retrieving revision 1.63.2.1
diff -u -r1.63 -r1.63.2.1
--- AxisEngine.java 3 Jan 2002 17:12:36 -0000 1.63
+++ AxisEngine.java 23 Jan 2002 17:57:07 -0000 1.63.2.1
@@ -98,11 +98,13 @@
public static final String PROP_SYNC_CONFIG = "syncConfiguration";
public static final String PROP_SEND_XSI = "sendXsiTypes";
+ // Default admin. password
+ private static final String DEFAULT_ADMIN_PASSWORD = "admin";
+
/** Our go-to guy for configuration... */
protected transient ConfigurationProvider configProvider;
- protected DeploymentRegistry myRegistry =
- new SimpleWsddDeploymentManager();
+ protected DeploymentRegistry myRegistry;
/** Has the user changed the password yet? */
protected boolean _hasSafePassword = false;
@@ -119,8 +121,6 @@
*/
private Session session = new SimpleSession();
- protected WSDDGlobalConfiguration myGlobalConfig = null;
-
/**
* What actor URIs hold for the entire engine?
*/
@@ -154,7 +154,7 @@
* No-arg constructor.
*
*/
- public AxisEngine()
+ private AxisEngine()
{
// !!! Set up default configuration?
init();
@@ -178,6 +178,8 @@
category.debug(JavaUtils.getMessage("enter00", "AxisEngine::init"));
}
+ myRegistry = configProvider.getDeploymentRegistry();
+
getTypeMappingRegistry().setParent(SOAPTypeMappingRegistry.getSingleton());
try {
@@ -185,6 +187,8 @@
} catch (Exception e) {
throw new InternalException(e);
}
+
+
if (category.isDebugEnabled()) {
category.debug(JavaUtils.getMessage("exit00", "AxisEngine::init"));
@@ -248,7 +252,7 @@
{
return myRegistry;
}
-
+
public TypeMappingRegistry getTypeMappingRegistry()
{
TypeMappingRegistry tmr = null;
@@ -268,25 +272,13 @@
public Handler getGlobalRequest()
throws Exception
{
- Handler h = null;
- if (myGlobalConfig != null) {
- WSDDRequestFlow reqFlow = myGlobalConfig.getRequestFlow();
- if (reqFlow != null)
- h = reqFlow.getInstance(myRegistry);
- }
- return h;
+ return myRegistry.getGlobalRequest();
}
public Handler getGlobalResponse()
throws Exception
{
- Handler h = null;
- if (myGlobalConfig != null) {
- WSDDResponseFlow respFlow = myGlobalConfig.getResponseFlow();
- if (respFlow != null)
- h = respFlow.getInstance(myRegistry);
- }
- return h;
+ return myRegistry.getGlobalResponse();
}
public ArrayList getActorURIs()
@@ -356,76 +348,74 @@
/**
* List of options which should be converted from Strings to Booleans
- * automatically.
+ * automatically. Note that these options are common to all XML
+ * web services.
*/
- static String [] booleanOptions = new String [] {
+ private static final String [] BOOLEAN_OPTIONS = new String [] {
PROP_DOMULTIREFS, PROP_SEND_XSI, PROP_XML_DECL
};
/**
- * Deploy a WSDD document to this engine. This will either add or
- * remove Handlers/Services/Transports/etc. depending on whether the
- * WSDD is a <deployment> or an <undeployment>
- *
- * @param doc the WSDD document to deploy.
- * @throws DeploymentException if there is a problem.
+ * Normalise the engine's options.
+ * <p>
+ * Convert boolean options from String to Boolean and default
+ * any ommitted boolean options to TRUE. Default the admin.
+ * password.
*/
- public void deployWSDD(WSDDDocument doc) throws DeploymentException
- {
- myRegistry.deploy(doc);
- myGlobalConfig = myRegistry.getGlobalConfiguration();
- if (myGlobalConfig != null)
- setOptions(myGlobalConfig.getParametersTable());
-
+ private void normaliseOptions() {
// Convert boolean options to Booleans so we don't need to use
// string comparisons. Default is "true".
- for (int i = 0; i < booleanOptions.length; i++) {
- Object val = getOption(booleanOptions[i]);
+ for (int i = 0; i < BOOLEAN_OPTIONS.length; i++) {
+ Object val = getOption(BOOLEAN_OPTIONS[i]);
if (val != null) {
if (val instanceof Boolean)
continue;
if (val instanceof String &&
"false".equalsIgnoreCase((String)val)) {
- setOption(booleanOptions[i], Boolean.FALSE);
+ setOption(BOOLEAN_OPTIONS[i], Boolean.FALSE);
continue;
}
}
// If it was null or not "false"...
- setOption(booleanOptions[i], Boolean.TRUE);
+ setOption(BOOLEAN_OPTIONS[i], Boolean.TRUE);
}
// Deal with admin password's default value.
if (getOption(PROP_PASSWORD) == null) {
- setOption(PROP_PASSWORD, "admin");
+ setOption(PROP_PASSWORD, DEFAULT_ADMIN_PASSWORD);
} else {
setAdminPassword((String)getOption(PROP_PASSWORD));
}
}
-
+
+ /**
+ * (Re-)load the global options from the registry.
+ */
+ public void refreshGlobalOptions() throws DeploymentException {
+ Hashtable globalOptions = myRegistry.getGlobalOptions();
+ if (globalOptions != null)
+ setOptions(globalOptions);
+
+ normaliseOptions();
+ }
+
/**
- * Deploy a Handler into our handler registry
+ * Deploy a Handler into our handler registry.
*/
public void deployHandler(String key, Handler handler)
throws DeploymentException
{
- handler.setName(key);
- WSDDDocument doc = (WSDDDocument)myRegistry.getConfigDocument();
- WSDDHandler newHandler = new WSDDHandler();
- newHandler.setName(key);
- newHandler.setType(new QName(WSDDConstants.WSDD_JAVA,
- handler.getClass().getName()));
- newHandler.setOptionsHashtable(handler.getOptions());
- myRegistry.deployHandler(newHandler);
+ myRegistry.deployHandler(key, handler);
}
/**
- * Undeploy (remove) a Handler from the handler registry
+ * Undeploy (remove) a Handler from our handler registry.
*/
public void undeployHandler(String key)
throws DeploymentException
{
- myRegistry.removeDeployedItem(new QName("", key));
+ myRegistry.undeployHandler(key);
}
/**
@@ -434,29 +424,8 @@
public void deployService(String key, SOAPService service)
throws DeploymentException
{
- category.info(JavaUtils.getMessage("deployService00", key, this.toString()));
- service.setName(key);
service.setEngine(this);
-
- WSDDService newService = new WSDDService();
- newService.setName(key);
- newService.setOptionsHashtable(service.getOptions());
- newService.setCachedService(service);
-
- Handler pivot = service.getPivotHandler();
- if (pivot == null) {
- throw new DeploymentException(JavaUtils.getMessage("noPivot01"));
- }
-
- if (pivot instanceof RPCProvider) {
- newService.setProviderQName(WSDDConstants.JAVARPC_PROVIDER);
- } else if (pivot instanceof MsgProvider) {
- newService.setProviderQName(WSDDConstants.JAVAMSG_PROVIDER);
- } else {
- newService.setProviderQName(WSDDConstants.HANDLER_PROVIDER);
- newService.setParameter("handlerClass", pivot.getClass().getName());
- }
- myRegistry.deployService(newService);
+ myRegistry.deployService(key, service);
}
/**
@@ -465,7 +434,7 @@
public void undeployService(String key)
throws DeploymentException
{
- myRegistry.undeployService(new QName("", key));
+ myRegistry.undeployService(key);
}
/**
1.3.4.1 +4 -0 xml-axis/java/src/org/apache/axis/ConfigurationProvider.java
Index: ConfigurationProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/ConfigurationProvider.java,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -r1.3 -r1.3.4.1
--- ConfigurationProvider.java 30 Oct 2001 16:46:34 -0000 1.3
+++ ConfigurationProvider.java 23 Jan 2002 17:57:07 -0000 1.3.4.1
@@ -54,6 +54,8 @@
*/
package org.apache.axis;
+import org.apache.axis.deployment.DeploymentRegistry;
+
/**
* ConfigurationProvider is an interface which represents a source of
* configuration information for an AxisEngine. Concrete implementations
@@ -81,4 +83,6 @@
* @throws Exception if there was a problem
*/
public void writeEngineConfig(AxisEngine engine) throws Exception;
+
+ public DeploymentRegistry getDeploymentRegistry();
}
No revision
No revision
1.14.2.1 +9 -1 xml-axis/java/src/org/apache/axis/configuration/FileProvider.java
Index: FileProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/configuration/FileProvider.java,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- FileProvider.java 9 Jan 2002 15:10:57 -0000 1.14
+++ FileProvider.java 23 Jan 2002 17:57:07 -0000 1.14.2.1
@@ -58,6 +58,8 @@
import org.apache.axis.AxisEngine;
import org.apache.axis.ConfigurationProvider;
import org.apache.axis.deployment.wsdd.WSDDDocument;
+import org.apache.axis.deployment.wsdd.SimpleWsddDeploymentManager;
+import org.apache.axis.deployment.DeploymentRegistry;
import org.apache.axis.utils.Admin;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -127,6 +129,11 @@
this.searchClasspath = searchClasspath;
}
+ public DeploymentRegistry getDeploymentRegistry()
+ {
+ return new SimpleWsddDeploymentManager();
+ }
+
public void configureEngine(AxisEngine engine) throws Exception
{
if (myInputStream == null) {
@@ -145,7 +152,8 @@
}
WSDDDocument doc = new WSDDDocument(XMLUtils.newDocument(myInputStream));
- engine.deployWSDD(doc);
+ engine.getDeploymentRegistry().deploy(doc);
+ engine.refreshGlobalOptions();
myInputStream = null;
}
1.1.4.1 +8 -0 xml-axis/java/src/org/apache/axis/configuration/NullProvider.java
Index: NullProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/configuration/NullProvider.java,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- NullProvider.java 31 Oct 2001 23:50:19 -0000 1.1
+++ NullProvider.java 23 Jan 2002 17:57:07 -0000 1.1.4.1
@@ -57,6 +57,8 @@
import org.apache.axis.AxisEngine;
import org.apache.axis.ConfigurationProvider;
+import org.apache.axis.deployment.wsdd.SimpleWsddDeploymentManager;
+import org.apache.axis.deployment.DeploymentRegistry;
/**
* A do-nothing ConfigurationProvider
@@ -65,6 +67,12 @@
*/
public class NullProvider implements ConfigurationProvider
{
+ public DeploymentRegistry getDeploymentRegistry()
+ {
+ // yeuch!
+ return new SimpleWsddDeploymentManager();
+ }
+
public void configureEngine(AxisEngine engine) throws Exception
{
}
1.4.4.1 +7 -0 xml-axis/java/src/org/apache/axis/configuration/XMLStringProvider.java
Index: XMLStringProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/configuration/XMLStringProvider.java,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- XMLStringProvider.java 30 Oct 2001 16:46:35 -0000 1.4
+++ XMLStringProvider.java 23 Jan 2002 17:57:07 -0000 1.4.4.1
@@ -57,6 +57,8 @@
import org.apache.axis.AxisEngine;
import org.apache.axis.ConfigurationProvider;
+import org.apache.axis.deployment.wsdd.SimpleWsddDeploymentManager;
+import org.apache.axis.deployment.DeploymentRegistry;
import org.apache.axis.utils.Admin;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Document;
@@ -85,6 +87,11 @@
public XMLStringProvider(String xmlConfiguration)
{
this.xmlConfiguration = xmlConfiguration;
+ }
+
+ public DeploymentRegistry getDeploymentRegistry()
+ {
+ return new SimpleWsddDeploymentManager();
}
public void configureEngine(AxisEngine engine) throws Exception
No revision
No revision
1.19.2.1 +53 -9 xml-axis/java/src/org/apache/axis/deployment/DeploymentRegistry.java
Index: DeploymentRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/DeploymentRegistry.java,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- DeploymentRegistry.java 28 Dec 2001 22:32:36 -0000 1.19
+++ DeploymentRegistry.java 23 Jan 2002 17:57:08 -0000 1.19.2.1
@@ -55,6 +55,7 @@
package org.apache.axis.deployment;
import org.apache.axis.Handler;
+import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.deployment.wsdd.WSDDGlobalConfiguration;
import org.apache.axis.deployment.wsdd.WSDDDocument;
import org.apache.axis.encoding.TypeMappingRegistry;
@@ -71,6 +72,7 @@
import java.io.OutputStream;
import java.io.Serializable;
import java.util.Enumeration;
+import java.util.Hashtable;
/**
* The DeploymentRegistry abstract class takes the place of the
@@ -86,14 +88,6 @@
throws DeploymentException;
/**
- * retrieve the global configuration for the axis engine
- * @return XXX
- * @throws DeploymentException XXX
- */
- public abstract WSDDGlobalConfiguration getGlobalConfiguration()
- throws DeploymentException;
-
- /**
* retrieve an instance of the named handler
* @param qname XXX
* @return XXX
@@ -200,6 +194,15 @@
throws DeploymentException;
/**
+ * deploy the given service
+ * @param key XXX
+ * @param service XXX
+ * @throws DeploymentException XXX
+ */
+ public abstract void deployService(String key, SOAPService service)
+ throws DeploymentException;
+
+ /**
* deploy the given handler
* @param item XXX
* @throws DeploymentException XXX
@@ -208,6 +211,15 @@
throws DeploymentException;
/**
+ * Deploy a Handler into the registry.
+ * @param key XXX
+ * @param handler XXX
+ * @throws DeploymentException XXX
+ */
+ public abstract void deployHandler(String key, Handler handler)
+ throws DeploymentException;
+
+ /**
* deploy the given transport
* @param item XXX
* @throws DeploymentException XXX
@@ -230,7 +242,15 @@
*/
public abstract void undeployHandler(QName qname)
throws DeploymentException;
-
+
+ /**
+ * Remove the specified handler.
+ * @param key XXX
+ * @throws DeploymentException XXX
+ */
+ public abstract void undeployHandler(String key)
+ throws DeploymentException;
+
/**
* remove the given service
* @param qname XXX
@@ -239,6 +259,14 @@
public abstract void undeployService(QName qname)
throws DeploymentException;
+ /**
+ * remove the given service
+ * @param key XXX
+ * @throws DeploymentException XXX
+ */
+ public abstract void undeployService(String key)
+ throws DeploymentException;
+
/**
* remove the given transport
* @param qname XXX
@@ -374,4 +402,20 @@
*/
public abstract Enumeration getTransports() throws DeploymentException ;
+ /**
+ * Returns a global request handler.
+ */
+ public abstract Handler getGlobalRequest()
+ throws Exception;
+
+ /**
+ * Returns a global response handler.
+ */
+ public abstract Handler getGlobalResponse()
+ throws Exception;
+
+ /**
+ * Returns the global configuration options.
+ */
+ public abstract Hashtable getGlobalOptions();
}
1.24.2.1 +115 -12 xml-axis/java/src/org/apache/axis/deployment/SimpleDeploymentManager.java
Index: SimpleDeploymentManager.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/SimpleDeploymentManager.java,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -u -r1.24 -r1.24.2.1
--- SimpleDeploymentManager.java 28 Dec 2001 22:32:36 -0000 1.24
+++ SimpleDeploymentManager.java 23 Jan 2002 17:57:08 -0000 1.24.2.1
@@ -57,6 +57,9 @@
import org.apache.axis.Constants;
import org.apache.axis.Handler;
import org.apache.axis.InternalException;
+import org.apache.axis.handlers.soap.SOAPService;
+import org.apache.axis.providers.java.RPCProvider;
+import org.apache.axis.providers.java.MsgProvider;
import org.apache.axis.deployment.wsdd.WSDDGlobalConfiguration;
import org.apache.axis.deployment.wsdd.WSDDDocument;
import org.apache.axis.deployment.wsdd.WSDDHandler;
@@ -64,9 +67,13 @@
import org.apache.axis.deployment.wsdd.WSDDService;
import org.apache.axis.deployment.wsdd.WSDDTransport;
import org.apache.axis.deployment.wsdd.WSDDTypeMapping;
+import org.apache.axis.deployment.wsdd.WSDDRequestFlow;
+import org.apache.axis.deployment.wsdd.WSDDResponseFlow;
import org.apache.axis.encoding.SOAPTypeMappingRegistry;
import org.apache.axis.encoding.TypeMappingRegistry;
import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.utils.JavaUtils;
+import org.apache.log4j.Category;
import org.w3c.dom.Document;
import javax.xml.rpc.namespace.QName;
@@ -85,6 +92,9 @@
public class SimpleDeploymentManager
extends DeploymentRegistry
{
+ static Category category =
+ Category.getInstance(SimpleDeploymentManager.class.getName());
+
/** Our global configuration */
WSDDGlobalConfiguration globalConfig;
@@ -138,18 +148,6 @@
}
/**
- * Return the global configuration
- *
- * @return our global configuration
- * @throws DeploymentException XXX
- */
- public WSDDGlobalConfiguration getGlobalConfiguration()
- throws DeploymentException
- {
- return globalConfig;
- }
-
- /**
* Set the global configuration
* @param global XXX
*/
@@ -453,4 +451,109 @@
return transports == null ? null : transports.keys();
}
+ /**
+ * Deploy a Handler into the registry.
+ */
+ public void deployHandler(String key, Handler handler)
+ throws DeploymentException
+ {
+ handler.setName(key);
+ WSDDDocument doc = (WSDDDocument)getConfigDocument();
+ WSDDHandler newHandler = new WSDDHandler();
+ newHandler.setName(key);
+ newHandler.setType(new QName(WSDDConstants.WSDD_JAVA,
+ handler.getClass().getName()));
+ newHandler.setOptionsHashtable(handler.getOptions());
+ deployHandler(newHandler);
+ }
+
+ /**
+ * Undeploy (remove) a Handler from the registry.
+ */
+ public void undeployHandler(String key)
+ throws DeploymentException
+ {
+ removeDeployedItem(new QName("", key));
+ }
+
+ /**
+ * Deploy a Service into the registry.
+ */
+ public void deployService(String key, SOAPService service)
+ throws DeploymentException
+ {
+ category.info(JavaUtils.getMessage("deployService00", key, this.toString()));
+ service.setName(key);
+
+ WSDDService newService = new WSDDService();
+ newService.setName(key);
+ newService.setOptionsHashtable(service.getOptions());
+ newService.setCachedService(service);
+
+ Handler pivot = service.getPivotHandler();
+ if (pivot == null) {
+ throw new DeploymentException(JavaUtils.getMessage("noPivot01"));
+ }
+
+ if (pivot instanceof RPCProvider) {
+ newService.setProviderQName(WSDDConstants.JAVARPC_PROVIDER);
+ } else if (pivot instanceof MsgProvider) {
+ newService.setProviderQName(WSDDConstants.JAVAMSG_PROVIDER);
+ } else {
+ newService.setProviderQName(WSDDConstants.HANDLER_PROVIDER);
+ newService.setParameter("handlerClass", pivot.getClass().getName());
+ }
+ deployService(newService);
+ }
+
+ /**
+ * Undeploy (remove) a Service from the registry.
+ */
+ public void undeployService(String key)
+ throws DeploymentException
+ {
+ undeployService(new QName("", key));
+ }
+
+ /**
+ * Returns a global request handler.
+ */
+ public Handler getGlobalRequest()
+ throws Exception
+ {
+ Handler h = null;
+ if (globalConfig != null) {
+ WSDDRequestFlow reqFlow = globalConfig.getRequestFlow();
+ if (reqFlow != null)
+ h = reqFlow.getInstance(this);
+ }
+ return h;
+ }
+
+ /**
+ * Returns a global response handler.
+ */
+ public Handler getGlobalResponse()
+ throws Exception
+ {
+ Handler h = null;
+ if (globalConfig != null) {
+ WSDDResponseFlow respFlow = globalConfig.getResponseFlow();
+ if (respFlow != null)
+ h = respFlow.getInstance(this);
+ }
+ return h;
+ }
+
+ /**
+ * Returns the global configuration options.
+ */
+ public Hashtable getGlobalOptions()
+ {
+ Hashtable go = null;
+ if (globalConfig != null) {
+ go = globalConfig.getParametersTable();
+ }
+ return go;
+ }
}
No revision
No revision
1.92.2.1 +3 -2 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.92
retrieving revision 1.92.2.1
diff -u -r1.92 -r1.92.2.1
--- Admin.java 17 Dec 2001 00:57:41 -0000 1.92
+++ Admin.java 23 Jan 2002 17:57:08 -0000 1.92.2.1
@@ -306,8 +306,9 @@
Document doc = null ;
WSDDDocument wsddDoc = new WSDDDocument(root);
- engine.deployWSDD(wsddDoc);
-
+ engine.getDeploymentRegistry().deploy(wsddDoc);
+ engine.refreshGlobalOptions();
+
engine.saveConfiguration();
doc = XMLUtils.newDocument();
No revision
No revision
1.2.4.1 +2 -1 xml-axis/java/test/wsdd/TestUndeployment.java
Index: TestUndeployment.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdd/TestUndeployment.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- TestUndeployment.java 3 Dec 2001 03:36:06 -0000 1.2
+++ TestUndeployment.java 23 Jan 2002 17:57:08 -0000 1.2.4.1
@@ -72,7 +72,8 @@
InputStream is = new StringBufferInputStream(undeployDoc);
WSDDDocument doc = new WSDDDocument(XMLUtils.newDocument(is));
- server.deployWSDD(doc);
+ server.getDeploymentRegistry().deploy(doc);
+ server.refreshGlobalOptions();
handler = server.getHandler("other");
assertNull("Undeployed handler is still available", handler);