You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/10/05 10:15:17 UTC
svn commit: r453133 - in /webservices/axis2/trunk/java/modules:
codegen/src/org/apache/axis2/wsdl/codegen/emitter/
codegen/src/org/apache/axis2/wsdl/template/java/
kernel/src/org/apache/axis2/client/ kernel/src/org/apache/axis2/description/
Author: sanka
Date: Thu Oct 5 01:15:16 2006
New Revision: 453133
URL: http://svn.apache.org/viewvc?view=rev&rev=453133
Log:
Adding Policy support per Message basis.
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.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/WSDL11ToAxisServiceBuilder.java
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?view=diff&rev=453133&r1=453132&r2=453133
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Thu Oct 5 01:15:16 2006
@@ -18,7 +18,7 @@
import org.apache.commons.logging.LogFactory;
import org.apache.neethi.Policy;
import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.woden.internal.util.dom.DOM2Writer;
+//import org.apache.woden.internal.util.dom.DOM2Writer;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -28,6 +28,8 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
@@ -1741,6 +1743,29 @@
protected Element getInputElement(Document doc, AxisOperation operation, List headerParameterQNameList) {
Element inputElt = doc.createElement("input");
String MEP = operation.getMessageExchangePattern();
+
+ /*
+ * Setting the input message policy as an attribute of the input element.
+ */
+ AxisMessage inputMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+ if (inputMessage != null) {
+ PolicyInclude policyInclude = inputMessage.getPolicyInclude();
+ Policy policy = policyInclude.getPolicy();
+
+ if (policy != null) {
+ policy = (Policy) policy.normalize(policyInclude.getPolicyRegistry(), false);
+ try {
+ String policyString = PolicyUtil.policyComponentToString(policy);
+ policyString = PolicyUtil.getSafeString(policyString);
+ addAttribute(doc, "policy", policyString, inputElt);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+
if (WSDLUtil.isInputPresentForMEP(MEP)) {
Element[] param = getInputParamElement(doc, operation);
for (int i = 0; i < param.length; i++) {
@@ -1782,6 +1807,25 @@
protected Element getOutputElement(Document doc, AxisOperation operation, List headerParameterQNameList) {
Element outputElt = doc.createElement("output");
String MEP = operation.getMessageExchangePattern();
+
+ AxisMessage outMessage = operation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+ if (outMessage != null) {
+ PolicyInclude policyInclude = outMessage.getPolicyInclude();
+ Policy policy = policyInclude.getPolicy();
+
+ if (policy != null) {
+ policy = (Policy) policy.normalize(policyInclude.getPolicyRegistry(), false);
+
+ try {
+ String policyString = PolicyUtil.policyComponentToString(policy);
+ policyString = PolicyUtil.getSafeString(policyString);
+
+ } catch (Exception e ) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
if (WSDLUtil.isOutputPresentForMEP(MEP)) {
Element param = getOutputParamElement(doc, operation);
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?view=diff&rev=453133&r1=453132&r2=453133
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Thu Oct 5 01:15:16 2006
@@ -74,32 +74,17 @@
</xsl:choose>
__operation.setName(new javax.xml.namespace.QName("<xsl:value-of select="@namespace"/>", "<xsl:value-of select="@name"/>"));
-
- <!--
- <xsl:if test="@policy">
- __operation_policy_string = "<xsl:value-of select="@policy"/>";
- org.apache.neethi.Policy __operation_policy = getPolicy(__operation_policy_string);
- ((org.apache.axis2.description.PolicyInclude) __operation.getPolicyInclude()).setPolicy(__operation_policy);
- </xsl:if>
- -->
-
- _operations[<xsl:value-of select="position()-1"/>]=__operation;
-
- <xsl:choose>
- <xsl:when test="@policy">
- __operation_policy_string = "<xsl:value-of select="@policy"/>";
- org.apache.neethi.Policy __operation_policy = getPolicy(__operation_policy_string);
-
- _service.addOperation(__operation);
- __operation.applyPolicy(__operation_policy);
- </xsl:when>
- <xsl:otherwise>
_service.addOperation(__operation);
- __operation.applyPolicy(new org.apache.neethi.Policy());
- </xsl:otherwise>
- </xsl:choose>
-
-
+
+ <xsl:if test="input/@policy">
+ (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicyInclude().setPolicy(getPolicy("<xsl:value-of select="input/@policy"/>"));
+ </xsl:if>
+
+ <xsl:if test="output/@policy">
+ (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE).getPolicyInclude().setPolicy(getPolicy("<xsl:value-of select="output/@policy"/>"));
+ </xsl:if>
+
+ _operations[<xsl:value-of select="position()-1"/>]=__operation;
</xsl:for-each>
}
@@ -139,6 +124,8 @@
populateFaults();
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
+ _service.applyPolicy();
+
configurationContext = _serviceClient.getServiceContext().getConfigurationContext();
_serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java?view=diff&rev=453133&r1=453132&r2=453133
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java Thu Oct 5 01:15:16 2006
@@ -125,12 +125,9 @@
this.axisService.setClientSide(true);
this.axisConfig.addService(this.axisService);
} else {
-
- // FIXME we should throw an error only if the AxisConfigurations are different ..
-
-// throw new AxisFault(Messages.getMessage(
-// "twoservicecannothavesamename",
-// this.axisService.getName()));
+ throw new AxisFault(Messages.getMessage(
+ "twoservicecannothavesamename",
+ this.axisService.getName()));
}
AxisServiceGroup axisServiceGroup = (AxisServiceGroup) this.axisService.getParent();
ServiceGroupContext sgc = new ServiceGroupContext(this.configContext,
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java?view=diff&rev=453133&r1=453132&r2=453133
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/Stub.java Thu Oct 5 01:15:16 2006
@@ -32,7 +32,6 @@
import org.apache.axiom.soap.SOAPProcessingException;
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.AxisService;
-import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.i18n.Messages;
/**
@@ -43,8 +42,7 @@
* underscore character to avoid conflicts with actual implementation methods.
*/
public abstract class Stub {
-
- protected AxisConfiguration _cofiguration;
+
protected AxisService _service;
protected ArrayList modules = new ArrayList();
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java?view=diff&rev=453133&r1=453132&r2=453133
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java Thu Oct 5 01:15:16 2006
@@ -97,8 +97,7 @@
}
Parameter parameter = getParameter(parameterName);
- return parameter != null
- && parameter.isLocked();
+ return parameter != null && parameter.isLocked();
}
public void setParent(AxisDescription parent) {
@@ -164,10 +163,10 @@
*/
public void applyPolicy(Policy policy) throws AxisFault {
AxisConfiguration configuration = getAxisConfiguration();
-
+
if (configuration == null) {
// FIXME return or throw an Exception?
- return;
+ return;
}
// sets AxisDescription policy
@@ -232,6 +231,86 @@
*/
engageModulesToAxisDescription(modulesToEngage, this);
+ }
+
+ /**
+ * Applies the policies on the Description Hierarchy recursively.
+ *
+ * @throws AxisFault
+ *
+ */
+ public void applyPolicy() throws AxisFault {
+
+ AxisConfiguration configuration = getAxisConfiguration();
+ if (configuration == null) {
+ return; // CHECKME: May be we need to throw an Exception ??
+ }
+
+ Policy effPolicy = getPolicyInclude().getEffectivePolicy();
+
+ 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) {
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?view=diff&rev=453133&r1=453132&r2=453133
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Thu Oct 5 01:15:16 2006
@@ -606,7 +606,7 @@
}
}
- break;
+// break;
} else if (extElement instanceof UnknownExtensibilityElement) {
if (WSDLConstants.WSDL11Constants.SOAP_12_BODY
@@ -637,7 +637,7 @@
}
}
// todo - add the code here to process the SOAP 1.2 body
- break;
+// break;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org