geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1097373 [3/5] - in /geronimo/bundles/trunk/axis2: ./ src/main/java/org/apache/axis2/addressing/ src/main/java/org/apache/axis2/description/ src/main/java/org/apache/axis2/jaxws/addressing/ src/main/java/org/apache/axis2/jaxws/addressing/po...
Date Thu, 28 Apr 2011 09:03:02 GMT
Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java
URL: http://svn.apache.org/viewvc/geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java?rev=1097373&view=auto
==============================================================================
--- geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java
(added)
+++ geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java
Thu Apr 28 09:03:01 2011
@@ -0,0 +1,102 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.axis2.jaxws.addressing.policy;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.description.AxisBinding;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+import org.apache.neethi.builders.PolicyContainingPrimitiveAssertion;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AddressingPolicyUtil {
+
+    private static final Log log = LogFactory.getLog(AddressingPolicyUtil.class);
+
+    public static void configureAddressingPolicyFromWSDL(AxisService axisService, AxisConfiguration
axisConfiguration) {
+        AxisBinding axisBinding = axisService.getEndpoint(axisService.getEndpointName()).getBinding();
+        Policy policy = axisBinding.getEffectivePolicy();
+        boolean addressingPolicyConfigured = false;
+        boolean anonymousResponsesSupported = false;
+        boolean nonAnonymousResponsesSupported = false;
+        boolean addressingOptional = false;
+        for (Iterator<List<Assertion>> it = policy.getAlternatives(); it.hasNext();)
{
+            for (Assertion assertion : it.next()) {
+                if (!assertion.getName().equals(AddressingConstants.ADDRESSING_QNAME)) {
+                    continue;
+                }
+                addressingPolicyConfigured = true;
+                if (assertion.isOptional()) {
+                    addressingOptional = true;
+                }
+                if (assertion instanceof PolicyContainingPrimitiveAssertion) {
+                    PolicyContainingPrimitiveAssertion policyContainingPrimitiveAssertion
= (PolicyContainingPrimitiveAssertion) assertion;
+                    Policy responsesPolicy = policyContainingPrimitiveAssertion.getPolicy();
+                    if (responsesPolicy == null) {
+                        continue;
+                    }
+                    for (Iterator<List<Assertion>> responsesIt = policy.getAlternatives();
responsesIt.hasNext();) {
+                        for (Assertion responsesAssertion : responsesIt.next()) {
+                            if (responsesAssertion.getName().equals(AddressingConstants.ANONYMOUSRESPONSES_QNAME))
{
+                                anonymousResponsesSupported = true;
+                            } else if (responsesAssertion.getName().equals(AddressingConstants.NONANONYMOUSRESPONSES_QNAME))
{
+                                nonAnonymousResponsesSupported = true;
+                            }
+                        }
+
+                    }
+
+                }
+            }
+        }
+        try {
+            if (addressingPolicyConfigured) {
+                if (!axisConfiguration.isEngaged(Constants.MODULE_ADDRESSING)) {
+                    axisConfiguration.engageModule(Constants.MODULE_ADDRESSING);
+                }
+                Parameter disabled = new Parameter(AddressingConstants.DISABLE_ADDRESSING_FOR_IN_MESSAGES,
"false");
+                axisService.addParameter(disabled);
+            }
+            if (anonymousResponsesSupported && !nonAnonymousResponsesSupported) {
+                Parameter responses = new Parameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME,
AddressingConstants.WSAM_INVOCATION_PATTERN_SYNCHRONOUS);
+                axisService.addParameter(responses);
+            } else if (!anonymousResponsesSupported && nonAnonymousResponsesSupported)
{
+                Parameter responses = new Parameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME,
AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS);
+                axisService.addParameter(responses);
+            }
+            Parameter required = new Parameter(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER,
addressingOptional ? AddressingConstants.ADDRESSING_UNSPECIFIED
+                    : AddressingConstants.ADDRESSING_REQUIRED);
+            axisService.addParameter(required);
+        } catch (Exception e) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("AddressingEngagementError",
e.toString()));
+        }
+    }
+}

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/bundles/trunk/axis2/src/main/java/org/apache/axis2/jaxws/addressing/policy/AddressingPolicyUtil.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message