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 gd...@apache.org on 2008/08/30 16:30:38 UTC

svn commit: r690515 [1/2] - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/deployment/ kernel/src/org/apache/axis2/description/ kernel/src/org/apache/axis2/engine/ kernel/test-resources/deployment/module1/META-INF/ kernel/test/or...

Author: gdaniels
Date: Sat Aug 30 07:30:37 2008
New Revision: 690515

URL: http://svn.apache.org/viewvc?rev=690515&view=rev
Log:
* Fix bug in comma processing multiple flows for <phase> tags in module.xml

* Test for above

* Make flow name comparison case-insensitive

* Some general code cleanup, moving to J5, and getting rid of IDE warnings

PLEASE WATCH YOUR FORMATTING WHEN YOU COMMIT, folks.  Spacing problems are bad
enough, but I actually removed a bunch of tabs here, and I bet there are more to be
found.  Code conventions exist so the code is consistent, easy to read, and 
manageable - please follow them.

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.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/AxisOperation.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/InOnlyAxisOperation.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/InOutAxisOperation.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DeployableChain.java
    webservices/axis2/trunk/java/modules/kernel/test-resources/deployment/module1/META-INF/module.xml
    webservices/axis2/trunk/java/modules/kernel/test/org/apache/axis2/deployment/DeploymentTotalTest.java
    webservices/axis2/trunk/java/modules/transports/src/org/apache/axis2/transport/http/HTTPTransportUtils.java

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=690515&r1=690514&r2=690515&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 Sat Aug 30 07:30:37 2008
@@ -28,7 +28,6 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisOperationFactory;
 import org.apache.axis2.description.InOnlyAxisOperation;
-import org.apache.axis2.description.PolicyInclude;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.Deployable;
 import org.apache.axis2.engine.MessageReceiver;
@@ -85,6 +84,11 @@
         }
     }
 
+    /**
+     * Fill in the AxisModule I'm holding from the module.xml configuration.
+     *
+     * @throws DeploymentException if there's a problem with the module.xml
+     */
     public void populateModule() throws DeploymentException {
         try {
             OMElement moduleElement = buildOM();
@@ -160,34 +164,29 @@
 
             // process INFLOW
             OMElement inFlow = moduleElement.getFirstChildWithName(new QName(TAG_FLOW_IN));
-
             if (inFlow != null) {
                 module.setInFlow(processFlow(inFlow, module));
             }
 
             OMElement outFlow = moduleElement.getFirstChildWithName(new QName(TAG_FLOW_OUT));
-
             if (outFlow != null) {
                 module.setOutFlow(processFlow(outFlow, module));
             }
 
             OMElement inFaultFlow =
                     moduleElement.getFirstChildWithName(new QName(TAG_FLOW_IN_FAULT));
-
             if (inFaultFlow != null) {
                 module.setFaultInFlow(processFlow(inFaultFlow, module));
             }
 
             OMElement outFaultFlow =
                     moduleElement.getFirstChildWithName(new QName(TAG_FLOW_OUT_FAULT));
-
             if (outFaultFlow != null) {
                 module.setFaultOutFlow(processFlow(outFaultFlow, module));
             }
 
             OMElement supportedPolicyNamespaces =
                     moduleElement.getFirstChildWithName(new QName(TAG_SUPPORTED_POLICY_NAMESPACES));
-
             if (supportedPolicyNamespaces != null) {
                 module.setSupportedPolicyNamespaces(
                         processSupportedPolicyNamespaces(supportedPolicyNamespaces));
@@ -199,7 +198,6 @@
             */
             OMElement localPolicyAssertionElement =
                     moduleElement.getFirstChildWithName(new QName("local-policy-assertions"));
-
             if (localPolicyAssertionElement != null) {
                 module.setLocalPolicyAssertions(
                         getLocalPolicyAssertionNames(localPolicyAssertionElement));
@@ -207,12 +205,10 @@
 
             // processing Operations
             Iterator op_itr = moduleElement.getChildrenWithName(new QName(TAG_OPERATION));
-            ArrayList operations = processOperations(op_itr);
+            ArrayList<AxisOperation> operations = processOperations(op_itr);
 
-            for (int i = 0; i < operations.size(); i++) {
-                AxisOperation operation = (AxisOperation) operations.get(i);
-
-                module.addOperation(operation);
+            for (AxisOperation op : operations) {
+                module.addOperation(op);
             }
 
         } catch (XMLStreamException e) {
@@ -222,33 +218,27 @@
         }
     }
 
-    private ArrayList processOperations(Iterator operationsIterator) throws DeploymentException {
+    private ArrayList<AxisOperation> processOperations(Iterator operationsIterator)
+            throws DeploymentException {
         ArrayList operations = new ArrayList();
 
         while (operationsIterator.hasNext()) {
             OMElement operation = (OMElement) operationsIterator.next();
+            AxisOperation op_descrip;
 
             //getting operation name
-            OMAttribute op_name_att = operation.getAttribute(new QName(ATTRIBUTE_NAME));
+            String opname = operation.getAttributeValue(new QName(ATTRIBUTE_NAME));
 
-            if (op_name_att == null) {
+            if (opname == null) {
                 throw new DeploymentException(
                         Messages.getMessage(
                                 Messages.getMessage(
                                         DeploymentErrorMsgs.INVALID_OP, "operation name missing")));
             }
 
-            OMAttribute op_mep_att = operation.getAttribute(new QName(TAG_MEP));
-            String mepURL = null;
-            AxisOperation op_descrip;
-
-            if (op_mep_att != null) {
-                mepURL = op_mep_att.getAttributeValue();
-            }
+            String mepURL = operation.getAttributeValue(new QName(TAG_MEP));
 
             if (mepURL == null) {
-
-                // assuming in-out MEP
                 op_descrip = new InOnlyAxisOperation();
             } else {
                 try {
@@ -262,8 +252,6 @@
                 }
             }
 
-            String opname = op_name_att.getAttributeValue();
-
             op_descrip.setName(new QName(opname));
 
             // Operation Parameters
@@ -287,19 +275,22 @@
                 MessageReceiver msgReceiver = loadDefaultMessageReceiver(mepURL, null);
                 op_descrip.setMessageReceiver(msgReceiver);
             }
+
             // Process Module Refs
             Iterator modules = operation.getChildrenWithName(new QName(TAG_MODULE));
             processOperationModuleRefs(modules, op_descrip);
             
 //          processing <wsp:Policy> .. </..> elements
-            Iterator policyElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
+            Iterator policyElements =
+                    operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
 
             if (policyElements != null && policyElements.hasNext()) {
                 processPolicyElements(policyElements, op_descrip.getPolicySubject());
             }
 
             // processing <wsp:PolicyReference> .. </..> elements
-            Iterator policyRefElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
+            Iterator policyRefElements =
+                    operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
 
             if (policyRefElements != null && policyRefElements.hasNext()) {
                 processPolicyRefElements(policyRefElements, module.getPolicySubject());
@@ -322,11 +313,14 @@
     }
 
     /**
-     * This will process the phase list and then added the phases specified in module.xml to
-     * axisConfiguration. The format of a phase element will something like
-     *  <phase name="Foo" after="After_phase_Name" before="Before_Phase_Name"
-     *  flow="[InFlow,OutFlow,OutFaultFlow,InFaultFlow]"/>
-     *  Here before and after can be null
+     * This will process the phase list and then add the specified phases to
+     * our AxisConfiguration.  The format of a phase element looks like this:
+     *
+     *  &lt;phase name="Foo" after="After_phase_Name" before="Before_Phase_Name"
+     *  flow="[InFlow,OutFlow,OutFaultFlow,InFaultFlow]"/&gt;
+     *
+     *  Here bef
+     *
      * @param phases : OMElement iterator
      * @throws AxisFault : If something went wrong
      */
@@ -334,6 +328,7 @@
         if (phases == null){
             return;
         }
+
         while (phases.hasNext()) {
             OMElement element = (OMElement) phases.next();
             String phaseName = element.getAttributeValue(new QName(ATTRIBUTE_NAME));
@@ -342,16 +337,14 @@
             String after = element.getAttributeValue(new QName(TAG_AFTER));
             if (after != null) {
                 String [] afters = after.split(",");
-                for (int i = 0; i < afters.length; i++) {
-                    String s = afters[i];
+                for (String s : afters) {
                     d.addPredecessor(s);
                 }
             }
             String before = element.getAttributeValue(new QName(TAG_BEFORE));
             if (before != null) {
                 String [] befores = before.split(",");
-                for (int i = 0; i < befores.length; i++) {
-                    String s = befores[i];
+                for (String s : befores) {
                     d.addSuccessor(s);
                 }
             }
@@ -361,16 +354,15 @@
                                               phaseName);
             }
             String[] flows = flowName.split(",");
-            for (int i = 0; i < flows.length; i++) {
-                String flow = flows[i];
+            for (String flow : flows) {
                 int flowIndex;
-                if (TAG_FLOW_IN.equals(flowName)){
-                    flowIndex = PhaseMetadata.IN_FLOW ;
-                } else if (TAG_FLOW_OUT.equals(flowName)) {
-                    flowIndex = PhaseMetadata.OUT_FLOW ;
-                } else if (TAG_FLOW_OUT_FAULT.equals(flowName)) {
+                if (TAG_FLOW_IN.equalsIgnoreCase(flow)) {
+                    flowIndex = PhaseMetadata.IN_FLOW;
+                } else if (TAG_FLOW_OUT.equalsIgnoreCase(flow)) {
+                    flowIndex = PhaseMetadata.OUT_FLOW;
+                } else if (TAG_FLOW_OUT_FAULT.equalsIgnoreCase(flow)) {
                     flowIndex = PhaseMetadata.FAULT_OUT_FLOW;
-                } else if (TAG_FLOW_IN_FAULT.equals(flowName)) {
+                } else if (TAG_FLOW_IN_FAULT.equalsIgnoreCase(flow)) {
                     flowIndex = PhaseMetadata.FAULT_IN_FLOW;
                 } else {
                     throw new DeploymentException("Unknown flow name '" + flow + "'");

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?rev=690515&r1=690514&r2=690515&view=diff
==============================================================================
--- 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 Sat Aug 30 07:30:37 2008
@@ -46,32 +46,30 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-public abstract class AxisDescription implements ParameterInclude,
-		DescriptionConstants {
+public abstract class AxisDescription implements ParameterInclude, DescriptionConstants {
 
-	protected AxisDescription parent = null;
+    protected AxisDescription parent = null;
 
-	private ParameterInclude parameterInclude;
+    private ParameterInclude parameterInclude;
 
-	private PolicyInclude policyInclude = null;
+    private PolicyInclude policyInclude = null;
 
+    private PolicySubject policySubject = null;
 
-	private PolicySubject policySubject = null;
+    private Map children;
 
-	private Map children;
+    protected Map engagedModules;
 
-	protected Map engagedModules;
+    /** List of ParameterObservers who want to be notified of changes */
+    protected List parameterObservers = null;
 
-	/** List of ParameterObservers who want to be notified of changes */
-	protected List parameterObservers = null;
+    private OMFactory omFactory = OMAbstractFactory.getOMFactory();
 
-	private OMFactory omFactory = OMAbstractFactory.getOMFactory();
+    // Holds the documentation details for each element
+    private OMNode documentation;
 
-	// Holds the documentation details for each element
-	private OMNode documentation;
-
-	// creating a logger instance
-	private static Log log = LogFactory.getLog(AxisDescription.class);
+    // creating a logger instance
+    private static Log log = LogFactory.getLog(AxisDescription.class);
 
     public AxisDescription() {
         parameterInclude = new ParameterIncludeImpl();
@@ -79,174 +77,173 @@
         policySubject = new PolicySubject();
     }
 
-	public void addParameterObserver(ParameterObserver observer) {
-		if (parameterObservers == null)
-			parameterObservers = new ArrayList();
-		parameterObservers.add(observer);
-	}
-
-	public void removeParameterObserver(ParameterObserver observer) {
-		if (parameterObservers != null) {
-			parameterObservers.remove(observer);
-		}
-	}
-
-	public void addParameter(Parameter param) throws AxisFault {
-		if (param == null) {
-			return;
-		}
-
-		if (isParameterLocked(param.getName())) {
-			throw new AxisFault(Messages.getMessage("paramterlockedbyparent",
-					param.getName()));
-		}
-
-		parameterInclude.addParameter(param);
-
-		// Tell anyone who wants to know
-		if (parameterObservers != null) {
-			for (Iterator i = parameterObservers.iterator(); i.hasNext();) {
-				ParameterObserver observer = (ParameterObserver) i.next();
-				observer.parameterChanged(param.getName(), param.getValue());
-			}
-		}
-	}
-
-	public void addParameter(String name, Object value) throws AxisFault {
-		addParameter(new Parameter(name, value));
-	}
-
-	public void removeParameter(Parameter param) throws AxisFault {
-		parameterInclude.removeParameter(param);
-	}
-
-	public void deserializeParameters(OMElement parameterElement)
-			throws AxisFault {
-
-		parameterInclude.deserializeParameters(parameterElement);
-
-	}
-
-	/**
-	 * If the parameter found in the current decription then the paremeter will
-	 * be writable else it will be read only
-	 * 
-	 * @param name
-	 * @return
-	 */
-	public Parameter getParameter(String name) {
-		Parameter parameter = parameterInclude.getParameter(name);
-		if (parameter != null) {
-			parameter.setEditable(true);
-			return parameter;
-		}
-		if (parent != null) {
-			parameter = parent.getParameter(name);
-			if (parameter != null) {
-				parameter.setEditable(false);
-			}
-			return parameter;
-		}
-		return null;
-	}
-
-	public Object getParameterValue(String name) {
-		Parameter param = getParameter(name);
-		if (param == null) {
-			return null;
-		}
-		return param.getValue();
-	}
-
-	public boolean isParameterTrue(String name) {
-		Parameter param = getParameter(name);
-		return param != null && JavaUtils.isTrue(param.getValue());
-	}
-
-	public ArrayList getParameters() {
-		return parameterInclude.getParameters();
-	}
-
-	public boolean isParameterLocked(String parameterName) {
-
-		if (this.parent != null && this.parent.isParameterLocked(parameterName)) {
-			return true;
-		}
-
-		Parameter parameter = getParameter(parameterName);
-		return parameter != null && parameter.isLocked();
-	}
-
-	public String getDocumentation() {
-		if (documentation != null) {
-			if (documentation.getType() == OMNode.TEXT_NODE) {
-				return ((OMText) documentation).getText();
-			} else {
-				StringWriter writer = new StringWriter();
-				documentation.build();
-				try {
-					documentation.serialize(writer);
-				} catch (XMLStreamException e) {
-					log.error(e);
-				}
-				writer.flush();
-				return writer.toString();
-			}
-		}
-		return null;
-	}
-
-	public OMNode getDocumentationNode() {
-		return documentation;
-	}
-
-	public void setDocumentation(OMNode documentation) {
-		this.documentation = documentation;
-	}
-
-	public void setDocumentation(String documentation) {
-		if (!"".equals(documentation)) {
-			this.documentation = omFactory.createOMText(documentation);
-		}
-	}
-
-	public void setParent(AxisDescription parent) {
-		this.parent = parent;
-	}
-
-	public AxisDescription getParent() {
-		return parent;
-	}
-
-	/**
-	 * @see org.apache.axis2.description.AxisDescription#setPolicyInclude(PolicyInclude)
-	 * @deprecated As of release 1.4, if you want to access the policy cache of
-	 *             a particular AxisDescription object use
-	 *             {@line #getPolicySubject()} instead.
-	 * 
-	 * @param policyInclude
-	 */
-	public void setPolicyInclude(PolicyInclude policyInclude) {
-		this.policyInclude = policyInclude;
-	}
-
-
-	/**
-	 * @see org.apache.axis2.description.AxisDescription#getPolicySubject()
-	 * @deprecated As of release 1.4, replaced by {@link #getPolicySubject()}
-	 */
-	public PolicyInclude getPolicyInclude() {
-		if (policyInclude == null) {
-			policyInclude = new PolicyInclude(this);
-		}
-		return policyInclude;
-	}
+    public void addParameterObserver(ParameterObserver observer) {
+        if (parameterObservers == null)
+            parameterObservers = new ArrayList();
+        parameterObservers.add(observer);
+    }
+
+    public void removeParameterObserver(ParameterObserver observer) {
+        if (parameterObservers != null) {
+            parameterObservers.remove(observer);
+        }
+    }
+
+    public void addParameter(Parameter param) throws AxisFault {
+        if (param == null) {
+            return;
+        }
+
+        if (isParameterLocked(param.getName())) {
+            throw new AxisFault(Messages.getMessage("paramterlockedbyparent",
+                                                    param.getName()));
+        }
+
+        parameterInclude.addParameter(param);
+
+        // Tell anyone who wants to know
+        if (parameterObservers != null) {
+            for (Object parameterObserver : parameterObservers) {
+                ParameterObserver observer = (ParameterObserver)parameterObserver;
+                observer.parameterChanged(param.getName(), param.getValue());
+            }
+        }
+    }
+
+    public void addParameter(String name, Object value) throws AxisFault {
+        addParameter(new Parameter(name, value));
+    }
+
+    public void removeParameter(Parameter param) throws AxisFault {
+        parameterInclude.removeParameter(param);
+    }
+
+    public void deserializeParameters(OMElement parameterElement)
+            throws AxisFault {
+
+        parameterInclude.deserializeParameters(parameterElement);
+
+    }
+
+    /**
+     * If the parameter is found in the current description then the Parameter will be writable else
+     * it will be read only
+     *
+     * @param name name of Parameter to retrieve
+     * @return the Parameter, if found anywhere in the stack, or null if not
+     */
+    public Parameter getParameter(String name) {
+        Parameter parameter = parameterInclude.getParameter(name);
+        if (parameter != null) {
+            parameter.setEditable(true);
+            return parameter;
+        }
+        if (parent != null) {
+            parameter = parent.getParameter(name);
+            if (parameter != null) {
+                parameter.setEditable(false);
+            }
+            return parameter;
+        }
+        return null;
+    }
+
+    public Object getParameterValue(String name) {
+        Parameter param = getParameter(name);
+        if (param == null) {
+            return null;
+        }
+        return param.getValue();
+    }
+
+    public boolean isParameterTrue(String name) {
+        Parameter param = getParameter(name);
+        return param != null && JavaUtils.isTrue(param.getValue());
+    }
+
+    public ArrayList getParameters() {
+        return parameterInclude.getParameters();
+    }
+
+    public boolean isParameterLocked(String parameterName) {
+
+        if (this.parent != null && this.parent.isParameterLocked(parameterName)) {
+            return true;
+        }
+
+        Parameter parameter = getParameter(parameterName);
+        return parameter != null && parameter.isLocked();
+    }
+
+    public String getDocumentation() {
+        if (documentation != null) {
+            if (documentation.getType() == OMNode.TEXT_NODE) {
+                return ((OMText)documentation).getText();
+            } else {
+                StringWriter writer = new StringWriter();
+                documentation.build();
+                try {
+                    documentation.serialize(writer);
+                } catch (XMLStreamException e) {
+                    log.error(e);
+                }
+                writer.flush();
+                return writer.toString();
+            }
+        }
+        return null;
+    }
+
+    public OMNode getDocumentationNode() {
+        return documentation;
+    }
+
+    public void setDocumentation(OMNode documentation) {
+        this.documentation = documentation;
+    }
+
+    public void setDocumentation(String documentation) {
+        if (!"".equals(documentation)) {
+            this.documentation = omFactory.createOMText(documentation);
+        }
+    }
+
+    public void setParent(AxisDescription parent) {
+        this.parent = parent;
+    }
+
+    public AxisDescription getParent() {
+        return parent;
+    }
+
+    /**
+     * @param policyInclude PolicyInclude value
+     * @see org.apache.axis2.description.AxisDescription#setPolicyInclude(PolicyInclude)
+     * @deprecated As of release 1.4, if you want to access the policy cache of a particular
+     *             AxisDescription object use {@link #getPolicySubject()} instead.
+     */
+    public void setPolicyInclude(PolicyInclude policyInclude) {
+        this.policyInclude = policyInclude;
+    }
+
+
+    /**
+     * @return the active PolicyInclue
+     * @see org.apache.axis2.description.AxisDescription#getPolicySubject()
+     * @deprecated As of release 1.4, replaced by {@link #getPolicySubject()}
+     */
+    public PolicyInclude getPolicyInclude() {
+        if (policyInclude == null) {
+            policyInclude = new PolicyInclude(this);
+        }
+        return policyInclude;
+    }
 
 
     // NOTE - These are NOT typesafe!
     public void addChild(AxisDescription child) {
         if (child.getKey() == null) {
-        // FIXME: Several classes that extend AxisDescription pass null in their getKey method.    
+            // FIXME: Several classes that extend AxisDescription pass null in their getKey method.
 //            throw new IllegalArgumentException("Please specify a key in the child");
         } else {
             children.put(child.getKey(), child);
@@ -254,230 +251,215 @@
     }
 
 
+    public void addChild(Object key, AxisDescription child) {
+        children.put(key, child);
+    }
 
-	public void addChild(Object key, AxisDescription child) {
-		children.put(key, child);
-	}
-
-	public Iterator getChildren() {
-		return children.values().iterator();
-	}
+    public Iterator getChildren() {
+        return children.values().iterator();
+    }
 
     public AxisDescription getChild(Object key) {
-        if(key == null) {
+        if (key == null) {
             // FIXME: Why are folks sending in null?
             return null;
         }
-        return (AxisDescription) children.get(key);
+        return (AxisDescription)children.get(key);
+    }
+
+    public void removeChild(Object key) {
+        children.remove(key);
+    }
+
+    /**
+     * This method sets the policy as the default of this AxisDescription instance. Further more
+     * this method does the followings. <p/> (1) Engage whatever modules necessary to execute new
+     * the effective policy of this AxisDescription instance. (2) Disengage whatever modules that
+     * are not necessary to execute the new effective policy of this AxisDescription instance. (3)
+     * Check whether each module can execute the new effective policy of this AxisDescription
+     * instance. (4) If not throw an AxisFault to notify the user. (5) Else notify each module about
+     * the new effective policy.
+     *
+     * @param policy the new policy of this AxisDescription instance. The effective policy is the
+     *               merge of this argument with effective policy of parent of this
+     *               AxisDescription.
+     * @throws AxisFault if any module is unable to execute the effective policy of this
+     *                   AxisDescription instance successfully or no module to execute some portion
+     *                   (one or more PrimtiveAssertions ) of that effective policy.
+     */
+    public void applyPolicy(Policy policy) throws AxisFault {
+        // sets AxisDescription policy
+        getPolicySubject().clear();
+        getPolicySubject().attachPolicy(policy);
+
+        /*
+           * now we try to engage appropriate modules based on the merged policy
+           * of axis description object and the corresponding axis binding
+           * description object.
+           */
+        applyPolicy();
+    }
+
+    /**
+     * Applies the policies on the Description Hierarchy recursively.
+     *
+     * @throws AxisFault an error occurred applying the policy
+     */
+    public void applyPolicy() throws AxisFault {
+        AxisConfiguration configuration = getAxisConfiguration();
+        if (configuration == null) {
+            return;
+        }
+
+        Policy applicablePolicy = getApplicablePolicy(this);
+        if (applicablePolicy != null) {
+            engageModulesForPolicy(applicablePolicy, configuration);
+        }
+
+        for (Iterator children = getChildren(); children.hasNext();) {
+            AxisDescription child = (AxisDescription)children.next();
+            child.applyPolicy();
+        }
+    }
+
+    private boolean canSupportAssertion(Assertion assertion, List moduleList) {
+
+        AxisModule axisModule;
+        Module module;
+
+        for (Object aModuleList : moduleList) {
+            axisModule = (AxisModule)aModuleList;
+            // FIXME is this step really needed ??
+            // Shouldn't axisMoudle.getModule always return not-null value ??
+            module = axisModule.getModule();
+
+            if (!(module == null || module.canSupportAssertion(assertion))) {
+                log.debug(axisModule.getName() + " says it can't support " + assertion.getName());
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    private void engageModulesForPolicy(Policy policy, AxisConfiguration axisConfiguration)
+            throws AxisFault {
+        /*
+           * for the moment we consider policies with only one alternative. If the
+           * policy contains multiple alternatives only the first alternative will
+           * be considered.
+           */
+        Iterator iterator = policy.getAlternatives();
+        if (!iterator.hasNext()) {
+            throw new AxisFault("Policy doesn't contain any policy alternatives");
+        }
+
+        List assertionList = (List)iterator.next();
+
+        Assertion assertion;
+        String namespaceURI;
+
+        List moduleList;
+
+        List namespaceList = new ArrayList();
+        List modulesToEngage = new ArrayList();
+
+        for (Object anAssertionList : assertionList) {
+            assertion = (Assertion)anAssertionList;
+            namespaceURI = assertion.getName().getNamespaceURI();
+
+            moduleList = axisConfiguration.getModulesForPolicyNamesapce(namespaceURI);
+
+            if (moduleList == null) {
+                log.debug("can't find any module to process " + assertion.getName() +
+                          " type assertions");
+                continue;
+            }
+
+            if (!canSupportAssertion(assertion, moduleList)) {
+                throw new AxisFault("atleast one module can't support " + assertion.getName());
+            }
+
+            if (!namespaceList.contains(namespaceURI)) {
+                namespaceList.add(namespaceURI);
+                modulesToEngage.addAll(moduleList);
+            }
+        }
+        engageModulesToAxisDescription(modulesToEngage, this);
+    }
+
+    private void engageModulesToAxisDescription(List moduleList, AxisDescription description)
+            throws AxisFault {
+
+        AxisModule axisModule;
+        Module module;
+
+        for (Object aModuleList : moduleList) {
+            axisModule = (AxisModule)aModuleList;
+            // FIXME is this step really needed ??
+            // Shouldn't axisMoudle.getModule always return not-null value ??
+            module = axisModule.getModule();
+
+            if (!(module == null || description.isEngaged(axisModule.getName()))) {
+                // engages the module to AxisDescription
+                description.engageModule(axisModule);
+                // notifies the module about the engagement
+                axisModule.getModule().engageNotify(description);
+            }
+        }
+    }
+
+    public AxisConfiguration getAxisConfiguration() {
+
+        if (this instanceof AxisConfiguration) {
+            return (AxisConfiguration)this;
+        }
+
+        if (this.parent != null) {
+            return this.parent.getAxisConfiguration();
+        }
+
+        return null;
+    }
+
+    public abstract Object getKey();
+
+
+    /**
+     * Engage a Module at this level
+     *
+     * @param axisModule the Module to engage
+     * @throws AxisFault if there's a problem engaging
+     */
+    public void engageModule(AxisModule axisModule) throws AxisFault {
+        engageModule(axisModule, this);
     }
 
-	public void removeChild(Object key) {
-		children.remove(key);
-	}
-
-	/**
-	 * This method sets the policy as the default of this AxisDescription
-	 * instance. Further more this method does the followings. <p/> (1) Engage
-	 * whatever modules necessary to execute new the effective policy of this
-	 * AxisDescription instance. (2) Disengage whatever modules that are not
-	 * necessary to execute the new effective policy of this AxisDescription
-	 * instance. (3) Check whether each module can execute the new effective
-	 * policy of this AxisDescription instance. (4) If not throw an AxisFault to
-	 * notify the user. (5) Else notify each module about the new effective
-	 * policy.
-	 * 
-	 * @param policy
-	 *            the new policy of this AxisDescription instance. The effective
-	 *            policy is the merge of this argument with effective policy of
-	 *            parent of this AxisDescription.
-	 * @throws AxisFault
-	 *             if any module is unable to execute the effective policy of
-	 *             this AxisDescription instance successfully or no module to
-	 *             execute some portion (one or more PrimtiveAssertions ) of
-	 *             that effective policy.
-	 */
-	public void applyPolicy(Policy policy) throws AxisFault {
-		// sets AxisDescription policy
-		getPolicySubject().clear();
-		getPolicySubject().attachPolicy(policy);
-
-		/*
-		 * now we try to engage appropriate modules based on the merged policy
-		 * of axis description object and the corresponding axis binding
-		 * description object.
-		 */
-		applyPolicy();
-	}
-
-	/**
-	 * Applies the policies on the Description Hierarchy recursively.
-	 * 
-	 * @throws AxisFault
-	 *             an error occurred applying the policy
-	 */
-	public void applyPolicy() throws AxisFault {
-		AxisConfiguration configuration = getAxisConfiguration();
-		if (configuration == null) {
-			return;
-		}
-
-		Policy applicablePolicy = getApplicablePolicy(this);
-		if (applicablePolicy != null) {
-			engageModulesForPolicy(this, applicablePolicy, configuration);
-		}
-
-		for (Iterator children = getChildren(); children.hasNext();) {
-			AxisDescription child = (AxisDescription) children.next();
-			child.applyPolicy();
-		}
-	}
-
-	private boolean canSupportAssertion(Assertion assertion, List moduleList) {
-
-		AxisModule axisModule;
-		Module module;
-
-		for (Iterator iterator = moduleList.iterator(); iterator.hasNext();) {
-			axisModule = (AxisModule) iterator.next();
-			// FIXME is this step really needed ??
-			// Shouldn't axisMoudle.getModule always return not-null value ??
-			module = axisModule.getModule();
-
-			if (!(module == null || module.canSupportAssertion(assertion))) {
-				log.debug(axisModule.getName() + " says it can't support "
-						+ assertion.getName());
-				return false;
-			}
-		}
-
-		return true;
-	}
-	
-	private void engageModulesForPolicy(AxisDescription axisDescription,
-			Policy policy, AxisConfiguration axisConfiguration)
-			throws AxisFault {
-		/*
-		 * for the moment we consider policies with only one alternative. If the
-		 * policy contains multiple alternatives only the first alternative will
-		 * be considered.
-		 */
-		Iterator iterator = policy.getAlternatives();
-		if (!iterator.hasNext()) {
-			throw new AxisFault(
-					"Policy doesn't contain any policy alternatives");
-		}
-
-		List assertionList = (List) iterator.next();
-
-		Assertion assertion;
-		String namespaceURI;
-
-		List moduleList;
-
-		List namespaceList = new ArrayList();
-		List modulesToEngage = new ArrayList();
-
-		for (Iterator assertions = assertionList.iterator(); assertions
-				.hasNext();) {
-			assertion = (Assertion) assertions.next();
-			namespaceURI = assertion.getName().getNamespaceURI();
-
-			moduleList = axisConfiguration
-					.getModulesForPolicyNamesapce(namespaceURI);
-
-			if (moduleList == null) {
-				log.debug("can't find any module to process "
-						+ assertion.getName() + " type assertions");
-				continue;
-			}
-
-			if (!canSupportAssertion(assertion, moduleList)) {
-				throw new AxisFault("atleast one module can't support "
-						+ assertion.getName());
-			}
-
-			if (!namespaceList.contains(namespaceURI)) {
-				namespaceList.add(namespaceURI);
-				modulesToEngage.addAll(moduleList);
-			}
-		}
-		engageModulesToAxisDescription(modulesToEngage, this);
-	}
-
-	private void engageModulesToAxisDescription(List moduleList,
-			AxisDescription description) throws AxisFault {
-
-		AxisModule axisModule;
-		Module module;
-
-		for (Iterator iterator = moduleList.iterator(); iterator.hasNext();) {
-			axisModule = (AxisModule) iterator.next();
-			// FIXME is this step really needed ??
-			// Shouldn't axisMoudle.getModule always return not-null value ??
-			module = axisModule.getModule();
-
-			if (!(module == null || description.isEngaged(axisModule.getName()))) {
-				// engages the module to AxisDescription
-				description.engageModule(axisModule);
-				// notifies the module about the engagement
-				axisModule.getModule().engageNotify(description);
-			}
-		}
-	}
-
-	public AxisConfiguration getAxisConfiguration() {
-
-		if (this instanceof AxisConfiguration) {
-			return (AxisConfiguration) this;
-		}
-
-		if (this.parent != null) {
-			return this.parent.getAxisConfiguration();
-		}
-
-		return null;
-	}
-
-	public abstract Object getKey();
-
-
-	/**
-	 * Engage a Module at this level
-	 * 
-	 * @param axisModule
-	 *            the Module to engage
-	 * @throws AxisFault
-	 *             if there's a problem engaging
-	 */
-	public void engageModule(AxisModule axisModule) throws AxisFault {
-		engageModule(axisModule, this);
-	}
-	
     /**
-     * Engage a Module at this level, keeping track of which level the engage was originally
-     * called from.  This is meant for internal use only.
+     * 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()
+     * @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 ConcurrentHashMap();
         String moduleName = axisModule.getName();
-        for (Iterator iterator = engagedModules.values().iterator(); iterator.hasNext();) {
-            AxisModule tempAxisModule = ((AxisModule) iterator.next());
+        for (Object o : engagedModules.values()) {
+            AxisModule tempAxisModule = ((AxisModule)o);
             String tempModuleName = tempAxisModule.getName();
 
             if (moduleName.equals(tempModuleName)) {
                 String existing = tempAxisModule.getVersion();
                 if (!Utils.checkVersion(axisModule.getVersion(), existing)) {
                     throw new AxisFault(Messages.getMessage("mismatchedModuleVersions",
-                            getClass().getName(),
-                            moduleName,
-                            existing));
+                                                            getClass().getName(),
+                                                            moduleName,
+                                                            existing));
                 }
             }
-            
+
         }
 
         // Let the Module know it's being engaged.  If it's not happy about it, it can throw.
@@ -492,101 +474,98 @@
         engagedModules.put(Utils.getModuleName(axisModule.getName(), axisModule.getVersion()),
                            axisModule);
     }
-    
-	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) {
-		return engagedModules != null
-				&& engagedModules.keySet().contains(moduleName);
-	}
-
-	public boolean isEngaged(AxisModule axisModule) {
-		String id = Utils.getModuleName(axisModule.getName(), axisModule
-				.getVersion());
-		return engagedModules != null && engagedModules.keySet().contains(id);
-	}
-
-	public void disengageModule(AxisModule module) throws AxisFault {
-		if (module == null || engagedModules == null)
-			return;
-		// String id = Utils.getModuleName(module.getName(),
-		// module.getVersion());
-		if (isEngaged(module)) {
-			onDisengage(module);
-			engagedModules.remove(Utils.getModuleName(module.getName(), module
-					.getVersion()));
-		}
-	}
-
-	protected void onDisengage(AxisModule module) throws AxisFault {
-		// Base version does nothing
-	}
-
-	private Policy getApplicablePolicy(AxisDescription axisDescription) {
-		if (axisDescription instanceof AxisMessage) {
-			AxisMessage axisMessage = (AxisMessage) axisDescription;
-			AxisOperation axisOperation = axisMessage.getAxisOperation();
-			if (axisOperation != null) {
-				AxisService axisService = (AxisService) axisOperation
-						.getAxisService();
-				if (axisService != null) {
-					if (axisService.getEndpointName() != null) {
-						AxisEndpoint axisEndpoint = axisService
-								.getEndpoint(axisService.getEndpointName());
-						if (axisEndpoint != null) {
-							AxisBinding axisBinding = axisEndpoint.getBinding();
-							AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisBinding
-									.getChild(axisOperation.getName());
-							String direction = axisMessage.getDirection();
-							AxisBindingMessage axisBindingMessage = null;
-							if (WSDLConstants.WSDL_MESSAGE_DIRECTION_IN
-									.equals(direction)
-									&& WSDLUtil
-											.isInputPresentForMEP(axisOperation
-													.getMessageExchangePattern())) {
-								axisBindingMessage = (AxisBindingMessage) axisBindingOperation
-										.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-								return axisBindingMessage.getEffectivePolicy();
-								
-							} else if (WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT
-									.equals(direction)
-									&& WSDLUtil
-											.isOutputPresentForMEP(axisOperation
-													.getMessageExchangePattern())) {
-								axisBindingMessage = (AxisBindingMessage) axisBindingOperation
-										.getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
-								return axisBindingMessage.getEffectivePolicy();
-							}
-						}
-
-					}
-				}
-			}
-			return ((AxisMessage) axisDescription).getEffectivePolicy();
-		}
-		return null;
-	}
-
-	public PolicySubject getPolicySubject() {
-		return policySubject;
-	}
+
+    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) {
+        return engagedModules != null
+               && engagedModules.keySet().contains(moduleName);
+    }
+
+    public boolean isEngaged(AxisModule axisModule) {
+        String id = Utils.getModuleName(axisModule.getName(), axisModule
+                .getVersion());
+        return engagedModules != null && engagedModules.keySet().contains(id);
+    }
+
+    public void disengageModule(AxisModule module) throws AxisFault {
+        if (module == null || engagedModules == null)
+            return;
+        // String id = Utils.getModuleName(module.getName(),
+        // module.getVersion());
+        if (isEngaged(module)) {
+            onDisengage(module);
+            engagedModules.remove(Utils.getModuleName(module.getName(), module
+                    .getVersion()));
+        }
+    }
+
+    protected void onDisengage(AxisModule module) throws AxisFault {
+        // Base version does nothing
+    }
+
+    private Policy getApplicablePolicy(AxisDescription axisDescription) {
+        if (axisDescription instanceof AxisMessage) {
+            AxisMessage axisMessage = (AxisMessage)axisDescription;
+            AxisOperation axisOperation = axisMessage.getAxisOperation();
+            if (axisOperation != null) {
+                AxisService axisService = axisOperation.getAxisService();
+                if (axisService != null) {
+                    if (axisService.getEndpointName() != null) {
+                        AxisEndpoint axisEndpoint =
+                                axisService.getEndpoint(axisService.getEndpointName());
+                        if (axisEndpoint != null) {
+                            AxisBinding axisBinding = axisEndpoint.getBinding();
+                            AxisBindingOperation axisBindingOperation =
+                                    (AxisBindingOperation)axisBinding
+                                            .getChild(axisOperation.getName());
+                            String direction = axisMessage.getDirection();
+                            AxisBindingMessage axisBindingMessage;
+                            if (WSDLConstants.WSDL_MESSAGE_DIRECTION_IN.equals(direction)
+                                && WSDLUtil
+                                    .isInputPresentForMEP(axisOperation
+                                            .getMessageExchangePattern())) {
+                                axisBindingMessage = (AxisBindingMessage)axisBindingOperation
+                                        .getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+                                return axisBindingMessage.getEffectivePolicy();
+
+                            } else if (WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT
+                                    .equals(direction)
+                                       && WSDLUtil
+                                    .isOutputPresentForMEP(axisOperation
+                                            .getMessageExchangePattern())) {
+                                axisBindingMessage = (AxisBindingMessage)axisBindingOperation
+                                        .getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+                                return axisBindingMessage.getEffectivePolicy();
+                            }
+                        }
+
+                    }
+                }
+            }
+            return ((AxisMessage)axisDescription).getEffectivePolicy();
+        }
+        return null;
+    }
+
+    public PolicySubject getPolicySubject() {
+        return policySubject;
+    }
 
 }

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?rev=690515&r1=690514&r2=690515&view=diff
==============================================================================
--- 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 Sat Aug 30 07:30:37 2008
@@ -27,8 +27,8 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.transport.TransportListener;
-import org.apache.axis2.util.WSDLSerializationUtil;
 import org.apache.axis2.util.Utils;
+import org.apache.axis2.util.WSDLSerializationUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -38,196 +38,189 @@
 
 public class AxisEndpoint extends AxisDescription {
 
-	private static final Log logger = LogFactory.getLog(AxisEndpoint.class);
+    private static final Log logger = LogFactory.getLog(AxisEndpoint.class);
 
-	// The name of the endpoint
-	private String name;
+    // The name of the endpoint
+    private String name;
 
-	// The binding reffered to by the endpoint
-	private AxisBinding binding;
+    // The binding reffered to by the endpoint
+    private AxisBinding binding;
 
-	// The address of the endpoint
-	private String endpointURL;
-
-	// The alias used for the endpoint
-	private String alias;
-
-	private Map options;
-
-	private String transportInDescName;
-
-	public String getEndpointURL() {
-		if (endpointURL == null) {
-			endpointURL = calculateEndpointURL();
-		}
-		return endpointURL;
-	}
-
-	public void setEndpointURL(String endpointURL) {
-		this.endpointURL = endpointURL;
-	}
-
-	public AxisEndpoint() {
-		options = new HashMap();
-	}
-
-	public void setProperty(String name, Object value) {
-		options.put(name, value);
-	}
-
-	/**
-	 * @param name
-	 *            name of the property to search for
-	 * @return the value of the property, or null if the property is not found
-	 */
-	public Object getProperty(String name) {
-		Object obj = options.get(name);
-		if (obj != null) {
-			return obj;
-		}
-
-		return null;
-	}
-
-	public String getAlias() {
-		return alias;
-	}
-
-	public void setAlias(String alias) {
-		this.alias = alias;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public AxisBinding getBinding() {
-		return binding;
-	}
-
-	public void setBinding(AxisBinding binding) {
-		this.binding = binding;
-	}
-
-	public Object getKey() {
-		// ToDO
-		return null; // To change body of implemented methods use File |
-		// Settings | File Templates.
-	}
-
-	public void engageModule(AxisModule axisModule) throws AxisFault {
-		throw new UnsupportedOperationException("Sorry we do not support this");
-	}
-
-	public boolean isEngaged(String moduleName) {
-		throw new UnsupportedOperationException(
-				"axisMessage.isEngaged() is not supported");
-	}
+    // The address of the endpoint
+    private String endpointURL;
+
+    // The alias used for the endpoint
+    private String alias;
+
+    private Map options;
+
+    private String transportInDescName;
+
+    public String getEndpointURL() {
+        if (endpointURL == null) {
+            endpointURL = calculateEndpointURL();
+        }
+        return endpointURL;
+    }
+
+    public void setEndpointURL(String endpointURL) {
+        this.endpointURL = endpointURL;
+    }
+
+    public AxisEndpoint() {
+        options = new HashMap();
+    }
+
+    public void setProperty(String name, Object value) {
+        options.put(name, value);
+    }
+
+    /**
+     * @param name name of the property to search for
+     * @return the value of the property, or null if the property is not found
+     */
+    public Object getProperty(String name) {
+        Object obj = options.get(name);
+        if (obj != null) {
+            return obj;
+        }
+
+        return null;
+    }
+
+    public String getAlias() {
+        return alias;
+    }
+
+    public void setAlias(String alias) {
+        this.alias = alias;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public AxisBinding getBinding() {
+        return binding;
+    }
+
+    public void setBinding(AxisBinding binding) {
+        this.binding = binding;
+    }
+
+    public Object getKey() {
+        // ToDO
+        return null; // To change body of implemented methods use File |
+        // Settings | File Templates.
+    }
+
+    public void engageModule(AxisModule axisModule) throws AxisFault {
+        // TODO - We totally should support this.  Endpoint Policy Subject, anyone?
+        throw new UnsupportedOperationException("Sorry we do not support this");
+    }
+
+    public boolean isEngaged(String moduleName) {
+        throw new UnsupportedOperationException("axisMessage.isEngaged() is not supported");
+    }
 
     public OMElement toWSDL20(OMNamespace wsdl, OMNamespace tns, OMNamespace whttp) {
-		String property;
-		OMFactory omFactory = OMAbstractFactory.getOMFactory();
-		OMElement endpointElement = omFactory.createOMElement(
-				WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
-		endpointElement.addAttribute(omFactory.createOMAttribute(
-				WSDL2Constants.ATTRIBUTE_NAME, null, name));
-		endpointElement.addAttribute(omFactory.createOMAttribute(
-				WSDL2Constants.BINDING_LOCAL_NAME, null, tns.getPrefix() + ":"
-						+ getBinding().getName().getLocalPart()));
-		endpointElement.addAttribute(omFactory.createOMAttribute(
-				WSDL2Constants.ATTRIBUTE_ADDRESS, null, getEndpointURL()));
-		Object authenticationScheme = this.options
-				.get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE);
-		if (authenticationScheme != null) {
-			endpointElement.addAttribute(omFactory.createOMAttribute(
-					WSDL2Constants.ATTRIBUTE_AUTHENTICATION_TYPE, whttp,
-					authenticationScheme.toString()));
-		}
-		property = (String) options
-				.get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_REALM);
-		if (property != null) {
-			endpointElement.addAttribute(omFactory.createOMAttribute(
-					WSDL2Constants.ATTRIBUTE_AUTHENTICATION_REALM, whttp,
-					property));
-		}
-		WSDLSerializationUtil.addWSDLDocumentationElement(this,
-				endpointElement, omFactory, wsdl);
-		WSDLSerializationUtil.addPoliciesAsExtensibleElement(this,
-				endpointElement);
-		return endpointElement;
-	}
-
-	public AxisService getAxisService() {
-		return (AxisService) parent;
-	}
-
-	public void setParent(AxisService service) {
-		parent = service;
-	}
-
-	public void setTransportInDescription(String transportInDescName) {
-		this.transportInDescName = transportInDescName;
-	}
-
-	public String calculateEndpointURL() {
-	    return calculateEndpointURL(null);
-	}
-	
-        public String calculateEndpointURL(String hostIP) {
-            if (transportInDescName != null && parent != null) {
-                    AxisConfiguration axisConfiguration = getAxisConfiguration();
-                    if (axisConfiguration != null) {
-                            try {
-                                    String serviceName = ((AxisService) parent).getName();
-                                    TransportInDescription in = axisConfiguration
-                                                    .getTransportIn(transportInDescName);
-                                    TransportListener listener = in.getReceiver();
-                                    String ip;
-                                    
-                                    if (hostIP != null) {
-                                        ip = hostIP;
-                                    } else {    
-                                        ip = Utils.getIpAddress(axisConfiguration);
-                                    }
-                                    
-                                    // we should pass [serviceName].[endpointName] instead of
-                                    // [endpointName]
-                                    String sDOTe = serviceName + "." + name;
-                                    EndpointReference[] eprsForService = listener
-                                                    .getEPRsForService(sDOTe, ip);
-                                    // we consider only the first address return by the listener
-                                    if (eprsForService != null && eprsForService.length > 0) {
-                                            return eprsForService[0].getAddress();
-                                    }
-                            } catch (SocketException e) {
-                                    logger.warn(e.getMessage(), e);
-                            } catch (AxisFault e) {
-                                    logger.warn(e.getMessage(), e);
-                            }
+        String property;
+        OMFactory omFactory = OMAbstractFactory.getOMFactory();
+        OMElement endpointElement =
+                omFactory.createOMElement(WSDL2Constants.ENDPOINT_LOCAL_NAME, wsdl);
+        endpointElement.addAttribute(
+                omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_NAME, null, name));
+        endpointElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.BINDING_LOCAL_NAME,
+                                                                 null, tns.getPrefix() + ":" +
+                                                                       getBinding().getName()
+                                                                               .getLocalPart()));
+        endpointElement.addAttribute(omFactory.createOMAttribute(WSDL2Constants.ATTRIBUTE_ADDRESS,
+                                                                 null, getEndpointURL()));
+        Object authenticationScheme =
+                this.options.get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_TYPE);
+        if (authenticationScheme != null) {
+            endpointElement.addAttribute(omFactory.createOMAttribute(
+                    WSDL2Constants.ATTRIBUTE_AUTHENTICATION_TYPE, whttp,
+                    authenticationScheme.toString()));
+        }
+        property = (String)options.get(WSDL2Constants.ATTR_WHTTP_AUTHENTICATION_REALM);
+        if (property != null) {
+            endpointElement.addAttribute(omFactory.createOMAttribute(
+                    WSDL2Constants.ATTRIBUTE_AUTHENTICATION_REALM, whttp, property));
+        }
+        WSDLSerializationUtil.addWSDLDocumentationElement(this, endpointElement, omFactory, wsdl);
+        WSDLSerializationUtil.addPoliciesAsExtensibleElement(this, endpointElement);
+        return endpointElement;
+    }
+
+    public AxisService getAxisService() {
+        return (AxisService)parent;
+    }
+
+    public void setParent(AxisService service) {
+        parent = service;
+    }
+
+    public void setTransportInDescription(String transportInDescName) {
+        this.transportInDescName = transportInDescName;
+    }
+
+    public String calculateEndpointURL() {
+        return calculateEndpointURL(null);
+    }
+
+    public String calculateEndpointURL(String hostIP) {
+        if (transportInDescName != null && parent != null) {
+            AxisConfiguration axisConfiguration = getAxisConfiguration();
+            if (axisConfiguration != null) {
+                try {
+                    String serviceName = ((AxisService)parent).getName();
+                    TransportInDescription in =
+                            axisConfiguration.getTransportIn(transportInDescName);
+                    TransportListener listener = in.getReceiver();
+                    String ip;
+
+                    if (hostIP != null) {
+                        ip = hostIP;
+                    } else {
+                        ip = Utils.getIpAddress(axisConfiguration);
                     }
+
+                    // we should pass [serviceName].[endpointName] instead of
+                    // [endpointName]
+                    String sDOTe = serviceName + "." + name;
+                    EndpointReference[] eprsForService = listener.getEPRsForService(sDOTe, ip);
+                    // we consider only the first address return by the listener
+                    if (eprsForService != null && eprsForService.length > 0) {
+                        return eprsForService[0].getAddress();
+                    }
+                } catch (SocketException e) {
+                    logger.warn(e.getMessage(), e);
+                } catch (AxisFault e) {
+                    logger.warn(e.getMessage(), e);
+                }
             }
+        }
 
-            return null;
-        }	
+        return null;
+    }
 
-	public boolean isActive() {
-		if (transportInDescName != null && parent != null) {
-			AxisConfiguration axisConfiguration = getAxisConfiguration();
-			if (axisConfiguration != null) {
-				AxisService service = (AxisService) parent;
-				if (service.isEnableAllTransports()) {
-					return axisConfiguration.getTransportsIn().containsKey(
-							transportInDescName);
-				} else {
-					return service.getExposedTransports().contains(
-							transportInDescName);
-				}
-			}
-		}
-		return false;
-	}
+    public boolean isActive() {
+        if (transportInDescName != null && parent != null) {
+            AxisConfiguration axisConfiguration = getAxisConfiguration();
+            if (axisConfiguration != null) {
+                AxisService service = (AxisService)parent;
+                if (service.isEnableAllTransports()) {
+                    return axisConfiguration.getTransportsIn().containsKey(transportInDescName);
+                } else {
+                    return service.getExposedTransports().contains(transportInDescName);
+                }
+            }
+        }
+        return false;
+    }
 }

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?rev=690515&r1=690514&r2=690515&view=diff
==============================================================================
--- 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 Sat Aug 30 07:30:37 2008
@@ -40,8 +40,8 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Set;
 import java.util.LinkedHashMap;
+import java.util.Set;
 
 public abstract class AxisOperation extends AxisDescription
         implements WSDLConstants {
@@ -51,9 +51,7 @@
     public static final String STYLE_DOC = "doc";
 
     private static final Log log = LogFactory.getLog(AxisOperation.class);
-    /**
-     * message exchange pattern
-     */
+    /** message exchange pattern */
     private int mep = WSDLConstants.MEP_CONSTANT_INVALID;
 
     // to hide control operation , operation which added by RM like module
@@ -61,7 +59,7 @@
     private String style = STYLE_DOC;
 
     // to store mepURL
-    private String mepURI;
+    protected String mepURI;
 
     private MessageReceiver messageReceiver;
 
@@ -81,9 +79,7 @@
     private String soapAction;
 
 
-    /**
-     * constructor
-     */
+    /** Default constructor */
     public AxisOperation() {
         mepURI = WSDL2Constants.MEP_URI_IN_OUT;
         modulerefs = new ArrayList();
@@ -102,12 +98,10 @@
     public abstract void addMessage(AxisMessage message, String label);
 
     /**
-     * Adds a message context into an operation context. Depending on MEPs, this
-     * method has to be overridden.
-     * Depending on the MEP operation description know how to fill the message context map
-     * in operationContext.
-     * As an example, if the MEP is IN-OUT then depending on messagable operation description
-     * should know how to keep them in correct locations.
+     * Adds a message context into an operation context. Depending on MEPs, this method has to be
+     * overridden. Depending on the MEP operation description know how to fill the message context
+     * map in operationContext. As an example, if the MEP is IN-OUT then depending on messagable
+     * operation description should know how to keep them in correct locations.
      *
      * @param msgContext <code>MessageContext</code>
      * @param opContext  <code>OperationContext</code>
@@ -127,18 +121,17 @@
     /**
      * Adds module configuration, if there is moduleConfig tag in operation.
      *
-     * @param moduleConfiguration
+     * @param moduleConfiguration a ModuleConfiguration which will be added (by name)
      */
     public void addModuleConfig(ModuleConfiguration moduleConfiguration) {
         moduleConfigmap.put(moduleConfiguration.getModuleName(), moduleConfiguration);
     }
 
     /**
-     * This is called when a module is engaged on this operation.  Handle operation-specific
-     * tasks.
+     * This is called when a module is engaged on this operation.  Handle operation-specific tasks.
      *
-     * @param axisModule AxisModule
-     * @param engager
+     * @param axisModule AxisModule being engaged
+     * @param engager    the AxisDescription where the engage occurred - could be us or a parent
      * @throws AxisFault
      */
     public final void onEngage(AxisModule axisModule, AxisDescription engager) throws AxisFault {
@@ -165,7 +158,7 @@
         AxisConfiguration axisConfiguration = service.getAxisConfiguration();
         PhaseResolver phaseResolver = new PhaseResolver(axisConfiguration);
         if (!service.isEngaged(module.getName()) &&
-                (axisConfiguration != null && !axisConfiguration.isEngaged(module.getName()))) {
+            (axisConfiguration != null && !axisConfiguration.isEngaged(module.getName()))) {
             phaseResolver.disengageModuleFromGlobalChains(module);
         }
         phaseResolver.disengageModuleFromOperationChain(module, this);
@@ -175,7 +168,7 @@
         if (moduleOperations != null) {
             Iterator moduleOperations_itr = moduleOperations.values().iterator();
             while (moduleOperations_itr.hasNext()) {
-                AxisOperation operation = (AxisOperation) moduleOperations_itr.next();
+                AxisOperation operation = (AxisOperation)moduleOperations_itr.next();
                 service.removeOperation(operation.getName());
             }
         }
@@ -196,50 +189,16 @@
         }
     }
 
-    /**
-     * Gets a copy from module operation.
-     *
-     * @param axisOperation
-     * @return Returns AxisOperation.
-     * @throws AxisFault
-     */
-    private AxisOperation copyOperation(AxisOperation axisOperation) throws AxisFault {
-        AxisOperation operation =
-                AxisOperationFactory
-                        .getOperationDescription(axisOperation.getMessageExchangePattern());
-
-        operation.setMessageReceiver(axisOperation.getMessageReceiver());
-        operation.setName(axisOperation.getName());
-
-        Iterator parameters = axisOperation.getParameters().iterator();
-
-        while (parameters.hasNext()) {
-            Parameter parameter = (Parameter) parameters.next();
-
-            operation.addParameter(parameter);
-        }
-
-        operation.setWsamappingList(axisOperation.getWSAMappingList());
-        operation.setOutputAction(axisOperation.getOutputAction());
-        String[] faultActionNames = axisOperation.getFaultActionNames();
-        for (int i = 0; i < faultActionNames.length; i++) {
-            operation.addFaultAction(faultActionNames[i],
-                                     axisOperation.getFaultAction(faultActionNames[i]));
-        }
-        operation.setRemainingPhasesInFlow(axisOperation.getRemainingPhasesInFlow());
-        operation.setPhasesInFaultFlow(axisOperation.getPhasesInFaultFlow());
-        operation.setPhasesOutFaultFlow(axisOperation.getPhasesOutFaultFlow());
-        operation.setPhasesOutFlow(axisOperation.getPhasesOutFlow());
-
-        return operation;
-    }
-
+//  Note - removed this method which was dead code.
+//    private AxisOperation copyOperation(AxisOperation axisOperation) throws AxisFault {
 
     /**
      * Returns as existing OperationContext related to this message if one exists.
+     * <p/>
+     * TODO - why both this and findOperationContext()? (GD)
      *
-     * @param msgContext
-     * @return Returns OperationContext.
+     * @param msgContext the MessageContext for which we'd like an OperationContext
+     * @return the OperationContext, or null
      * @throws AxisFault
      */
     public OperationContext findForExistingOperationContext(MessageContext msgContext)
@@ -261,8 +220,8 @@
 
             if (null == operationContext && log.isDebugEnabled()) {
                 log.debug(msgContext.getLogIDString() +
-                        " Cannot correlate inbound message RelatesTo value [" +
-                        msgContext.getRelatesTo() + "] to in-progree MEP");
+                          " Cannot correlate inbound message RelatesTo value [" +
+                          msgContext.getRelatesTo() + "] to in-progree MEP");
             }
         }
 
@@ -270,25 +229,25 @@
     }
 
     /**
-     * Finds a MEPContext for an incoming message. An incoming message can be
-     * of two states.
+     * Finds an OperationContext for an incoming message. An incoming message can be of two states.
      * <p/>
-     * 1)This is a new incoming message of a given MEP. 2)This message is a
-     * part of an MEP which has already begun.
+     * 1)This is a new incoming message of a given MEP. 2)This message is a part of an MEP which has
+     * already begun.
      * <p/>
      * The method is special cased for the two MEPs
      * <p/>
      * #IN_ONLY #IN_OUT
      * <p/>
-     * for two reasons. First reason is the wide usage and the second being that
-     * the need for the MEPContext to be saved for further incoming messages.
+     * for two reasons. First reason is the wide usage and the second being that the need for the
+     * MEPContext to be saved for further incoming messages.
      * <p/>
-     * In the event that MEP of this operation is different from the two MEPs
-     * defaulted above the decision of creating a new or this message relates
-     * to a MEP which already in business is decided by looking at the WSA
-     * Relates TO of the incoming message.
+     * In the event that MEP of this operation is different from the two MEPs defaulted above the
+     * decision of creating a new or this message relates to a MEP which already in business is
+     * decided by looking at the WSA Relates TO of the incoming message.
      *
-     * @param msgContext
+     * @param msgContext     MessageContext to search
+     * @param serviceContext ServiceContext (TODO - why pass this? (GD))
+     * @return the active OperationContext
      */
     public OperationContext findOperationContext(MessageContext msgContext,
                                                  ServiceContext serviceContext)
@@ -341,9 +300,11 @@
     }
 
     /**
-     * Maps the String URI of the Message exchange pattern to a integer.
-     * Further, in the first lookup, it will cache the looked
-     * up value so that the subsequent method calls are extremely efficient.
+     * Maps the String URI of the Message exchange pattern to an integer. Further, in the first
+     * lookup, it will cache the looked up value so that the subsequent method calls are extremely
+     * efficient.
+     *
+     * @return an MEP constant from WSDLConstants
      */
     public int getAxisSpecificMEPConstant() {
         if (this.mep != WSDLConstants.MEP_CONSTANT_INVALID) {
@@ -396,7 +357,7 @@
     }
 
     public ModuleConfiguration getModuleConfig(String moduleName) {
-        return (ModuleConfiguration) moduleConfigmap.get(moduleName);
+        return (ModuleConfiguration)moduleConfigmap.get(moduleName);
     }
 
     public ArrayList getModuleRefs() {
@@ -481,12 +442,13 @@
     }
 
     /**
-     * 
+     * Return an OperationClient suitable for this AxisOperation.
+     *
+     * @param sc      active ServiceContext
+     * @param options active Options
+     * @return an OperationClient set up appropriately for this operation
      */
-    public OperationClient createClient(ServiceContext sc, Options options) {
-        throw new UnsupportedOperationException(
-                Messages.getMessage("mepnotyetimplemented", mepURI));
-    }
+    public abstract OperationClient createClient(ServiceContext sc, Options options);
 
     public Object getKey() {
         return this.name;
@@ -499,34 +461,34 @@
     public void setFaultMessages(AxisMessage faultMessage) {
         faultMessage.setParent(this);
         faultMessages.add(faultMessage);
-        if(getFaultAction(faultMessage.getName())==null){
-            addFaultAction(faultMessage.getName(),"urn:" + name.getLocalPart()
-                    + faultMessage.getName());
+        if (getFaultAction(faultMessage.getName()) == null) {
+            addFaultAction(faultMessage.getName(),
+                           "urn:" + name.getLocalPart() + faultMessage.getName());
         }
     }
 
     public void setSoapAction(String soapAction) {
         this.soapAction = soapAction;
     }
-    
+
     /*
-     * Convenience method to access the WS-A Input Action per the
-     * WS-A spec. Effectively use the soapAction if available else
-     * use the first entry in the WSA Mapping list.
-     * 
-     * Use getSoapAction when you want to get the soap action and this
-     * when you want to get the wsa input action.
-     */
+    * Convenience method to access the WS-A Input Action per the
+    * WS-A spec. Effectively use the soapAction if available else
+    * use the first entry in the WSA Mapping list.
+    *
+    * Use getSoapAction when you want to get the soap action and this
+    * when you want to get the wsa input action.
+    */
     public String getInputAction() {
-    	String result = null;
-    	if(soapAction != null && !"".equals(soapAction)){
-    		result = soapAction;
-    	}else{
-    		if(wsamappingList != null && !wsamappingList.isEmpty()){
-    			result = (String)wsamappingList.get(0);
-    		}
-    	}
-    	return result;
+        String result = null;
+        if (soapAction != null && !"".equals(soapAction)) {
+            result = soapAction;
+        } else {
+            if (wsamappingList != null && !wsamappingList.isEmpty()) {
+                result = (String)wsamappingList.get(0);
+            }
+        }
+        return result;
     }
 
     public String getOutputAction() {
@@ -546,13 +508,13 @@
     }
 
     public String getFaultAction(String faultName) {
-        return (String) faultActions.get(faultName);
+        return (String)faultActions.get(faultName);
     }
 
     public String[] getFaultActionNames() {
         Set keys = faultActions.keySet();
         String[] faultActionNames = new String[keys.size()];
-        faultActionNames = (String[]) keys.toArray(faultActionNames);
+        faultActionNames = (String[])keys.toArray(faultActionNames);
         return faultActionNames;
     }
 
@@ -560,17 +522,17 @@
         String result = null;
         Iterator iter = faultActions.values().iterator();
         if (iter.hasNext()) {
-            result = (String) iter.next();
+            result = (String)iter.next();
         }
         return result;
     }
-    
+
     /**
-     * All childerns of a AxisOperation must be Messages. So we just return it. 
-     * @return
+     * Get the messages referenced by this operation
+     *
+     * @return an Iterator of all the AxisMessages we deal with
      */
-    
-    public Iterator getMessages(){
+    public Iterator getMessages() {
         return getChildren();
     }
 
@@ -583,7 +545,7 @@
         return (AxisService)getParent();
     }
 
-	public String getSoapAction() {
+    public String getSoapAction() {
         /*
          * This AxisOperation instance may be used for the client OUT-IN or for
          * the server IN-OUT.  If the below code were changed to getInputActions, and the
@@ -592,6 +554,5 @@
          * this as 'return soapAction;' OR make it client/server aware.
          */
         return soapAction;
-	}
-    
- }
+    }
+}