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 sa...@apache.org on 2008/03/04 15:31:52 UTC

svn commit: r633485 [4/7] - in /webservices/axis2/trunk/java/modules: integration/test-resources/ integration/test-resources/ComplexDataTypes/ integration/test/org/apache/axis2/deployment/ integration/test/org/apache/axis2/engine/ integration/test/org/...

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=633485&r1=633484&r2=633485&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 Tue Mar  4 06:31:32 2008
@@ -42,182 +42,187 @@
 import java.util.Map;
 
 public abstract class AxisDescription implements ParameterInclude,
-        DescriptionConstants {
+		DescriptionConstants {
 
-    protected AxisDescription parent = null;
+	protected AxisDescription parent = null;
 
-    private ParameterInclude parameterInclude;
+	private ParameterInclude parameterInclude;
 
-    private PolicyInclude policyInclude = null;
+	private PolicyInclude policyInclude = null;
 
-    private Map children;
 
-    protected Map engagedModules;
+	private PolicySubject policySubject = null;
 
-    /** List of ParameterObservers who want to be notified of changes */
-    protected List parameterObservers = null;
+	private Map children;
 
-    private OMFactory omFactory = OMAbstractFactory.getOMFactory();
+	protected Map engagedModules;
 
-    // Holds the documentation details for each element
-    private OMNode documentation;
+	/** List of ParameterObservers who want to be notified of changes */
+	protected List parameterObservers = null;
 
-    // creating a logger instance
-    private Log log = LogFactory.getLog(this.getClass());
+	private OMFactory omFactory = OMAbstractFactory.getOMFactory();
+
+	// Holds the documentation details for each element
+	private OMNode documentation;
+
+	// creating a logger instance
+	private Log log = LogFactory.getLog(this.getClass());
 
     public AxisDescription() {
         parameterInclude = new ParameterIncludeImpl();
         children = new ConcurrentHashMap();
+        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;
-    }
-
-    public void setPolicyInclude(PolicyInclude policyInclude) {
-        this.policyInclude = policyInclude;
-    }
-
-    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 (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;
+	}
+
+	public void setPolicyInclude(PolicyInclude policyInclude) {
+		this.policyInclude = policyInclude;
+	}
+
+	public PolicyInclude getPolicyInclude() {
+		if (policyInclude == null) {
+			policyInclude = new PolicyInclude(this);
+		}
+		return policyInclude;
+	}
 
     // NOTE - These are NOT typesafe!
     public void addChild(AxisDescription child) {
@@ -229,13 +234,15 @@
         }
     }
 
-    public void addChild(Object key, AxisDescription child) {
-        children.put(key, child);
-    }
 
-    public Iterator getChildren() {
-        return children.values().iterator();
-    }
+
+	public void addChild(Object key, AxisDescription child) {
+		children.put(key, child);
+	}
+
+	public Iterator getChildren() {
+		return children.values().iterator();
+	}
 
     public AxisDescription getChild(Object key) {
         if(key == null) {
@@ -245,247 +252,253 @@
         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 {
-        AxisConfiguration configuration = getAxisConfiguration();
-
-        if (configuration == null) {
-            // FIXME return or throw an Exception?
-            return;
-        }
-
-        // sets AxisDescription policy
-        getPolicyInclude().setPolicy(policy);
-
-        /*
-         * now we should take the effective one .. it is necessary since
-         * AxisDescription.applyPolicy(..) doesn't override policies at the
-         * Upper levels.
-         */
-        Policy effPolicy = getPolicyInclude().getEffectivePolicy();
-
-        /*
-         * 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 = effPolicy.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 = configuration
-                    .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);
-            }
-        }
-
-        /*
-         * FIXME We need to disengage any modules that are already engaged *but*
-         * has nothing to do with the policy to apply
-         */
-
-        engageModulesToAxisDescription(modulesToEngage, this);
-    }
-
-    /**
-     * 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; // CHECKME: May be we need to throw an Exception ??
-        }
-
-        Policy effPolicy = getApplicablePolicy(this);
-
-        if (effPolicy != null) {
-
-            /*
-             * 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 = effPolicy.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 = configuration
-                        .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);
-                }
-            }
-
-            /*
-             * FIXME We need to disengage any modules that are already engaged
-             * *but* has nothing to do with the policy to apply
-             */
-
-            engageModulesToAxisDescription(modulesToEngage, this);
-
-        }
-
-        AxisDescription child;
-
-        for (Iterator children = getChildren(); children.hasNext();) {
-            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 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);
-    }
-
+	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 {
+		AxisConfiguration configuration = getAxisConfiguration();
+
+		if (configuration == null) {
+			// FIXME return or throw an Exception?
+			return;
+		}
+
+		// sets AxisDescription policy
+		getPolicyInclude().setPolicy(policy);
+
+		/*
+		 * now we should take the effective one .. it is necessary since
+		 * AxisDescription.applyPolicy(..) doesn't override policies at the
+		 * Upper levels.
+		 */
+		Policy effPolicy = getPolicyInclude().getEffectivePolicy();
+
+		/*
+		 * 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 = effPolicy.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 = configuration
+					.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);
+			}
+		}
+
+		/*
+		 * FIXME We need to disengage any modules that are already engaged *but*
+		 * has nothing to do with the policy to apply
+		 */
+
+		engageModulesToAxisDescription(modulesToEngage, this);
+	}
+
+	/**
+	 * 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; // CHECKME: May be we need to throw an Exception ??
+		}
+
+		Policy effPolicy = getApplicablePolicy(this);
+
+		if (effPolicy != null) {
+
+			/*
+			 * 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 = effPolicy.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 = configuration
+						.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);
+				}
+			}
+
+			/*
+			 * FIXME We need to disengage any modules that are already engaged
+			 * *but* has nothing to do with the policy to apply
+			 */
+
+			engageModulesToAxisDescription(modulesToEngage, this);
+
+		}
+
+		AxisDescription child;
+
+		for (Iterator children = getChildren(); children.hasNext();) {
+			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 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.
@@ -525,93 +538,109 @@
         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
-    }
+	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 AxisOperation) {
+			AxisOperation operation = (AxisOperation) axisDescription;
+			AxisService service = operation.getAxisService();
+
+			if (service != null) {
+
+				AxisEndpoint axisEndpoint = service.getEndpoint(service
+						.getEndpointName());
+
+				AxisBinding axisBinding = null;
+
+				if (axisEndpoint != null) {
+					axisBinding = axisEndpoint.getBinding();
+				}
+
+				AxisBindingOperation axisBindingOperation = null;
+
+				if (axisBinding != null) {
+					axisBindingOperation = (AxisBindingOperation) axisBinding
+							.getChild(operation.getName());
+				}
+
+				if (axisBindingOperation != null) {
+					return axisBindingOperation.getEffectivePolicy();
+				}
+			}
+
+			return operation.getPolicyInclude().getEffectivePolicy();
+
+		} else if (axisDescription instanceof AxisService) {
+			AxisService service = (AxisService) axisDescription;
+
+			AxisEndpoint axisEndpoint = service.getEndpoint(service
+					.getEndpointName());
+			AxisBinding axisBinding = null;
+
+			if (axisEndpoint != null) {
+				axisBinding = axisEndpoint.getBinding();
+			}
+
+			if (axisBinding != null) {
+				return axisBinding.getEffectivePolicy();
+			}
+
+			return service.getPolicyInclude().getEffectivePolicy();
+
+		} else {
+			return axisDescription.getPolicyInclude().getEffectivePolicy();
+		}
+	}
+
+	public PolicySubject getPolicySubject() {
+		return policySubject;
+	}
 
-    private Policy getApplicablePolicy(AxisDescription axisDescription) {
-
-        if (axisDescription instanceof AxisOperation) {
-            AxisOperation operation = (AxisOperation) axisDescription;
-            AxisService service = operation.getAxisService();
-
-            if (service != null) {
-
-                AxisEndpoint axisEndpoint = service.getEndpoint(service.getEndpointName());
-
-                AxisBinding axisBinding = null;
-
-                if (axisEndpoint != null) {
-                    axisBinding = axisEndpoint.getBinding();
-                }
-
-                AxisBindingOperation axisBindingOperation = null;
-
-                if (axisBinding != null) {
-                    axisBindingOperation = (AxisBindingOperation) axisBinding.getChild(operation.getName());
-                }
-
-                if (axisBindingOperation != null) {
-                    return axisBindingOperation.getEffectivePolicy();
-                }
-            }
-
-            return operation.getPolicyInclude().getEffectivePolicy();
-
-        } else if (axisDescription instanceof AxisService) {
-            AxisService service = (AxisService) axisDescription;
-
-            AxisEndpoint axisEndpoint = service.getEndpoint(service.getEndpointName());
-            AxisBinding axisBinding = null;
-
-            if (axisEndpoint != null) {
-                axisBinding = axisEndpoint.getBinding();
-            }
-
-            if (axisBinding != null) {
-                return axisBinding.getEffectivePolicy();
-            }
-
-            return service.getPolicyInclude().getEffectivePolicy();
-
-        } else {
-            return axisDescription.getPolicyInclude().getEffectivePolicy();
-        }
-    }
 }

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=633485&r1=633484&r2=633485&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 Tue Mar  4 06:31:32 2008
@@ -23,126 +23,188 @@
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.axis2.util.WSDLSerializationUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
+import java.net.SocketException;
 import java.util.HashMap;
 import java.util.Map;
 
 public class AxisEndpoint extends AxisDescription {
 
-    // The name of the endpoint
-    private String name;
+	private static final Log logger = LogFactory.getLog(AxisEndpoint.class);
 
-    // The binding reffered to by the endpoint
-    private AxisBinding binding;
+	// The name of the endpoint
+	private String name;
 
-    // The address of the endpoint
-    private String endpointURL;
+	// The binding reffered to by the endpoint
+	private AxisBinding binding;
 
-    // The alias used for the endpoint
-    private String alias;
-
-    private Map options;
-
-
-    public String getEndpointURL() {
-        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");
-    }
-
-    public OMElement toWSDL20(OMNamespace wsdl, OMNamespace tns, OMNamespace whttp, String epr) {
-        String property;
-        String name;
-        if (epr.startsWith("https://")) {
-            // The reason to do this is to have camel case
-            String endpointName = this.getName();
-            name = WSDL2Constants.DEFAULT_HTTPS_PREFIX + endpointName.substring(0,1).toUpperCase() + endpointName.substring(1);
-        } else {
-            name = this.getName();
-        }
-        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, epr));
-        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);
-        return endpointElement;
-    }
-
-    public AxisService getAxisService() {
-        return (AxisService)parent;
-    }
-
-    public void setParent(AxisService service) {
-        parent = service;
-    }
+	// 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");
+	}
+
+	public OMElement toWSDL20(OMNamespace wsdl, OMNamespace tns,
+			OMNamespace whttp, String epr) {
+		String property;
+		String name;
+		if (epr.startsWith("https://")) {
+			// The reason to do this is to have camel case
+			String endpointName = this.getName();
+			name = WSDL2Constants.DEFAULT_HTTPS_PREFIX
+					+ endpointName.substring(0, 1).toUpperCase()
+					+ endpointName.substring(1);
+		} else {
+			name = this.getName();
+		}
+		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, epr));
+		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);
+		return endpointElement;
+	}
+
+	public AxisService getAxisService() {
+		return (AxisService) parent;
+	}
+
+	public void setParent(AxisService service) {
+		parent = service;
+	}
+
+	public void setTransportInDescription(String transportInDescName) {
+		this.transportInDescName = transportInDescName;
+	}
+
+	private String calculateEndpointURL() {
+		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 = HttpUtils.getIpAddress(axisConfiguration);
+					EndpointReference[] eprsForService = listener
+							.getEPRsForService(serviceName, 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);
+				} catch (AxisFault e) {
+					logger.warn("", e);
+				}
+			}
+		}
+		
+		return null;
+	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org