Author: glen
Date: Tue Jan 15 09:06:30 2008
New Revision: 12286
Log:
Add bidirectional parameter transfer capability.
Some code cleanup.
Modified:
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1Deployer.java
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1InOutMessageReceiver.java
Modified:
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1Deployer.java
==============================================================================
---
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1Deployer.java
(original)
+++
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1Deployer.java
Tue Jan 15 09:06:30 2008
@@ -3,6 +3,7 @@
import org.apache.axis.ConfigurationException;
import org.apache.axis.MessageContext;
import org.apache.axis.configuration.FileProvider;
+import org.apache.axis.deployment.wsdd.WSDDService;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.server.AxisServer;
import org.apache.axis.utils.DOM2Writer;
@@ -32,6 +33,8 @@
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.MalformedURLException;
+import java.util.Enumeration;
+import java.util.Hashtable;
import java.util.Iterator;
/*
@@ -51,16 +54,29 @@
*/
/**
- * This is a Deployer which adapts Axis1 services to Axis2. It works by
- * embedding an instance of Axis1's AxisEngine, and building proxy Axis2
- * services for each Axis1 service in a WSDD file. Each of those Axis2
- * services uses the Axis1InOutMessageReceiver, which handles the runtime
- * work of pulling in a message from Axis2 (after any Modules have run)
- * and pushing it into Axis1 via the Local transport.
+ * This is a Deployer which adapts Axis1 services to Axis2. It works by
embedding an instance of
+ * Axis1's AxisEngine, and building proxy Axis2 services for each Axis1
service in a WSDD file. Each
+ * of those Axis2 services uses the Axis1InOutMessageReceiver, which handles
the runtime work of
+ * pulling in a message from Axis2 (after any Modules have run) and pushing it
into Axis1 via the
+ * Local transport.
* <p/>
* Please contact Glen Daniels ([EMAIL PROTECTED]) for any questions.
*/
public class Axis1Deployer implements Deployer {
+
+ public class Axis1ParameterObserver implements ParameterObserver {
+ ServiceDesc serviceDesc;
+
+ public Axis1ParameterObserver(ServiceDesc serviceDesc) {
+ this.serviceDesc = serviceDesc;
+ }
+
+ public void parameterChanged(String name, Object value) {
+ System.out.println("pushing param " + name);
+ serviceDesc.setProperty(name, value);
+ }
+ }
+
protected static final Log log = LogFactory.getLog(Axis1Deployer.class);
public static class A1WSDLSupplier implements WSDLSupplier {
@@ -123,12 +139,14 @@
FileProvider config = new
FileProvider(deploymentFileData.getAbsolutePath());
AxisServer server = new AxisServer(config);
WSDLSupplier supplier = new A1WSDLSupplier(server);
-
- Iterator services = config.getDeployedServices();
+
+ config.getDeployedServices(); // ensure everything's set up
+
+ WSDDService[] services = config.getDeployment().getServices();
AxisServiceGroup serviceGroup = new AxisServiceGroup();
serviceGroup.addParameter("service.axis1.server", server);
- while (services.hasNext()) {
- ServiceDesc service = (ServiceDesc) services.next();
+ for (int i = 0; i < services.length; i++) {
+ ServiceDesc service = services[i].getServiceDesc();
log.info("Deploying Axis1 service -- " + service.getName());
AxisService axisService;
@@ -157,7 +175,7 @@
service.setDefaultNamespace(null);
}
log.info("Couldn't process WSDL for Axis1 service '" +
serviceName +
- "', defaulting to passthrough mode.");
+ "', defaulting to passthrough mode.");
// Couldn't process WSDL (RPC/enc?), so set up passthrough
axisService = new AxisService(serviceName);
@@ -168,17 +186,26 @@
AxisOperation op = new InOutAxisOperation(new
QName("invokeAxis1Service"));
op.setDocumentation("This operation is a 'passthrough' for
all operations in " +
- "an RPC/encoded Axis1 service.");
+ "an RPC/encoded Axis1 service.");
axisService.addOperation(op);
}
axisService.setName(service.getName());
axisService.setClassLoader(classLoader);
+ // Put all the parameters from the A1 service into the A2
service
+ Hashtable params = services[i].getParametersTable();
+ Enumeration paramKeys = params.keys();
+ while (paramKeys.hasMoreElements()) {
+ String key = (String)paramKeys.nextElement();
+ System.out.println("Copying param '" + key + "'");
+ axisService.addParameter(key, params.get(key));
+ }
+
Axis1InOutMessageReceiver receiver = new
Axis1InOutMessageReceiver();
AxisConfiguration axisConfig =
configCtx.getAxisConfiguration();
PhasesInfo phaseInfo = axisConfig.getPhasesInfo();
- for (Iterator i = axisService.getOperations(); i.hasNext();) {
- AxisOperation op = (AxisOperation)i.next();
+ for (Iterator ops = axisService.getOperations();
ops.hasNext();) {
+ AxisOperation op = (AxisOperation)ops.next();
op.setMessageReceiver(receiver);
phaseInfo.setOperationPhases(op);
}
@@ -188,6 +215,7 @@
// Add service type
axisService.addParameter("serviceType", "axis1_service");
axisService.setFileName(deploymentFileData.getFile().toURL());
+ axisService.addParameterObserver(new
Axis1ParameterObserver(service));
serviceGroup.addService(axisService);
}
serviceGroup.setServiceGroupName(deploymentFileData.getName());
@@ -204,8 +232,8 @@
throw new DeploymentException(e);
} catch (MalformedURLException e) {
throw new DeploymentException(e);
- } finally{
- if (threadClassLoader != null) {
+ } finally {
+ if (threadClassLoader != null) {
Thread.currentThread().setContextClassLoader(threadClassLoader);
}
}
@@ -227,7 +255,7 @@
axisConfig.removeServiceGroup(fileName);
configCtx.removeServiceGroupContext(asg);
log.info(Messages.getMessage(DeploymentErrorMsgs.SERVICE_REMOVED,
- fileName));
+ fileName));
} else {
axisConfig.removeFaultyService(fileName);
}
Modified:
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1InOutMessageReceiver.java
==============================================================================
---
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1InOutMessageReceiver.java
(original)
+++
trunk/commons/deployers/axis1deployer/src/main/java/a1deployer/Axis1InOutMessageReceiver.java
Tue Jan 15 09:06:30 2008
@@ -107,6 +107,13 @@
outMessage.setEnvelope(builder.getSOAPEnvelope());
}
+ /**
+ * Translate an Axis1.X fault into an Axis2 fault by serializing /
deserializing
+ *
+ * @param fault Axis1 fault
+ * @return an Axis2 fault
+ * @noinspection ThrowableInstanceNeverThrown
+ */
public static AxisFault translateFault(org.apache.axis.AxisFault fault) {
try {
org.apache.axis.Message msg = new Message(fault);
_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev