Author: midon
Date: Mon Oct 20 16:29:39 2008
New Revision: 706455
URL: http://svn.apache.org/viewvc?rev=706455&view=rev
Log:
ODE-393: load modules on a service basis
Modified:
ode/branches/APACHE_ODE_1.X/axis2-war/src/main/webapp/WEB-INF/conf/axis2.xml
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/RampartBasicTest.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
Modified:
ode/branches/APACHE_ODE_1.X/axis2-war/src/main/webapp/WEB-INF/conf/axis2.xml
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/main/webapp/WEB-INF/conf/axis2.xml?rev=706455&r1=706454&r2=706455&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2-war/src/main/webapp/WEB-INF/conf/axis2.xml
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2-war/src/main/webapp/WEB-INF/conf/axis2.xml
Mon Oct 20 16:29:39 2008
@@ -214,8 +214,6 @@
<!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
<!--</moduleConfig>-->
- <module ref="rampart" />
-
<!-- ================================================= -->
<!-- Phases -->
<!-- ================================================= -->
Modified:
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/RampartBasicTest.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/RampartBasicTest.java?rev=706455&r1=706454&r2=706455&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/RampartBasicTest.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2-war/src/test/java/org/apache/ode/axis2/RampartBasicTest.java
Mon Oct 20 16:29:39 2008
@@ -19,21 +19,18 @@
package org.apache.ode.axis2;
-import org.apache.axis2.transport.http.SimpleHTTPServer;
-import org.testng.annotations.Test;
-import org.testng.annotations.Factory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.AfterMethod;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
-import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
+import org.apache.axis2.transport.http.server.SimpleHttpServer;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
-import java.net.URL;
import java.io.File;
-import java.io.FilenameFilter;
import java.io.FileFilter;
-import java.util.Arrays;
/**
*
@@ -59,28 +56,19 @@
@BeforeClass
protected void setUp() throws Exception {
- // mind the annotation above also
+ // mind the annotation above: start the server only once for all tests
startServer("TestRampartBasic", "webapp/WEB-INF/conf/axis2.xml");
-// try{
-// while(true){
-// synchronized (this){
-// wait(50);
-// }
-// }
-// }catch(Exception e){
-// e.printStackTrace();
-// }
}
@AfterClass
protected void tearDown() throws Exception {
- // simply change the annotation, see above
+ // mind the annotation above: start the server only once for all tests
super.tearDown();
}
@Test(dataProvider = "bundles")
public void executeProcess(String bundleName) throws Exception {
- if (server.isDeployed(new File(bundleName).getName())){
+ if (server.isDeployed(new File(bundleName).getName())) {
server.undeployProcess(bundleName);
}
server.deployProcess(bundleName);
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
URL:
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java?rev=706455&r1=706454&r2=706455&view=diff
==============================================================================
---
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
(original)
+++
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
Mon Oct 20 16:29:39 2008
@@ -31,6 +31,7 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.OutInAxisOperation;
import org.apache.axis2.description.OutOnlyAxisOperation;
+import org.apache.axis2.description.AxisModule;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
@@ -53,6 +54,7 @@
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.Namespaces;
import org.apache.ode.utils.WatchDog;
+import org.apache.ode.utils.GUID;
import org.apache.ode.utils.fs.FileUtils;
import org.apache.ode.utils.uuid.UUID;
import org.apache.ode.utils.wsdl.Messages;
@@ -233,8 +235,10 @@
serviceClient = new ServiceClient(_configContext, null);
_cachedClients.set(serviceClient);
}
-
serviceClient.setAxisService(_axisServiceWatchDog.getObserver().service);
+ AxisService anonymousService =
_axisServiceWatchDog.getObserver().anonymousService;
+ serviceClient.setAxisService(anonymousService);
serviceClient.setOptions(_axisOptionsWatchDog.getObserver().options);
+
applySecuritySettings(_axisOptionsWatchDog.getObserver().options,
serviceClient);
return serviceClient;
@@ -257,7 +261,8 @@
options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
policyDoc);
// make sure the proper modules are engaged
- if
(!serviceClient.getAxisService().getAxisConfiguration().isEngaged("rampart")){
+ if
(!serviceClient.getAxisService().getAxisConfiguration().isEngaged("rampart")
+ &&
!serviceClient.getAxisService().isEngaged("rampart")) {
serviceClient.engageModule("rampart");
}
} finally {
@@ -426,7 +431,8 @@
* this service-specific config file.
*/
private class ServiceFileObserver extends WatchDog.DefaultObserver {
- AxisService service;
+ String serviceName = "anonymous_service_" + new GUID().toString();
+ AxisService anonymousService;
File file;
private ServiceFileObserver(File file) {
@@ -434,16 +440,21 @@
}
public boolean isInitialized() {
- return service != null;
+ return anonymousService != null;
}
public void init() {
- service = new AxisService(_serviceName.toString());
+ // create an anonymous axis service that will be used by the
ServiceClient
+ // this service will be added to the AxisConfig so do not reuse
the name of the external service
+ // as it could blow up if the service is deployed in the same
axis2 instance
+ anonymousService = new AxisService(serviceName);
+ anonymousService.setParent(_axisConfig);
+
OutOnlyAxisOperation outOnlyOperation = new
OutOnlyAxisOperation(ServiceClient.ANON_OUT_ONLY_OP);
- service.addOperation(outOnlyOperation);
+ anonymousService.addOperation(outOnlyOperation);
OutInAxisOperation outInOperation = new
OutInAxisOperation(ServiceClient.ANON_OUT_IN_OP);
- service.addOperation(outInOperation);
+ anonymousService.addOperation(outInOperation);
}
public void onUpdate() {
@@ -455,11 +466,26 @@
InputStream ais = file.toURI().toURL().openStream();
if (ais != null) {
if (__log.isDebugEnabled()) __log.debug("Configuring
service " + _serviceName + " using: " + file);
- ServiceBuilder builder = new ServiceBuilder(ais,
_configContext, service);
+ ServiceBuilder builder = new ServiceBuilder(ais,
_configContext, anonymousService);
builder.populateService(builder.buildOM());
+ // do not allow the service.xml file to change the service
name
+ anonymousService.setName(serviceName);
+
+ // the service builder only updates the module list but do
not engage them
+ // module have to be engaged manually,
+ for (int i = 0; i < anonymousService.getModules().size();
i++) {
+ String moduleRef = (String)
anonymousService.getModules().get(i);
+ AxisModule module = _axisConfig.getModule(moduleRef);
+ if (module != null) {
+ anonymousService.engageModule(module);
+ } else {
+ throw new AxisFault("Unable to engage module : " +
moduleRef);
+ }
+ }
}
} catch (Exception e) {
- if (__log.isWarnEnabled()) __log.warn("Exception while
configuring service: " + _serviceName, e);
+ if (__log.isWarnEnabled()) __log.warn("Exception while
configuring service: " + _serviceName,e);
+ throw new RuntimeException("Exception while configuring
service: " + _serviceName,e);
}
}
}