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 de...@apache.org on 2005/09/05 06:24:52 UTC
svn commit: r278669 - in /webservices/axis2/trunk/java/modules/core:
src/org/apache/axis2/deployment/ src/org/apache/axis2/description/
src/org/apache/axis2/engine/ test-resources/deployment/moduleConfig/
test/org/apache/axis2/engine/
Author: deepal
Date: Sun Sep 4 21:24:28 2005
New Revision: 278669
URL: http://svn.apache.org/viewcvs?rev=278669&view=rev
Log:
Fixing AXIS2-195
<moduleConfig name="Servie_module">
<parameter name="Servie_module_para" locked="false">N/A</parameter>
</moduleConfig>
Added:
webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/
webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/axis2.xml
webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/service1.xml
webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/engine/ModuleConfigTest.java
Modified:
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2.xml
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OperationDescription.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java
webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java Sun Sep 4 21:24:28 2005
@@ -12,8 +12,7 @@
import org.apache.axis2.deployment.util.PhasesInfo;
import org.apache.axis2.transport.TransportSender;
import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.*;
import javax.xml.stream.XMLStreamException;
import javax.xml.namespace.QName;
@@ -102,6 +101,8 @@
OMElement storages = config_element.getFirstChildWithName(new QName(AXIS_STORAGE)) ;
processAxisStorage(storages);
+ Iterator moduleConfigs = config_element.getChildrenWithName(new QName(MODULECONFIG));
+ processModuleConfig(moduleConfigs,axisConfiguration,axisConfiguration);
} catch (XMLStreamException e) {
@@ -416,7 +417,26 @@
String refName = moduleRefAttribute.getValue();
engine.addModule(new QName(refName));
}
+ }
+ protected void processModuleConfig(Iterator moduleConfigs ,
+ ParameterInclude parent, AxisConfiguration config)
+ throws DeploymentException {
+ while (moduleConfigs.hasNext()) {
+ OMElement moduleConfig = (OMElement) moduleConfigs.next();
+ OMAttribute moduleName_att = moduleConfig.getAttribute(
+ new QName(ATTNAME));
+ if(moduleName_att == null){
+ throw new DeploymentException("Invalid module configuration");
+ } else {
+ String module = moduleName_att.getValue();
+ ModuleConfiguration moduleConfiguration =
+ new ModuleConfiguration(new QName(module),parent);
+ Iterator paramters= moduleConfig.getChildrenWithName(new QName(PARAMETERST));
+ processParameters(paramters,moduleConfiguration,parent);
+ ((AxisConfigurationImpl)config).addModuleConfig(moduleConfiguration);
+ }
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java Sun Sep 4 21:24:28 2005
@@ -30,6 +30,7 @@
String LISTENERST = "listener";// paramater start tag
String HANDERST = "handler";
String MODULEST = "module";
+ String MODULECONFIG = "moduleConfig";
String PHASEST = "phase";
String PHASE_ORDER = "phaseOrder";
String TYPEMAPPINGST = "typeMapping";// typeMapping start tag
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java Sun Sep 4 21:24:28 2005
@@ -202,7 +202,6 @@
throws DeploymentException {
while (paramters.hasNext()) {
//this is to check whether some one has locked the parmter at the top level
- boolean allowedtoadd = true;
OMElement paramterElement = (OMElement) paramters.next();
Parameter paramter = new ParameterImpl();
@@ -346,7 +345,6 @@
}
return fileName;
}
-
/**
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java Sun Sep 4 21:24:28 2005
@@ -149,6 +149,9 @@
service.addOperation(opeartionDesc);
}
+ Iterator moduleConfigs = service_element.getChildrenWithName(new QName(MODULECONFIG));
+ processServiceModuleConfig(moduleConfigs,service,service);
+
} catch (XMLStreamException e) {
throw new DeploymentException(e);
@@ -182,7 +185,7 @@
op_descrip.setMessageExchangePattern(mep);
}
- //Opeartion Paramters
+ //Opeartion Paramters
Iterator paramters = operation.getChildrenWithName(
new QName(PARAMETERST));
processParameters(paramters,op_descrip,service);
@@ -211,10 +214,54 @@
info.setOperationPhases(op_descrip);
}
+ Iterator moduleConfigs = operation.getChildrenWithName(new QName(MODULECONFIG));
+ processOperationModuleConfig(moduleConfigs,op_descrip,op_descrip);
+
//adding the opeartion
operations.add(op_descrip);
}
return operations;
+ }
+
+
+ protected void processServiceModuleConfig(Iterator moduleConfigs ,
+ ParameterInclude parent, ServiceDescription service)
+ throws DeploymentException {
+ while (moduleConfigs.hasNext()) {
+ OMElement moduleConfig = (OMElement) moduleConfigs.next();
+ OMAttribute moduleName_att = moduleConfig.getAttribute(
+ new QName(ATTNAME));
+ if(moduleName_att == null){
+ throw new DeploymentException("Invalid module configuration");
+ } else {
+ String module = moduleName_att.getValue();
+ ModuleConfiguration moduleConfiguration =
+ new ModuleConfiguration(new QName(module),parent);
+ Iterator paramters= moduleConfig.getChildrenWithName(new QName(PARAMETERST));
+ processParameters(paramters,moduleConfiguration,parent);
+ service.addModuleConfig(moduleConfiguration);
+ }
+ }
+ }
+
+ protected void processOperationModuleConfig(Iterator moduleConfigs ,
+ ParameterInclude parent, OperationDescription opeartion)
+ throws DeploymentException {
+ while (moduleConfigs.hasNext()) {
+ OMElement moduleConfig = (OMElement) moduleConfigs.next();
+ OMAttribute moduleName_att = moduleConfig.getAttribute(
+ new QName(ATTNAME));
+ if(moduleName_att == null){
+ throw new DeploymentException("Invalid module configuration");
+ } else {
+ String module = moduleName_att.getValue();
+ ModuleConfiguration moduleConfiguration =
+ new ModuleConfiguration(new QName(module),parent);
+ Iterator paramters= moduleConfig.getChildrenWithName(new QName(PARAMETERST));
+ processParameters(paramters,moduleConfiguration,parent);
+ opeartion.addModuleConfig(moduleConfiguration);
+ }
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2.xml?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/axis2.xml Sun Sep 4 21:24:28 2005
@@ -88,6 +88,12 @@
<!-- Comment this to disable Addressing -->
<module ref="addressing"/>
+
+ <!--Configuring module , providing paramters for modules whether they refer or not-->
+ <!--<moduleConfig name="addressing">-->
+ <!--<parameter name="addressingPara" locked="false">N/A</parameter>-->
+ <!--</moduleConfig>-->
+
<!-- ================================================= -->
<!-- Phases -->
<!-- ================================================= -->
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OperationDescription.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OperationDescription.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OperationDescription.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OperationDescription.java Sun Sep 4 21:24:28 2005
@@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.HashMap;
/**
* @author chathura@opensource.lk
@@ -31,6 +32,8 @@
private ArrayList phasesInFaultFlow;
private ArrayList phasesOutFaultFlow;
+ private HashMap moduleConfigmap;
+
private int mep = MEP_CONSTANT_INVALID;
private ServiceDescription parent;
@@ -362,7 +365,21 @@
return false;
}
}
+ }
+
+ /**
+ * Adding module configuration , if there is moduleConfig tag in operation
+ * @param moduleConfiguration
+ */
+ public void addModuleConfig(ModuleConfiguration moduleConfiguration){
+ if(moduleConfigmap == null){
+ moduleConfigmap = new HashMap();
+ }
+ moduleConfigmap.put(moduleConfiguration.getModuleName(),moduleConfiguration);
+ }
+ public ModuleConfiguration getModuleConfig(QName moduleName){
+ return (ModuleConfiguration)moduleConfigmap.get(moduleName);
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ServiceDescription.java Sun Sep 4 21:24:28 2005
@@ -49,6 +49,8 @@
private Definition difDefinition = null;
+ private HashMap moduleConfigmap;
+
private AxisConfiguration parent;
//to store the wsdl definition , which is build at the deployment time
@@ -793,6 +795,21 @@
return false;
}
}
+ }
+
+ /**
+ * Adding module configuration , if there is moduleConfig tag in service
+ * @param moduleConfiguration
+ */
+ public void addModuleConfig(ModuleConfiguration moduleConfiguration){
+ if(moduleConfigmap == null){
+ moduleConfigmap = new HashMap();
+ }
+ moduleConfigmap.put(moduleConfiguration.getModuleName(),moduleConfiguration);
+ }
+ public ModuleConfiguration getModuleConfig(QName moduleName){
+ return (ModuleConfiguration)moduleConfigmap.get(moduleName);
}
+
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java?rev=278669&r1=278668&r2=278669&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfigurationImpl.java Sun Sep 4 21:24:28 2005
@@ -39,6 +39,8 @@
*/
private Hashtable errornesServices;
+ private HashMap moduleConfigmap;
+
//to keep axis2 storage class
private AxisStorage axisStorage;
@@ -451,5 +453,22 @@
public void addObservers(AxisObserver axisObserver){
observersList.add(axisObserver);
}
+
+
+ /**
+ * Adding module configuration , if there is moduleConfig tag in service
+ * @param moduleConfiguration
+ */
+ public void addModuleConfig(ModuleConfiguration moduleConfiguration){
+ if(moduleConfigmap == null){
+ moduleConfigmap = new HashMap();
+ }
+ moduleConfigmap.put(moduleConfiguration.getModuleName(),moduleConfiguration);
+ }
+
+ public ModuleConfiguration getModuleConfig(QName moduleName){
+ return (ModuleConfiguration)moduleConfigmap.get(moduleName);
+ }
+
}
Added: webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/axis2.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/axis2.xml?rev=278669&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/axis2.xml (added)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/axis2.xml Sun Sep 4 21:24:28 2005
@@ -0,0 +1,35 @@
+<axisconfig name="AxisJava2.0">
+
+
+ <moduleConfig name="testModule">
+ <parameter name="testModulePara" locked="false">N/A</parameter>
+ </moduleConfig>
+
+ <moduleConfig name="testModule2">
+ <parameter name="testModulePara2" locked="false">N/A</parameter>
+ </moduleConfig>
+
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="TransportIn"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch"/>
+ <phase name="PostDispatch"/>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="userphase1"/>
+ </phaseOrder>
+</axisconfig>
+
Added: webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/service1.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/service1.xml?rev=278669&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/service1.xml (added)
+++ webservices/axis2/trunk/java/modules/core/test-resources/deployment/moduleConfig/service1.xml Sun Sep 4 21:24:28 2005
@@ -0,0 +1,14 @@
+<service name="Service1">
+ <description>
+ This is a testing service , to test the system is working or not
+ </description>
+
+ <moduleConfig name="Servie_module">
+ <parameter name="Servie_module_para" locked="false">N/A</parameter>
+ </moduleConfig>
+ <operation name="echoString">
+ <moduleConfig name="Op_Module">
+ <parameter name="Op_Module_para" locked="false">N/A</parameter>
+ </moduleConfig>
+ </operation>
+</service>
\ No newline at end of file
Added: webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/engine/ModuleConfigTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/engine/ModuleConfigTest.java?rev=278669&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/engine/ModuleConfigTest.java (added)
+++ webservices/axis2/trunk/java/modules/core/test/org/apache/axis2/engine/ModuleConfigTest.java Sun Sep 4 21:24:28 2005
@@ -0,0 +1,100 @@
+package org.apache.axis2.engine;
+
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.ServiceBuilder;
+import org.apache.axis2.description.ModuleConfiguration;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ServiceDescription;
+import org.apache.axis2.description.OperationDescription;
+import junit.framework.TestCase;
+
+import javax.xml.namespace.QName;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+*
+*/
+
+/**
+ * Author: Deepal Jayasinghe
+ * Date: Sep 1, 2005
+ * Time: 3:42:25 PM
+ */
+public class ModuleConfigTest extends TestCase {
+
+ AxisConfiguration ar;
+ String repo ="./test-resources/deployment/moduleConfig";
+
+
+
+ public void testModuleConfigAtAxisConfig() {
+ try {
+ ConfigurationContextFactory builder = new ConfigurationContextFactory();
+ ar = builder.buildConfigurationContext(repo).getAxisConfiguration();
+ ModuleConfiguration moduleConfiguration =
+ ((AxisConfigurationImpl)ar).getModuleConfig(new QName("testModule"));
+ assertNotNull(moduleConfiguration);
+ Parameter para = moduleConfiguration.getParameter("testModulePara");
+ assertNotNull(para);
+
+ moduleConfiguration =
+ ((AxisConfigurationImpl)ar).getModuleConfig(new QName("testModule2"));
+ assertNotNull(moduleConfiguration);
+ para = moduleConfiguration.getParameter("testModulePara2");
+ assertNotNull(para);
+ } catch (DeploymentException e) {
+ e.printStackTrace();
+ fail("This can not fail with this DeploymentException " + e) ;
+ }
+ }
+
+
+ public void testModuleConfigAtService() {
+ try {
+ ConfigurationContextFactory builder = new ConfigurationContextFactory();
+ ar = builder.buildConfigurationContext(repo).getAxisConfiguration();
+
+
+ ServiceDescription service = new ServiceDescription();
+ service.setParent(ar);
+ InputStream in = new FileInputStream(repo + "/service1.xml");
+ ServiceBuilder sbuilder = new ServiceBuilder(in,null,service);
+ sbuilder.populateService();
+
+ ModuleConfiguration moduleConfiguration = service.getModuleConfig(new QName("Servie_module"));
+ assertNotNull(moduleConfiguration);
+ Parameter para = moduleConfiguration.getParameter("Servie_module_para");
+ assertNotNull(para);
+
+ OperationDescription op = service.getOperation("echoString");
+ assertNotNull(op);
+
+ moduleConfiguration = op.getModuleConfig(new QName("Op_Module"));
+ assertNotNull(moduleConfiguration);
+ para = moduleConfiguration.getParameter("Op_Module_para");
+ assertNotNull(para);
+
+
+ } catch (DeploymentException e) {
+ fail("This can not fail with this DeploymentException " + e) ;
+ } catch (FileNotFoundException e) {
+ fail("This can not fail with this FileNotFoundException " + e) ;
+ }
+ }
+}