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 na...@apache.org on 2009/10/02 03:34:18 UTC

svn commit: r820862 - in /webservices/axis2/trunk/java/modules/kernel: src/org/apache/axis2/deployment/ src/org/apache/axis2/description/ test/org/apache/axis2/description/

Author: nagy
Date: Fri Oct  2 01:34:17 2009
New Revision: 820862

URL: http://svn.apache.org/viewvc?rev=820862&view=rev
Log:
Enhancement to allow operations declared within modules to specify that they may be overridden by an operation on a service implementation without having both operations be deregistered.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=820862&r1=820861&r2=820862&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java Fri Oct  2 01:34:17 2009
@@ -90,6 +90,7 @@
     String TAG_HOT_UPDATE = "hotupdate";
     String TAG_ANTI_JAR_LOCKING = "antiJARLocking";
     String TAG_HOT_DEPLOYMENT = "hotdeployment";
+    String TAG_ALLOWOVERRIDE = "allowOverride";
     String TAG_EXPOSE = "expose";
     String TAG_EXTRACT_SERVICE_ARCHIVE = "extractServiceArchive";
     String TAG_DISPATCH_ORDER = "dispatchOrder";

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java?rev=820862&r1=820861&r2=820862&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java Fri Oct  2 01:34:17 2009
@@ -35,6 +35,8 @@
 import org.apache.axis2.phaseresolver.PhaseMetadata;
 import org.apache.axis2.util.Loader;
 import org.apache.axis2.util.JavaUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -49,6 +51,7 @@
  * Builds a module description from OM
  */
 public class ModuleBuilder extends DescriptionBuilder {
+    private static final Log log = LogFactory.getLog(ModuleBuilder.class);
     private AxisModule module;
 
     public ModuleBuilder(InputStream serviceInputStream, AxisModule module,
@@ -129,7 +132,12 @@
                     module.setName(moduleName);
                 }
             }
-
+            
+            if (log.isDebugEnabled()) {
+              log.debug("populateModule: Building module description for: "
+                        + module.getName());
+            }
+                        
             // Process service description
             OMElement descriptionElement =
                     moduleElement.getFirstChildWithName(new QName(TAG_DESCRIPTION));
@@ -216,6 +224,10 @@
                 module.addOperation(op);
             }
 
+            if (log.isDebugEnabled()) {
+              log.debug("populateModule: Done building module description");
+            }
+                        
         } catch (XMLStreamException e) {
             throw new DeploymentException(e);
         } catch(AxisFault e) {
@@ -259,6 +271,26 @@
 
             op_descrip.setName(new QName(opname));
 
+            //Check for the allowOverride attribute
+            OMAttribute op_allowOverride_att = operation.getAttribute(new QName(TAG_ALLOWOVERRIDE));
+            if (op_allowOverride_att != null) {
+              try {
+                op_descrip.addParameter(TAG_ALLOWOVERRIDE, op_allowOverride_att.getAttributeValue());
+              } catch (AxisFault axisFault) {
+                throw new DeploymentException(
+                            Messages.getMessage(
+                                    Messages.getMessage(
+                                            DeploymentErrorMsgs.PARAMETER_LOCKED,
+                                            axisFault.getMessage())));
+                      
+              }
+              if (log.isDebugEnabled()) {
+                log.debug("processOperations: allowOverride set to "
+                          + op_allowOverride_att.getAttributeValue()
+                          + " for operation: "+opname);
+              }
+            }
+            
             // Operation Parameters
             Iterator parameters = operation.getChildrenWithName(new QName(TAG_PARAMETER));
             processParameters(parameters, op_descrip, module);

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?rev=820862&r1=820861&r2=820862&view=diff
==============================================================================
--- 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 Fri Oct  2 01:34:17 2009
@@ -543,7 +543,31 @@
 				if (wsamappings != null) {
 					for (int j = 0, size = wsamappings.size(); j < size; j++) {
 						String mapping = (String) wsamappings.get(j);
-						mapActionToOperation(mapping, axisOperation);
+                        //If there is already an operation with this action
+						//mapping (e.g. if the service has a matching operation)
+						//then we're going to check to see if the module's
+						//operation says that it's OK to be overridden and
+						//if so, we'll simply ignore the mapping, otherwise
+						//we continue as before
+						AxisOperation mappedOperation = getOperationByAction(mapping);
+						if ((mappedOperation != null)
+						    && (axisOperation.isParameterTrue(DeploymentConstants.TAG_ALLOWOVERRIDE))) {
+						  if (log.isDebugEnabled()) {
+						    log
+						    .debug("addModuleOperations: Mapping already exists for action: "
+						           + mapping
+						           + " to operation: "
+						           + axisOperation
+						           + " named: "
+						           + axisOperation.getName()
+						           + " and an override is allowed, so the module mapping for module: "
+						           + module.getName()
+						           + " is being ignored.");
+						    log.debug(JavaUtils.callStackToString());
+						  }
+						} else {
+						  mapActionToOperation(mapping, axisOperation);
+						}
 					}
 				}
 				// If we've set the "expose" parameter for this operation, it's
@@ -793,6 +817,29 @@
 							+ "; operation: "
 							+ axisOperation
 							+ "named: " + axisOperation.getName());
+              log.debug(JavaUtils.callStackToString());
+		}
+                      
+		//If there is already an operation with this action
+		//mapping then we're going to check to see if the
+		//operation says that it's OK to be overridden and
+		//if so, we'll simply ignore the mapping, otherwise
+		//we continue as before
+		AxisOperation mappedOperation = getOperationByAction(action);
+		if ((mappedOperation != null)
+		    && (axisOperation.isParameterTrue(DeploymentConstants.TAG_ALLOWOVERRIDE))) {
+		  if (log.isDebugEnabled()) {
+		    log
+		    .debug("addModuleOperations: Mapping already exists for action: "
+		           + action
+		           + " to operation: "
+		           + axisOperation
+		           + " named: "
+		           + axisOperation.getName()
+		           + " and an override is allowed, so the mapping is being ignored.");
+		    log.debug(JavaUtils.callStackToString());
+		  }
+		  return;		
 		}
 
 		// First check if this action has already been flagged as invalid

Modified: webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java?rev=820862&r1=820861&r2=820862&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/description/AxisServiceTest.java Fri Oct  2 01:34:17 2009
@@ -24,6 +24,7 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.engine.AxisConfiguration;
 
 import javax.xml.namespace.QName;
@@ -175,6 +176,32 @@
         assertTrue("SUCCESSFUL".equals(mc.getProperty("MESSAGE_PROPERTY")));
     }
     
+    public void testOperationActionMapping() throws Exception {
+        AxisService service = new AxisService();
+                
+        AxisOperation op1 = new InOutAxisOperation();
+        AxisOperation op2 = new InOutAxisOperation();
+        op2.addParameter(DeploymentConstants.TAG_ALLOWOVERRIDE, "true");
+        AxisOperation op3 = new InOutAxisOperation();
+        
+        service.mapActionToOperation("testaction1", op1);
+        assertEquals(service.getOperationByAction("testaction1"), op1);
+        //Test duplicate registration with same operation
+        service.mapActionToOperation("testaction1", op1);
+        assertEquals(service.getOperationByAction("testaction1"), op1);
+        //Test duplicate registration with different operation and allowOverride
+        service.mapActionToOperation("testaction1", op2);
+        assertEquals(service.getOperationByAction("testaction1"), op1);
+        //Test registration of new operation with allowOverride
+        service.mapActionToOperation("testaction2", op2);
+        assertEquals(service.getOperationByAction("testaction1"), op1);
+        assertEquals(service.getOperationByAction("testaction2"), op2);
+        //Test duplicate registration with different operation and no allowOverride
+        service.mapActionToOperation("testaction1", op3);
+        assertNull(service.getOperationByAction("testaction1"));
+        assertEquals(service.getOperationByAction("testaction2"), op2);
+    }
+    
     /**
      * Sameple MessageContextListener which sets a property 
      * on the MessageContext when the SerivceContext is attached.