You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by gd...@apache.org on 2007/06/21 19:16:29 UTC
svn commit: r549554 - in /webservices/axis2/trunk/java/modules/kernel:
src/org/apache/axis2/client/ src/org/apache/axis2/context/
src/org/apache/axis2/deployment/ src/org/apache/axis2/description/
src/org/apache/axis2/engine/ src/org/apache/axis2/i18n/...
Author: gdaniels
Date: Thu Jun 21 10:16:27 2007
New Revision: 549554
URL: http://svn.apache.org/viewvc?view=rev&rev=549554
Log:
* Refactor module handling up to AxisDescription level, remove a bunch of repeated code from service, operation, etc.
* Add isParameterTrue() to AxisDescription for convenient programming
* Clean up various spelling errors, spacing probs, JavaDocs, and naming issues.
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisServiceGroup.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/HandlerDescription.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/phaseresolver/PhaseResolver.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java
webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/ModuleDisengagementTest.java
webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/SameServiceAddingTest.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java Thu Jun 21 10:16:27 2007
@@ -44,6 +44,8 @@
import org.apache.axis2.engine.ListenerManager;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.logging.Log;
import javax.wsdl.Definition;
@@ -58,7 +60,8 @@
* configure various aspects of the service access.
*/
public class ServiceClient {
-
+ protected static final Log log = LogFactory.getLog(ServiceClient.class);
+
/**
* Base name used for a service created without an existing configuration.
*/
@@ -345,7 +348,11 @@
public void disengageModule(String moduleName) {
AxisModule module = axisConfig.getModule(moduleName);
if (module != null) {
- axisService.disengageModule(module);
+ try {
+ axisService.disengageModule(module);
+ } catch (AxisFault axisFault) {
+ log.error(axisFault);
+ }
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java Thu Jun 21 10:16:27 2007
@@ -73,7 +73,7 @@
axisConfigurator.engageGlobalModules();
axisConfigurator.loadServices();
addModuleService(configContext);
- initApplicationScopeServices(configContext);
+// initApplicationScopeServices(configContext);
axisConfig.setStart(true);
return configContext;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Thu Jun 21 10:16:27 2007
@@ -451,7 +451,7 @@
ArrayList serviceList,
URL serviceLocation,
AxisConfiguration axisConfig) throws AxisFault {
- serviceGroup.setParent(axisConfig);
+// serviceGroup.setParent(axisConfig);
// module from services.xml at serviceGroup level
ArrayList groupModules = serviceGroup.getModuleRefs();
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java Thu Jun 21 10:16:27 2007
@@ -309,7 +309,7 @@
for (int i = 0; i < ops.size(); i++) {
AxisOperation operationDesc = (AxisOperation) ops.get(i);
- ArrayList wsamappings = operationDesc.getWsamappingList();
+ ArrayList wsamappings = operationDesc.getWSAMappingList();
if (wsamappings == null) {
continue;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java Thu Jun 21 10:16:27 2007
@@ -73,14 +73,13 @@
}
}
}
- AxisServiceGroup sericeGroup = new AxisServiceGroup(axisConfig);
- sericeGroup.setServiceGroupClassLoader(
- deploymentFileData.getClassLoader());
+ AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig);
+ serviceGroup.setServiceGroupClassLoader(deploymentFileData.getClassLoader());
ArrayList serviceList = archiveReader.processServiceGroup(
deploymentFileData.getAbsolutePath(), deploymentFileData,
- sericeGroup, isDirectory, wsdlservice,
+ serviceGroup, isDirectory, wsdlservice,
configCtx);
- DeploymentEngine.addServiceGroup(sericeGroup,
+ DeploymentEngine.addServiceGroup(serviceGroup,
serviceList,
deploymentFileData.getFile().toURL(),
deploymentFileData,
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java Thu Jun 21 10:16:27 2007
@@ -18,6 +18,8 @@
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.util.Utils;
+import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.modules.Module;
@@ -31,6 +33,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Collection;
+import java.util.Map;
public abstract class AxisDescription implements ParameterInclude,
DescriptionConstants {
@@ -43,6 +46,8 @@
private HashMap children;
+ protected Map engagedModules;
+
// Holds the documentation details for each element
private String documentation;
@@ -101,6 +106,14 @@
return param.getValue();
}
+ public boolean isParameterTrue(String name) {
+ Parameter param = getParameter(name);
+ if (param == null) {
+ return false;
+ }
+ return JavaUtils.isTrue(param.getValue());
+ }
+
public ArrayList getParameters() {
return parameterInclude.getParameters();
}
@@ -397,12 +410,74 @@
* Engage a Module at this level
*
* @param axisModule the Module to engage
+ * @throws AxisFault if there's a problem engaging
*/
- public abstract void engageModule(AxisModule axisModule) throws AxisFault;
+ public void engageModule(AxisModule axisModule) throws AxisFault {
+ engageModule(axisModule, this);
+ }
- public abstract boolean isEngaged(String moduleName);
+ /**
+ * Engage a Module at this level, keeping track of which level the engage was originally
+ * called from. This is meant for internal use only.
+ *
+ * @param axisModule module to engage
+ * @param source the AxisDescription which originally called engageModule()
+ * @throws AxisFault if there's a problem engaging
+ */
+ public void engageModule(AxisModule axisModule, AxisDescription source) throws AxisFault {
+ if (engagedModules == null) engagedModules = new HashMap();
+ String moduleName = axisModule.getName();
+ for (Iterator iterator = engagedModules.values().iterator(); iterator.hasNext();) {
+ String existing = ((AxisModule)iterator.next()).getName();
+ if (!Utils.checkVersion(moduleName, existing)) {
+ throw new AxisFault(Messages.getMessage("mismatchedModuleVersions",
+ getClass().getName(),
+ moduleName,
+ existing));
+ }
+ }
+
+ // If we have anything specific to do, let that happen
+ onEngage(axisModule, source);
+
+ engagedModules.put(axisModule.getName(), axisModule);
+ }
-// public Collection getEngagedModules() { return null; }
+ protected void onEngage(AxisModule module, AxisDescription engager) throws AxisFault {
+ // Default version does nothing, feel free to override
+ }
+
+ static Collection NULL_MODULES = new ArrayList(0);
+ public Collection getEngagedModules() {
+ return engagedModules == null ? NULL_MODULES : engagedModules.values();
+ }
+
+ /**
+ * Check if a given module is engaged at this level.
+ *
+ * @param moduleName module to investigate.
+ * @return true if engaged, false if not.
+ * TODO: Handle versions? isEngaged("addressing") should be true even for versioned modulename...
+ */
+ public boolean isEngaged(String moduleName) {
+ if (engagedModules != null) {
+ return engagedModules.keySet().contains(moduleName);
+ }
+ return false;
+ }
+
+ public void disengageModule(AxisModule module) throws AxisFault {
+ if ((module == null) || (engagedModules == null)) return;
+ String moduleName = module.getName();
+ if (isEngaged(moduleName)) {
+ onDisengage(module);
+ engagedModules.remove(module.getName());
+ }
+ }
+
+ protected void onDisengage(AxisModule module) throws AxisFault {
+ // Base version does nothing
+ }
private Policy getApplicablePolicy(AxisDescription axisDescription) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisEndpoint.java Thu Jun 21 10:16:27 2007
@@ -110,7 +110,6 @@
public boolean isEngaged(String moduleName) {
throw new UnsupportedOperationException("axisMessage.isEngaged() is not supported");
-
}
public OMElement toWSDL20(OMNamespace wsdl, OMNamespace tns, OMNamespace whttp, String epr) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Thu Jun 21 10:16:27 2007
@@ -19,11 +19,13 @@
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
-import org.apache.axis2.modules.Module;
import org.apache.axis2.phaseresolver.PhaseResolver;
-import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.wsdl.SOAPHeaderMessage;
-import org.apache.ws.commons.schema.*;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaImport;
+import org.apache.ws.commons.schema.XmlSchemaInclude;
+import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import javax.xml.namespace.QName;
import java.util.ArrayList;
@@ -51,14 +53,8 @@
private ArrayList modulerefs;
private String partName = Java2WSDLConstants.PARAMETERS;
- /**
- * list of engaged modules
- */
- private ArrayList engagedModules = new ArrayList();
-
// private PolicyInclude policyInclude;
-
public String getMessagePartName() {
return messagePartName;
}
@@ -141,7 +137,7 @@
XmlSchemaObjectCollection includes = schema.getIncludes();
if (includes != null) {
Iterator includesIter = includes.getIterator();
- Object object = null;
+ Object object;
while (includesIter.hasNext()) {
object = includesIter.next();
if (object instanceof XmlSchemaImport) {
@@ -190,46 +186,15 @@
}
/**
- *
* We do not support adding module operations when engaging a module to an AxisMessage
+ *
* @param axisModule AxisModule to engage
+ * @param engager
* @throws AxisFault something went wrong
*/
- public void engageModule(AxisModule axisModule) throws AxisFault {
- if (axisModule == null) {
- return;
- }
- Iterator module_itr = engagedModules.iterator();
- boolean isEngagable;
- String moduleName = axisModule.getName();
- while (module_itr.hasNext()) {
- AxisModule module = (AxisModule) module_itr.next();
- String modu = module.getName();
- isEngagable = org.apache.axis2.util.Utils.checkVersion(moduleName, modu);
- if (!isEngagable) {
- return ;
- }
- }
-
- Module module = axisModule.getModule();
- if (module != null) {
- module.engageNotify(this);
- }
- AxisConfiguration axisConfig = getAxisConfiguration();
- PhaseResolver phaseResolver = new PhaseResolver(axisConfig);
+ public void onEngage(AxisModule axisModule, AxisDescription engager) throws AxisFault {
+ PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration());
phaseResolver.engageModuleToMessage(this, axisModule);
- engagedModules.add(axisModule);
- }
-
- public boolean isEngaged(String moduleName) {
- Iterator engagedModuleItr = engagedModules.iterator();
- while (engagedModuleItr.hasNext()) {
- AxisModule axisModule = (AxisModule) engagedModuleItr.next();
- if (axisModule.getName().equals(moduleName)) {
- return true;
- }
- }
- return false;
}
public ArrayList getModulerefs() {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java Thu Jun 21 10:16:27 2007
@@ -17,14 +17,7 @@
package org.apache.axis2.description;
import org.apache.axiom.om.util.UUIDGenerator;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.deployment.DeploymentConstants;
-import org.apache.axis2.util.WSDLSerializationUtil;
-import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.client.OperationClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.ConfigurationContext;
@@ -43,12 +36,9 @@
import javax.xml.namespace.QName;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
-import java.util.Map;
-import java.net.URI;
public abstract class AxisOperation extends AxisDescription
implements WSDLConstants {
@@ -63,11 +53,6 @@
*/
private int mep = WSDLConstants.MEP_CONSTANT_INVALID;
- /**
- * list of engaged modules
- */
- private ArrayList engagedModules = new ArrayList();
-
// to hide control operation , operation which added by RM like module
private boolean controlOperation = false;
private String style = STYLE_DOC;
@@ -146,136 +131,71 @@
}
/**
- * Engages a module. It is required to use this method.
+ * This is called when a module is engaged on this operation. Handle operation-specific
+ * tasks.
*
- * @param moduleref
+ * @param axisModule AxisModule
+ * @param engager
* @throws AxisFault
*/
- public final void engageModule(AxisModule moduleref)
- throws AxisFault {
- ArrayList moduleOperations = engageModuleToOperation(moduleref);
- AxisService service = (AxisService) getParent();
- if (service != null) {
- for (int i = 0; i < moduleOperations.size(); i++) {
- AxisOperation axisOperation = (AxisOperation) moduleOperations.get(i);
- service.addOperation(axisOperation);
+ public final void onEngage(AxisModule axisModule, AxisDescription engager) throws AxisFault {
+ // Am I the source of this engagement?
+ boolean selfEngaged = (engager == this);
+
+ // If I'm not, the operations will already have been added by someone above, so don't
+ // do it again.
+ if (selfEngaged) {
+ AxisService service = (AxisService)getParent();
+ if (service != null) {
+ service.addModuleOperations(axisModule);
}
}
- }
- private ArrayList engageModuleToOperation(AxisModule moduleref)
- throws AxisFault {
- if (moduleref == null) {
- return null;
- }
- Iterator module_itr = engagedModules.iterator();
- boolean isEngagable;
- String moduleName = moduleref.getName();
- while (module_itr.hasNext()) {
- AxisModule module = (AxisModule) module_itr.next();
- String modu = module.getName();
- isEngagable = org.apache.axis2.util.Utils.checkVersion(moduleName, modu);
- if (!isEngagable) {
- return new ArrayList();
- }
- }
AxisConfiguration axisConfig = getAxisConfiguration();
PhaseResolver phaseResolver = new PhaseResolver(axisConfig);
- phaseResolver.engageModuleToOperation(this, moduleref);
- Module module = moduleref.getModule();
+ phaseResolver.engageModuleToOperation(this, axisModule);
+ Module module = axisModule.getModule();
if (module != null) {
module.engageNotify(this);
}
- engagedModules.add(moduleref);
- return addModuleOperations(moduleref, axisConfig, (AxisService) getParent());
}
- public void disengageModule(AxisModule module) {
- if (module != null) {
- if (getParent() != null) {
- AxisService service = (AxisService) getParent();
- AxisConfiguration axiConfiguration = service.getAxisConfiguration();
- PhaseResolver phaseResolver = new PhaseResolver(axiConfiguration);
- if (service.isEngaged(module.getName())) {
- phaseResolver.disengageModuleFromOperationChain(module, this);
- } else if (axiConfiguration != null &&
- axiConfiguration.isEngaged(module.getName())) {
- phaseResolver.disengageModuleFromOperationChain(module, this);
- } else {
- if (axiConfiguration != null) {
- phaseResolver.disengageModuleFromGlobalChains(module);
- }
- phaseResolver.disengageModuleFromOperationChain(module, this);
- //removing operations added at the time of module engagemnt
- HashMap moduleOperations = module.getOperations();
- if (moduleOperations != null) {
- Iterator moduleOperations_itr = moduleOperations.values().iterator();
- while (moduleOperations_itr.hasNext()) {
- AxisOperation operation = (AxisOperation) moduleOperations_itr.next();
- service.removeOperation(operation.getName());
- }
- }
+ protected void onDisengage(AxisModule module) {
+ if (getParent() != null) {
+ AxisService service = (AxisService) getParent();
+ AxisConfiguration axisConfiguration = service.getAxisConfiguration();
+ PhaseResolver phaseResolver = new PhaseResolver(axisConfiguration);
+ if (!service.isEngaged(module.getName()) &&
+ (axisConfiguration != null && !axisConfiguration.isEngaged(module.getName()))) {
+ phaseResolver.disengageModuleFromGlobalChains(module);
+ }
+ phaseResolver.disengageModuleFromOperationChain(module, this);
+
+ //removing operations added at the time of module engagemnt
+ HashMap moduleOperations = module.getOperations();
+ if (moduleOperations != null) {
+ Iterator moduleOperations_itr = moduleOperations.values().iterator();
+ while (moduleOperations_itr.hasNext()) {
+ AxisOperation operation = (AxisOperation) moduleOperations_itr.next();
+ service.removeOperation(operation.getName());
}
}
- engagedModules.remove(module);
- log.debug("removed module from engaged modules list " + module.getName());
}
}
/**
* To remove module from engage module list
*
- * @param module
+ * @param module module to remove
+ * @deprecated please use disengageModule(), this method will disappear after 1.3
*/
public void removeFromEngagedModuleList(AxisModule module) {
- engagedModules.remove(module);
- log.debug("removed module from engaged modules list " + module.getName());
- }
-
-
- /**
- * Adds an operation to a service if a module is required to do so.
- *
- * @param module
- */
- public ArrayList addModuleOperations(AxisModule module, AxisConfiguration axisConfig,
- AxisService service)
- throws AxisFault {
- HashMap map = module.getOperations();
- Collection col = map.values();
- PhaseResolver phaseResolver = new PhaseResolver(axisConfig);
- //this array list is return , to avoid concurrent modifications , in the deployment engine
- ArrayList ops = new ArrayList();
- for (Iterator iterator = col.iterator(); iterator.hasNext();) {
- AxisOperation axisOperation = copyOperation((AxisOperation) iterator.next());
- axisOperation.setParent(service);
- ArrayList wsamappings = axisOperation.getWsamappingList();
- if (service.getOperation(axisOperation.getName()) == null) {
- // this operation is a control operation.
- Parameter expose = axisOperation.getParameter(DeploymentConstants.TAG_EXPOSE);
- if(expose!=null){
- if(JavaUtils.isTrue(expose.getValue(), false)){
- axisOperation.setControlOperation(true);
- }
- } else {
- axisOperation.setControlOperation(true);
- }
- Module moduleclazz = module.getModule();
- if (moduleclazz != null) {
- moduleclazz.engageNotify(axisOperation);
- }
- phaseResolver.engageModuleToOperation(axisOperation, module);
- ops.add(axisOperation);
- if (wsamappings != null) {
- for (int j = 0; j < wsamappings.size(); j++) {
- String mapping = (String) wsamappings.get(j);
-
- service.mapActionToOperation(mapping, axisOperation);
- }
- }
- }
+ try {
+ disengageModule(module);
+ } catch (AxisFault axisFault) {
+ // Can't do much here...
+ log.error(axisFault);
}
- return ops;
}
/**
@@ -301,7 +221,7 @@
operation.addParameter(parameter);
}
- operation.setWsamappingList(axisOperation.getWsamappingList());
+ operation.setWsamappingList(axisOperation.getWSAMappingList());
operation.setOutputAction(axisOperation.getOutputAction());
String[] faultActionNames = axisOperation.getFaultActionNames();
for (int i = 0; i < faultActionNames.length; i++) {
@@ -467,13 +387,6 @@
* @see org.apache.axis2.description.AxisService#getEngadgedModules()
*/
- /**
- * Method getEngagedModules.
- */
- public Collection getEngagedModules() {
- return engagedModules;
- }
-
public abstract AxisMessage getMessage(String label);
public String getMessageExchangePattern() {
@@ -508,7 +421,7 @@
return style;
}
- public ArrayList getWsamappingList() {
+ public ArrayList getWSAMappingList() {
return wsamappingList;
}
@@ -631,17 +544,6 @@
result = (String) iter.next();
}
return result;
- }
-
- public boolean isEngaged(String moduleName) {
- Iterator engagedModuleItr = engagedModules.iterator();
- while (engagedModuleItr.hasNext()) {
- AxisModule axisModule = (AxisModule) engagedModuleItr.next();
- if (axisModule.getName().equals(moduleName)) {
- return true;
- }
- }
- return false;
}
/**
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Thu Jun 21 10:16:27 2007
@@ -48,7 +48,6 @@
import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.util.Loader;
import org.apache.axis2.util.XMLUtils;
-import org.apache.axis2.util.JavaUtils;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -111,7 +110,9 @@
// Maps httpLocations to corresponding operations. Used to dispatch rest messages.
private HashMap httpLocationDispatcherMap = null;
+ /** Map from String(action URI) -> AxisOperation */
private HashMap operationsAliasesMap = null;
+
// Collection of aliases that are invalid for this service because they are duplicated across
// multiple operations under this service.
private List invalidOperationsAliases = null;
@@ -120,9 +121,6 @@
// to store module ref at deploy time parsing
private ArrayList moduleRefs = null;
- // to store engaged modules
- private ArrayList engagedModules = null;
-
// to store the wsdl definition , which is build at the deployment time
// to keep the time that last update time of the service
private long lastupdate;
@@ -305,7 +303,6 @@
httpLocationDispatcherMap = new HashMap();
messageReceivers = new HashMap();
moduleRefs = new ArrayList();
- engagedModules = new ArrayList();
schemaList = new ArrayList();
serviceClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController
.doPrivileged(new PrivilegedAction() {
@@ -465,32 +462,36 @@
}
/**
- * Adds an operation to a service if a module is required to do so.
+ * Add any control operations defined by a Module to this service.
*
- * @param module
+ * @param module the AxisModule which has just been engaged
+ * @throws AxisFault if a problem occurs
*/
- public void addModuleOperations(AxisModule module) throws AxisFault {
+ void addModuleOperations(AxisModule module) throws AxisFault {
HashMap map = module.getOperations();
Collection col = map.values();
+ PhaseResolver phaseResolver = new PhaseResolver(getAxisConfiguration());
for (Iterator iterator = col.iterator(); iterator.hasNext();) {
AxisOperation axisOperation = copyOperation((AxisOperation) iterator.next());
if (this.getOperation(axisOperation.getName()) == null) {
- ArrayList wsamappings = axisOperation.getWsamappingList();
+ ArrayList wsamappings = axisOperation.getWSAMappingList();
if (wsamappings != null) {
for (int j = 0, size = wsamappings.size(); j < size; j++) {
String mapping = (String) wsamappings.get(j);
mapActionToOperation(mapping, axisOperation);
}
}
- // this operation is a control operation.
- Parameter expose = axisOperation.getParameter(DeploymentConstants.TAG_EXPOSE);
- if(expose!=null){
- if(JavaUtils.isTrue(expose.getValue(), false)){
- axisOperation.setControlOperation(true);
- }
+ // If we've set the "expose" parameter for this operation, it's normal (non-
+ // control) and therefore it will appear in generated WSDL. If we haven't,
+ // it's a control operation and will be ignored at WSDL-gen time.
+ if (axisOperation.isParameterTrue(DeploymentConstants.TAG_EXPOSE)) {
+ axisOperation.setControlOperation(false);
} else {
axisOperation.setControlOperation(true);
}
+
+ phaseResolver.engageModuleToOperation(axisOperation, module);
+
this.addOperation(axisOperation);
}
}
@@ -563,7 +564,7 @@
mapActionToOperation(action, axisOperation);
}
- ArrayList wsamappings = axisOperation.getWsamappingList();
+ ArrayList wsamappings = axisOperation.getWSAMappingList();
if (wsamappings != null) {
for (int j = 0, size = wsamappings.size(); j < size; j++) {
String mapping = (String) wsamappings.get(j);
@@ -631,7 +632,7 @@
}
operation.setPolicyInclude(policyInclude);
- operation.setWsamappingList(axisOperation.getWsamappingList());
+ operation.setWsamappingList(axisOperation.getWSAMappingList());
operation.setRemainingPhasesInFlow(axisOperation.getRemainingPhasesInFlow());
operation.setPhasesInFaultFlow(axisOperation.getPhasesInFaultFlow());
operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
@@ -657,39 +658,18 @@
* Engages a module. It is required to use this method.
*
* @param axisModule
+ * @param engager
*/
- public void engageModule(AxisModule axisModule)
+ public void onEngage(AxisModule axisModule, AxisDescription engager)
throws AxisFault {
- if (axisModule == null) {
- throw new AxisFault(Messages.getMessage("modulenf"));
- }
- Iterator itr_engageModules = engagedModules.iterator();
- boolean isEngagable;
- String moduleName = axisModule.getName();
- while (itr_engageModules.hasNext()) {
- AxisModule module = (AxisModule) itr_engageModules.next();
- String modu = module.getName();
- isEngagable = org.apache.axis2.util.Utils.checkVersion(moduleName, modu);
- if (!isEngagable) {
- return;
- }
- }
-
- Module moduleImpl = axisModule.getModule();
- if (moduleImpl != null) {
- // notyfying module for service engagement
- moduleImpl.engageNotify(this);
- }
// adding module operations
addModuleOperations(axisModule);
Iterator operations = getOperations();
-
while (operations.hasNext()) {
AxisOperation axisOperation = (AxisOperation) operations.next();
- axisOperation.engageModule(axisModule);
+ axisOperation.engageModule(axisModule, engager);
}
- engagedModules.add(axisModule);
}
/**
@@ -819,13 +799,6 @@
return schema;
}
- public AxisConfiguration getAxisConfiguration() {
- if (getParent() != null) {
- return (AxisConfiguration) getParent().getParent();
- }
- return null;
- }
-
public void setEPRs(String[] eprs) {
this.eprs = eprs;
}
@@ -1065,15 +1038,6 @@
return operationList;
}
- /**
- * Method getEngagedModules.
- *
- * @return Returns Collection.
- */
- public Collection getEngagedModules() {
- return engagedModules;
- }
-
public URL getFileName() {
return fileName;
}
@@ -1370,36 +1334,24 @@
return exposedTransports.contains(transport);
}
- public void disengageModule(AxisModule module) {
- AxisConfiguration axisConfig = getAxisConfiguration();
- if (axisConfig != null) {
- PhaseResolver phaseResolver = new PhaseResolver(axisConfig);
- if (axisConfig.isEngaged(module.getName())) {
- removeModuleOperations(module);
- Iterator operations = getChildren();
- while (operations.hasNext()) {
- AxisOperation axisOperation = (AxisOperation) operations.next();
- phaseResolver.disengageModuleFromOperationChain(module, axisOperation);
- axisOperation.removeFromEngagedModuleList(module);
- }
- } else {
- if (isEngaged(module.getName())) {
- phaseResolver.disengageModuleFromGlobalChains(module);
- removeModuleOperations(module);
- Iterator operations = getChildren();
- while (operations.hasNext()) {
- AxisOperation axisOperation = (AxisOperation) operations.next();
- phaseResolver.disengageModuleFromOperationChain(module, axisOperation);
- axisOperation.removeFromEngagedModuleList(module);
- }
- }
- }
+ public void onDisengage(AxisModule module) throws AxisFault {
+ Iterator operations = getChildren();
+ while (operations.hasNext()) {
+ AxisOperation axisOperation = (AxisOperation) operations.next();
+ axisOperation.disengageModule(module);
+ }
+ removeModuleOperations(module);
+ AxisConfiguration config = getAxisConfiguration();
+ if (!config.isEngaged(module.getName())) {
+ PhaseResolver phaseResolver = new PhaseResolver(config);
+ phaseResolver.disengageModuleFromGlobalChains(module);
}
- engagedModules.remove(module);
}
/**
- * To remove module operations added at the time of engagement
+ * Remove any operations which were added by a given module.
+ *
+ * @param module the module in question
*/
private void removeModuleOperations(AxisModule module) {
HashMap moduleOerations = module.getOperations();
@@ -1412,21 +1364,6 @@
}
}
- public boolean isEngaged(String moduleName) {
- AxisModule module = getAxisConfiguration().getModule(moduleName);
- if (module == null) {
- return false;
- }
- Iterator engagedModuleItr = engagedModules.iterator();
- while (engagedModuleItr.hasNext()) {
- AxisModule axisModule = (AxisModule) engagedModuleItr.next();
- if (axisModule.getName().equals(module.getName())) {
- return true;
- }
- }
- return false;
- }
-
//#######################################################################################
// APIs to create AxisService
@@ -1693,7 +1630,7 @@
AxisOperation operation = getOperation(opName);
if (operation != null) {
removeChild(opName);
- ArrayList mappingList = operation.getWsamappingList();
+ ArrayList mappingList = operation.getWSAMappingList();
if (mappingList != null) {
for (int i = 0; i < mappingList.size(); i++) {
String actionMapping = (String) mappingList.get(i);
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisServiceGroup.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisServiceGroup.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisServiceGroup.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisServiceGroup.java Thu Jun 21 10:16:27 2007
@@ -22,7 +22,6 @@
import org.apache.axis2.engine.AxisEvent;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.modules.Module;
-import org.apache.axis2.util.Utils;
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,9 +34,6 @@
// to store module ref at deploy time parsing
private ArrayList modulesList = new ArrayList();
- // to store service Group engagedModules name
- private ArrayList engagedModules;
-
// to store modeule configuration info
private HashMap moduleConfigmap;
@@ -49,7 +45,6 @@
public AxisServiceGroup() {
moduleConfigmap = new HashMap();
- engagedModules = new ArrayList();
}
public AxisServiceGroup(AxisConfiguration axisDescription) {
@@ -89,7 +84,7 @@
AxisConfiguration axisConfig = (AxisConfiguration) getParent();
if (axisConfig != null) {
- Iterator modules = this.engagedModules.iterator();
+ Iterator modules = getEngagedModules().iterator();
while (modules.hasNext()) {
String moduleName = (String) modules.next();
@@ -110,73 +105,40 @@
service.setLastupdate();
addChild(service);
- }
-
- public void addToGroup(AxisService service) throws Exception {
- if (service == null) {
- return;
- }
- service.setParent(this);
-
- AxisConfiguration axisConfig = (AxisConfiguration) getParent();
-
- if (axisConfig != null) {
- Iterator modules = this.engagedModules.iterator();
-
- while (modules.hasNext()) {
- String moduleName = (String) modules.next();
- AxisModule axisModule = axisConfig.getModule(moduleName);
-
- if (axisModule != null) {
- Module moduleImpl = axisModule.getModule();
- if (moduleImpl != null) {
- // notyfying module for service engagement
- moduleImpl.engageNotify(service);
- }
- service.engageModule(axisModule);
- } else {
- throw new AxisFault(Messages.getMessage("modulenotavailble", moduleName));
- }
- }
- }
- service.setLastupdate();
- addChild(service);
if (axisConfig != null) {
- axisConfig.addToAllServicesMap(service.getName(), service);
+ axisConfig.addToAllServicesMap(service);
}
}
- public void addToengagedModules(String moduleName) {
- engagedModules.add(moduleName);
- }
-
- public void removeFromEngageList(String moduleName) {
- engagedModules.remove(moduleName);
+ /**
+ *
+ * @param service
+ * @throws Exception
+ * @deprecated please use addService() instead
+ */
+ public void addToGroup(AxisService service) throws Exception {
+ addService(service);
}
- public void engageModule(AxisModule module) throws AxisFault {
- String moduleName = module.getName();
- boolean isEngagable;
- for (Iterator iterator = engagedModules.iterator(); iterator.hasNext();) {
- String modu = (String) iterator.next();
- isEngagable = Utils.checkVersion(moduleName, modu);
- if (!isEngagable) {
- return;
- }
- }
+ /**
+ * When a module gets engaged on a ServiceGroup, we have to engage it for each Service.
+ *
+ * @param module the newly-engaged AxisModule
+ * @param engager
+ * @throws AxisFault if there is a problem
+ */
+ protected void onEngage(AxisModule module, AxisDescription engager) throws AxisFault {
for (Iterator serviceIter = getServices(); serviceIter.hasNext();) {
AxisService axisService = (AxisService) serviceIter.next();
- axisService.engageModule(module);
+ axisService.engageModule(module, engager);
}
- addToengagedModules(moduleName);
}
- public void disengageModule(AxisModule module) throws AxisFault {
+ public void onDisengage(AxisModule module) throws AxisFault {
for (Iterator serviceIter = getServices(); serviceIter.hasNext();) {
AxisService axisService = (AxisService) serviceIter.next();
axisService.disengageModule(module);
}
- removeFromEngageList(module.getName());
}
public void removeService(String name) throws AxisFault {
@@ -189,14 +151,6 @@
removeChild(name);
}
- public AxisConfiguration getAxisDescription() {
- return (AxisConfiguration) getParent();
- }
-
- public ArrayList getEngagedModules() {
- return engagedModules;
- }
-
public ModuleConfiguration getModuleConfig(String moduleName) {
return (ModuleConfiguration) moduleConfigmap.get(moduleName);
}
@@ -243,23 +197,7 @@
return this.serviceGroupName;
}
- public boolean isEngaged(String moduleName) {
- AxisModule module = getAxisDescription().getModule(moduleName);
- if (module == null) {
- return false;
- }
-
- for (Iterator engagedModuleItr = engagedModules.iterator();
- engagedModuleItr.hasNext();) {
- String axisModule = (String) engagedModuleItr.next();
- if (axisModule.equals(module.getName())) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isFoundWebResources() {
+ public boolean isFoundWebResources() {
return foundWebResources;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/HandlerDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/HandlerDescription.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/HandlerDescription.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/HandlerDescription.java Thu Jun 21 10:16:27 2007
@@ -34,25 +34,10 @@
*/
private String className;
- /**
- * Field handler
- */
private Handler handler;
-
- /**
- * Field name
- */
private String name;
-
- /**
- * Field parameterInclude
- */
private final ParameterInclude parameterInclude;
private ParameterInclude parent;
-
- /**
- * Field rules
- */
private PhaseRule rules;
/**
@@ -66,7 +51,7 @@
/**
* Constructor HandlerDescription.
*
- * @param name
+ * @param name name of handler
*/
public HandlerDescription(String name) {
this();
@@ -74,7 +59,9 @@
}
/**
- * @param param
+ * Add a Parameter
+ *
+ * @param param the Parameter to associate with this HandlerDescription
*/
public void addParameter(Parameter param) throws AxisFault {
if (isParameterLocked(param.getName())) {
@@ -120,8 +107,10 @@
}
/**
- * @param name
- * @return Returns Parameter.
+ * Get a named Parameter
+ *
+ * @param name name of Parameter to search
+ * @return a Parameter, which may come from us or from some parent up the tree, or null.
*/
public Parameter getParameter(String name) {
Parameter parameter = parameterInclude.getParameter(name);
@@ -163,14 +152,16 @@
/**
* Method setClassName.
*
- * @param className
+ * @param className the class name of the Handler class
*/
public void setClassName(String className) {
this.className = className;
}
/**
- * @param handler
+ * Explicitly set the Handler object
+ *
+ * @param handler a Handler instance, which will be deployed wherever this HandlerDescription is
*/
public void setHandler(Handler handler) {
this.handler = handler;
@@ -178,7 +169,9 @@
}
/**
- * @param name
+ * Set the name
+ *
+ * @param name the desired name
*/
public void setName(String name) {
this.name = name;
@@ -189,9 +182,9 @@
}
/**
- * Method setRules.
+ * Set the deployment rules for this HandlerDescription
*
- * @param rules
+ * @param rules a PhaseRule object
*/
public void setRules(PhaseRule rules) {
this.rules = rules;
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Thu Jun 21 10:16:27 2007
@@ -18,8 +18,6 @@
import org.apache.neethi.Constants;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyReference;
-import org.apache.neethi.PolicyRegistry;
-import org.apache.neethi.PolicyRegistryImpl;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axiom.soap.SOAP11Constants;
@@ -1023,7 +1021,7 @@
// Check if the action is already set as we don't want to
// override it
// with the Default Action Pattern
- ArrayList inputActions = axisOperation.getWsamappingList();
+ ArrayList inputActions = axisOperation.getWSAMappingList();
String action = null;
if (inputActions == null || inputActions.size() == 0) {
action = WSDL11ActionHelper
@@ -1115,7 +1113,7 @@
// Check if the action is already set as we don't want to
// override it
// with the Default Action Pattern
- ArrayList inputActions = axisOperation.getWsamappingList();
+ ArrayList inputActions = axisOperation.getWSAMappingList();
String action = null;
if (inputActions == null || inputActions.size() == 0) {
action = WSDL11ActionHelper.getActionFromOutputElement(dif,
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java Thu Jun 21 10:16:27 2007
@@ -84,11 +84,6 @@
*/
private List globalModuleList;
- /**
- * Field engagedModules
- */
- private final ArrayList engagedModules;
-
private Hashtable faultyModules;
/**
@@ -134,7 +129,6 @@
*/
public AxisConfiguration() {
moduleConfigmap = new HashMap();
- engagedModules = new ArrayList();
globalModuleList = new ArrayList();
messageReceivers = new HashMap();
messageBuilders = new HashMap();
@@ -271,11 +265,6 @@
Iterator services = axisServiceGroup.getServices();
while (services.hasNext()) {
axisService = (AxisService) services.next();
- String serviceName = axisService.getName();
- if (allServices.get(serviceName) != null) {
- throw new AxisFault(Messages.getMessage("twoservicecannothavesamename",
- axisService.getName()));
- }
if (axisService.getSchematargetNamespace() == null) {
axisService.setSchemaTargetNamespace(Java2WSDLConstants.AXIS2_XSD);
}
@@ -291,17 +280,30 @@
}
}
}
- Iterator enModule = engagedModules.iterator();
+ Iterator enModule = getEngagedModules().iterator();
while (enModule.hasNext()) {
axisServiceGroup.engageModule((AxisModule)enModule.next());
}
services = axisServiceGroup.getServices();
+ ArrayList servicesIAdded = new ArrayList();
while (services.hasNext()) {
axisService = (AxisService) services.next();
Map endpoints = axisService.getEndpoints();
String serviceName = axisService.getName();
- addToAllServicesMap(serviceName, axisService);
+ try {
+ addToAllServicesMap(axisService);
+ } catch (AxisFault axisFault) {
+ // Whoops, must have been a duplicate! If we had a problem here, we have to
+ // remove all the ones we added...
+ for (Iterator i = servicesIAdded.iterator(); i.hasNext();) {
+ AxisService service = (AxisService)i.next();
+ allServices.remove(service.getName());
+ }
+ // And toss this in case anyone wants it?
+ throw axisFault;
+ }
+ servicesIAdded.add(axisService);
if (endpoints != null) {
Iterator endpointNameIter = endpoints.keySet().iterator();
while (endpointNameIter.hasNext()) {
@@ -319,8 +321,18 @@
addChild(axisServiceGroup);
}
- public void addToAllServicesMap(String serviceName, AxisService axisService) {
- allServices.put(serviceName, axisService);
+ public void addToAllServicesMap(AxisService axisService) throws AxisFault {
+ String serviceName = axisService.getName();
+ AxisService oldService = (AxisService)allServices.get(serviceName);
+ if (oldService == null) {
+ allServices.put(serviceName, axisService);
+ } else {
+ // If we were already there, that's fine. If not, fault!
+ if (oldService != axisService) {
+ throw new AxisFault(Messages.getMessage("twoservicecannothavesamename",
+ axisService.getName()));
+ }
+ }
}
public AxisServiceGroup removeServiceGroup(String serviceGroupName) throws AxisFault {
@@ -423,52 +435,28 @@
}
}
- public void engageModule(AxisModule module) throws AxisFault {
- boolean isEngagable;
- if (module != null) {
- String moduleName = module.getName();
- for (Iterator iterator = engagedModules.iterator(); iterator.hasNext();) {
- AxisModule thisModule = (AxisModule)iterator.next();
-
- isEngagable = Utils.checkVersion(moduleName, thisModule.getName());
- if (!isEngagable) {
- return;
- }
- }
- } else {
- throw new AxisFault(Messages.getMessage("refertoinvalidmodule"));
- }
+ public void onEngage(AxisModule module, AxisDescription engager) throws AxisFault {
Iterator servicegroups = getServiceGroups();
while (servicegroups.hasNext()) {
- AxisServiceGroup serviceGroup = (AxisServiceGroup) servicegroups
- .next();
- serviceGroup.engageModule(module);
+ AxisServiceGroup serviceGroup = (AxisServiceGroup) servicegroups.next();
+ serviceGroup.engageModule(module, engager);
}
- engagedModules.add(module);
}
/**
* To dis-engage a module from the system. This will remove all the handlers
* belonging to this module from all the handler chains.
*
- * @param module
+ * @param module module to disengage
*/
- public void disengageModule(AxisModule module) {
- if (module != null && isEngaged(module.getName())) {
- PhaseResolver phaseResolver = new PhaseResolver(this);
- phaseResolver.disengageModuleFromGlobalChains(module);
- Iterator serviceItr = getServices().values().iterator();
- while (serviceItr.hasNext()) {
- AxisService axisService = (AxisService) serviceItr.next();
- axisService.disengageModule(module);
- }
- Iterator serviceGroups = getServiceGroups();
- while (serviceGroups.hasNext()) {
- AxisServiceGroup axisServiceGroup = (AxisServiceGroup) serviceGroups
- .next();
- axisServiceGroup.removeFromEngageList(module.getName());
- }
- engagedModules.remove(module);
+ public void onDisengage(AxisModule module) throws AxisFault {
+ PhaseResolver phaseResolver = new PhaseResolver(this);
+ phaseResolver.disengageModuleFromGlobalChains(module);
+
+ Iterator serviceGroups = getServiceGroups();
+ while (serviceGroups.hasNext()) {
+ AxisServiceGroup axisServiceGroup = (AxisServiceGroup) serviceGroups.next();
+ axisServiceGroup.disengageModule(module);
}
}
@@ -535,15 +523,6 @@
}
/**
- * getEngagedModules() returns a copy of the list of engaged modules
- *
- * @return Collection a collection, containing AxisModules
- */
- public Collection getEngagedModules() {
- return (Collection)engagedModules.clone();
- }
-
- /**
* Add an AxisModule to the list of globally deployed modules.
*
* TODO: should this check for duplicate names?
@@ -765,18 +744,6 @@
// To get all the services in the system
public HashMap getServices() {
- Iterator sgs = getServiceGroups();
-
- while (sgs.hasNext()) {
- AxisServiceGroup axisServiceGroup = (AxisServiceGroup) sgs.next();
- Iterator servics = axisServiceGroup.getServices();
-
- while (servics.hasNext()) {
- AxisService axisService = (AxisService) servics.next();
- addToAllServicesMap(axisService.getName(), axisService);
- }
- }
-
return allServices;
}
@@ -805,10 +772,10 @@
public boolean isEngaged(String moduleName) {
AxisModule module = (AxisModule)allModules.get(moduleName);
if (module == null) return false;
- boolean isEngaged = engagedModules.contains(moduleName);
+ boolean isEngaged = super.isEngaged(moduleName);
if (!isEngaged) {
AxisModule defaultModule = getDefaultModule(moduleName);
- isEngaged = engagedModules.contains(defaultModule);
+ isEngaged = engagedModules != null && engagedModules.values().contains(defaultModule);
}
return isEngaged;
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/i18n/resource.properties Thu Jun 21 10:16:27 2007
@@ -253,3 +253,4 @@
wsaddressingrequirednotpresent=WS-Addressing is required, but it cannot be found.
nomessagereciever=Message Receiver not found for AxisOperation: {0}
duplicaterelatesto=The message is a duplicate (has the same reply relationship value) of an already processed message. RelatesTo = {0}
+mismatchedModuleVersions=Tried to deploy (to {0}) a module ''{1}'' when ''{2}'' was already deployed - version mismatch!
\ No newline at end of file
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/phaseresolver/PhaseResolver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/phaseresolver/PhaseResolver.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/phaseresolver/PhaseResolver.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/phaseresolver/PhaseResolver.java Thu Jun 21 10:16:27 2007
@@ -68,7 +68,7 @@
int flowType) throws PhaseException {
List phases = new ArrayList();
Flow flow = null;
- switch(flowType){
+ switch (flowType) {
case PhaseMetadata.IN_FLOW : {
phases.addAll(axisConfig.getInFlowPhases());
phases.addAll(axisOperation.getRemainingPhasesInFlow());
@@ -94,8 +94,9 @@
break;
}
}
- engageModuleToFlow(flow,phases);
+ engageModuleToFlow(flow, phases);
}
+
public void engageModuleToOperation(AxisOperation axisOperation, AxisModule module)
throws PhaseException {
for (int type = IN_FLOW; type < OUT_FAULT_FLOW; type++) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java Thu Jun 21 10:16:27 2007
@@ -283,14 +283,14 @@
}
/**
- * Will check whether a given module can be engage or not
- * if the version mismamathc then thow en exception
+ *
* - if he trying to engage the same module then method will returen false
* - else it will return true
*
- * @param deployingModuleName
- * @param deployedModulename
- * @throws AxisFault
+ * @param deployingModuleName the module we're currently deploying
+ * @param deployedModulename an existing module
+ * @return true if these are different modules, false if they're the same
+ * @throws AxisFault if two different versions of the same module are deployed
*/
public static boolean checkVersion(String deployingModuleName,
String deployedModulename) throws AxisFault {
@@ -304,9 +304,10 @@
throw new AxisFault("trying to engage two different module versions " +
module1version + " : " + module2version);
} else {
- return false;
+ return true;
}
- } else if (module2version == null) {
+ } else if (module2version != null) {
+ // TODO: Check default version?
return false;
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/ModuleDisengagementTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/ModuleDisengagementTest.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/ModuleDisengagementTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/ModuleDisengagementTest.java Thu Jun 21 10:16:27 2007
@@ -32,168 +32,184 @@
*/
public class ModuleDisengagementTest extends TestCase {
- AxisConfiguration er;
+ AxisConfiguration config;
String serviceName = "testService";
QName opName = new QName("testOperation");
protected void setUp() throws Exception {
String filename =
AbstractTestCase.basedir + "/test-resources/deployment/moduleDisEngegeRepo";
- er = ConfigurationContextFactory.
+ config = ConfigurationContextFactory.
createConfigurationContextFromFileSystem(filename, null).getAxisConfiguration();
AxisService testService = new AxisService();
testService.setName(serviceName);
AxisOperation testOperation = new InOutAxisOperation();
testOperation.setName(opName);
testService.addOperation(testOperation);
- er.addService(testService);
+
+ testOperation = new InOutAxisOperation();
+ testOperation.setName(new QName("oper2"));
+ testService.addOperation(testOperation);
+
+ config.addService(testService);
}
- public void testGloalDisengagement() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ public void testGlobalDisengagement() throws AxisFault {
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
- Phase predisptah;
+ Phase phase;
Phase userPhase;
- ArrayList globalinflow = er.getInFlowPhases();
+ ArrayList globalinflow = config.getInFlowPhases();
assertNotNull(globalinflow);
- predisptah = (Phase) globalinflow.get(2);
- assertNotNull(predisptah);
- assertEquals(predisptah.getHandlerCount(), 0);
- AxisService service = er.getService(serviceName);
+ phase = (Phase) globalinflow.get(2);
+ assertNotNull(phase);
+ assertEquals(phase.getHandlerCount(), 0);
+ AxisService service = config.getService(serviceName);
assertNotNull(service);
AxisOperation operation = service.getOperation(opName);
assertNotNull(operation);
userPhase = (Phase) operation.getRemainingPhasesInFlow().get(1);
assertNotNull(userPhase);
assertEquals(0, userPhase.getHandlerCount());
- er.engageModule(module.getName());
- assertEquals(predisptah.getHandlerCount(), 2);
+
+ config.engageModule(module.getName());
+ assertEquals(2, phase.getHandlerCount());
assertEquals(1, userPhase.getHandlerCount());
- er.disengageModule(module);
- assertEquals(predisptah.getHandlerCount(), 0);
+
+ config.disengageModule(module);
+ assertEquals(0, phase.getHandlerCount());
assertEquals(0, userPhase.getHandlerCount());
}
public void testServiceDisengagement() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
- Phase predisptah;
+ Phase phase;
Phase userPhase;
- ArrayList globalinflow = er.getInFlowPhases();
+ ArrayList globalinflow = config.getInFlowPhases();
assertNotNull(globalinflow);
- predisptah = (Phase) globalinflow.get(2);
- assertNotNull(predisptah);
- assertEquals(predisptah.getHandlerCount(), 0);
- AxisService service = er.getService(serviceName);
+ phase = (Phase) globalinflow.get(2);
+ assertNotNull(phase);
+ assertEquals(0, phase.getHandlerCount());
+ AxisService service = config.getService(serviceName);
assertNotNull(service);
AxisOperation operation = service.getOperation(opName);
assertNotNull(operation);
+
userPhase = (Phase) operation.getRemainingPhasesInFlow().get(1);
assertNotNull(userPhase);
assertEquals(0, userPhase.getHandlerCount());
- er.engageModule(module.getName());
- assertEquals(predisptah.getHandlerCount(), 2);
+
+ config.engageModule(module.getName());
+ assertEquals(2, phase.getHandlerCount());
assertEquals(1, userPhase.getHandlerCount());
+
service.disengageModule(module);
- assertEquals(predisptah.getHandlerCount(), 2);
+ assertEquals(2, phase.getHandlerCount());
assertEquals(0, userPhase.getHandlerCount());
}
- public void testGlobalChcek() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ public void testGlobalCheck() throws AxisFault {
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
- er.engageModule(module.getName());
- er.disengageModule(module);
- er.engageModule(module.getName());
+ config.engageModule(module.getName());
+ config.disengageModule(module);
+ config.engageModule(module.getName());
}
public void testOperationDisengagement() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
- Phase predisptah;
+ Phase phase;
Phase userPhase;
- ArrayList globalinflow = er.getInFlowPhases();
+ ArrayList globalinflow = config.getInFlowPhases();
assertNotNull(globalinflow);
- predisptah = (Phase) globalinflow.get(2);
- assertNotNull(predisptah);
- assertEquals(predisptah.getHandlerCount(), 0);
- AxisService service = er.getService(serviceName);
+ phase = (Phase) globalinflow.get(2);
+ assertNotNull(phase);
+ assertEquals(phase.getHandlerCount(), 0);
+ AxisService service = config.getService(serviceName);
assertNotNull(service);
AxisOperation operation = service.getOperation(opName);
assertNotNull(operation);
userPhase = (Phase) operation.getRemainingPhasesInFlow().get(1);
assertNotNull(userPhase);
assertEquals(0, userPhase.getHandlerCount());
- er.engageModule(module.getName());
- assertEquals(predisptah.getHandlerCount(), 2);
+
+ config.engageModule(module.getName());
+ assertEquals(2, phase.getHandlerCount());
assertEquals(1, userPhase.getHandlerCount());
+
operation.disengageModule(module);
- assertEquals(predisptah.getHandlerCount(), 2);
+ assertEquals(2, phase.getHandlerCount());
assertEquals(0, userPhase.getHandlerCount());
}
- public void testServiceEnageServiceDisengag() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ public void testServiceEngageServiceDisengage() throws AxisFault {
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
Phase predisptah;
Phase userPhase;
- ArrayList globalinflow = er.getInFlowPhases();
+ ArrayList globalinflow = config.getInFlowPhases();
assertNotNull(globalinflow);
predisptah = (Phase) globalinflow.get(2);
assertNotNull(predisptah);
assertEquals(predisptah.getHandlerCount(), 0);
- AxisService service = er.getService(serviceName);
+ AxisService service = config.getService(serviceName);
assertNotNull(service);
AxisOperation operation = service.getOperation(opName);
assertNotNull(operation);
userPhase = (Phase) operation.getRemainingPhasesInFlow().get(1);
assertNotNull(userPhase);
assertEquals(0, userPhase.getHandlerCount());
+
service.engageModule(module);
- assertEquals(predisptah.getHandlerCount(), 2);
+ assertEquals(2, predisptah.getHandlerCount());
assertEquals(1, userPhase.getHandlerCount());
+
service.disengageModule(module);
- assertEquals(predisptah.getHandlerCount(), 0);
+ assertEquals(0, predisptah.getHandlerCount());
assertEquals(0, userPhase.getHandlerCount());
}
- public void testServiceEnageOperationDisengag() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ public void testServiceEngageOperationDisengage() throws AxisFault {
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
- Phase predisptah;
+ Phase phase;
Phase userPhase;
- ArrayList globalinflow = er.getInFlowPhases();
+ ArrayList globalinflow = config.getInFlowPhases();
assertNotNull(globalinflow);
- predisptah = (Phase) globalinflow.get(2);
- assertNotNull(predisptah);
- assertEquals(predisptah.getHandlerCount(), 0);
- AxisService service = er.getService(serviceName);
+ phase = (Phase) globalinflow.get(2);
+ assertNotNull(phase);
+ assertEquals(phase.getHandlerCount(), 0);
+ AxisService service = config.getService(serviceName);
assertNotNull(service);
AxisOperation operation = service.getOperation(opName);
assertNotNull(operation);
userPhase = (Phase) operation.getRemainingPhasesInFlow().get(1);
assertNotNull(userPhase);
assertEquals(0, userPhase.getHandlerCount());
+
service.engageModule(module);
- assertEquals(predisptah.getHandlerCount(), 2);
+ assertEquals(2, phase.getHandlerCount());
assertEquals(1, userPhase.getHandlerCount());
+
operation.disengageModule(module);
- assertEquals(predisptah.getHandlerCount(), 2);
+ assertEquals(2, phase.getHandlerCount());
assertEquals(0, userPhase.getHandlerCount());
}
- public void testOperationEnageOperationDisengage() throws AxisFault {
- AxisModule module = er.getModule("testModule");
+ public void testOperationEngageOperationDisengage() throws AxisFault {
+ AxisModule module = config.getModule("testModule");
assertNotNull(module);
- Phase predisptah;
+ Phase phase;
Phase userPhase;
- ArrayList globalinflow = er.getInFlowPhases();
+ ArrayList globalinflow = config.getInFlowPhases();
assertNotNull(globalinflow);
- predisptah = (Phase) globalinflow.get(2);
- assertNotNull(predisptah);
- assertEquals(predisptah.getHandlerCount(), 0);
- AxisService service = er.getService(serviceName);
+ phase = (Phase) globalinflow.get(2);
+ assertNotNull(phase);
+ assertEquals(phase.getHandlerCount(), 0);
+ AxisService service = config.getService(serviceName);
assertNotNull(service);
AxisOperation operation = service.getOperation(opName);
assertNotNull(operation);
@@ -201,10 +217,10 @@
assertNotNull(userPhase);
assertEquals(0, userPhase.getHandlerCount());
operation.engageModule(module);
- assertEquals(predisptah.getHandlerCount(), 2);
+ assertEquals(2, phase.getHandlerCount());
assertEquals(1, userPhase.getHandlerCount());
operation.disengageModule(module);
- assertEquals(predisptah.getHandlerCount(), 0);
+ assertEquals(0, phase.getHandlerCount());
assertEquals(0, userPhase.getHandlerCount());
}
Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/SameServiceAddingTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/SameServiceAddingTest.java?view=diff&rev=549554&r1=549553&r2=549554
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/SameServiceAddingTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/SameServiceAddingTest.java Thu Jun 21 10:16:27 2007
@@ -25,52 +25,61 @@
*/
/**
- * Author: Deepal Jayasinghe
- * Date: Sep 16, 2005
- * Time: 11:29:06 PM
+ * This test confirms that we behave correctly when adding ServiceGroups with duplicate
+ * Services to ones that have already been deployed.
*/
public class SameServiceAddingTest extends TestCase {
- AxisConfiguration ar;
+ AxisConfiguration config;
public void testServiceGroup() throws AxisFault {
- ar = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null)
+ final String SERVICE1 = "serevice1";
+ final String SERVICE2 = "serevice2";
+ final String SERVICE4 = "serevice4";
+ final String SERVICE_GROUP2 = "ServiceGroup2";
+
+ config = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null)
.getAxisConfiguration();
+
+ // First create a ServiceGroup with S1 and S4
AxisServiceGroup axisServiceGroup1 = new AxisServiceGroup();
axisServiceGroup1.setServiceGroupName("ServiceGroup1");
AxisService service1 = new AxisService();
- service1.setName("serevice1");
+ service1.setName(SERVICE1);
axisServiceGroup1.addService(service1);
AxisService service4 = new AxisService();
- service4.setName("serevice4");
+ service4.setName(SERVICE4);
axisServiceGroup1.addService(service4);
- ar.addServiceGroup(axisServiceGroup1);
-
+ config.addServiceGroup(axisServiceGroup1);
+ // Now create another ServiceGroup with S2 and S4
AxisServiceGroup axisServiceGroup2 = new AxisServiceGroup();
- axisServiceGroup2.setServiceGroupName("ServiceGroup2");
+ axisServiceGroup2.setServiceGroupName(SERVICE_GROUP2);
AxisService service2 = new AxisService();
- service2.setName("serevice2");
+ service2.setName(SERVICE2);
axisServiceGroup2.addService(service2);
AxisService service24 = new AxisService();
- service24.setName("serevice4");
+ service24.setName(SERVICE4);
axisServiceGroup2.addService(service24);
try {
- ar.addServiceGroup(axisServiceGroup2);
+ // This should fail!
+ config.addServiceGroup(axisServiceGroup2);
} catch (AxisFault axisFault) {
- //I have to ignore this
+ // This is expected because S4 was a duplicate name to an already existing service
+ assertTrue("Caught the wrong fault!", axisFault.getMessage().indexOf(SERVICE4) > -1);
}
- AxisService servie = ar.getService("serevice1");
- assertNotNull(servie);
- servie = ar.getService("serevice4");
- assertNotNull(servie);
-
- servie = ar.getService("serevice2");
- assertEquals(null, servie);
- assertEquals(null, ar.getServiceGroup("service2"));
+ AxisService service = config.getService(SERVICE1);
+ assertNotNull("Service 1 wasn't deployed!", service);
+ service = config.getService(SERVICE4);
+ assertNotNull("Service 4 wasn't deployed!", service);
+
+ service = config.getService(SERVICE2);
+ assertNull("Service 2 wasn't supposed to be deployed!", service);
+ assertNull("ServiceGroup2 wasn't supposed to be deployed!",
+ config.getServiceGroup("service2"));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org