Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 17320 invoked from network); 19 Jan 2007 21:45:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Jan 2007 21:45:32 -0000 Received: (qmail 91917 invoked by uid 500); 19 Jan 2007 21:45:37 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 91851 invoked by uid 500); 19 Jan 2007 21:45:37 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 91839 invoked by uid 500); 19 Jan 2007 21:45:37 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 91836 invoked by uid 99); 19 Jan 2007 21:45:37 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jan 2007 13:45:37 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 19 Jan 2007 13:45:30 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id DD3C91A981A; Fri, 19 Jan 2007 13:44:24 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r497964 - in /webservices/axis2/trunk/java/modules/addressing/src: META-INF/module.xml org/apache/axis2/addressing/AddressingModule.java org/apache/axis2/handlers/addressing/AddressingOutHandler.java Date: Fri, 19 Jan 2007 21:44:24 -0000 To: axis2-cvs@ws.apache.org From: pradine@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070119214424.DD3C91A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pradine Date: Fri Jan 19 13:44:23 2007 New Revision: 497964 URL: http://svn.apache.org/viewvc?view=rev&rev=497964 Log: Add new AddressingModule class to configure the handlers. Added: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingModule.java Modified: webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Modified: webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml?view=diff&rev=497964&r1=497963&r2=497964 ============================================================================== --- webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml (original) +++ webservices/axis2/trunk/java/modules/addressing/src/META-INF/module.xml Fri Jan 19 13:44:23 2007 @@ -1,4 +1,4 @@ - + This is WS-Addressing implementation on Axis2. Currently we have implemented Submission version (2004/08) and Proposed Recommendation. Added: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingModule.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingModule.java?view=auto&rev=497964 ============================================================================== --- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingModule.java (added) +++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/addressing/AddressingModule.java Fri Jan 19 13:44:23 2007 @@ -0,0 +1,110 @@ +/* + * Copyright 2007 The Apache Software Foundation. + * + * Licensed 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.addressing; + +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.description.AxisDescription; +import org.apache.axis2.description.AxisModule; +import org.apache.axis2.description.Flow; +import org.apache.axis2.description.HandlerDescription; +import org.apache.axis2.description.ModuleConfiguration; +import org.apache.axis2.description.Parameter; +import org.apache.axis2.engine.AxisConfiguration; +import org.apache.axis2.engine.Handler; +import org.apache.axis2.modules.Module; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.neethi.Assertion; +import org.apache.neethi.Policy; + +public class AddressingModule implements Module { + + private static final Log log = LogFactory.getLog(AddressingModule.class); + private static final QName ADDRESSING = new QName(Constants.MODULE_ADDRESSING); + + public void init(ConfigurationContext arg0, AxisModule arg1) + throws AxisFault { + AxisConfiguration axisConfig = arg0.getAxisConfiguration(); + ModuleConfiguration moduleConfig = axisConfig.getModuleConfig(ADDRESSING); + + if (moduleConfig != null) { + List list = moduleConfig.getParameters(); + for (int i = 0, size = list.size(); i < size; i++) { + Parameter param = (Parameter) list.get(i); + arg1.addParameter(param); + + if(log.isTraceEnabled()){ + log.trace("init: Addressing config -" + param); + } + } + + initHandlers(arg1); + } + } + + public void engageNotify(AxisDescription arg0) throws AxisFault { + // TODO Auto-generated method stub + + } + + public boolean canSupportAssertion(Assertion arg0) { + // TODO Auto-generated method stub + return false; + } + + public void applyPolicy(Policy arg0, AxisDescription arg1) throws AxisFault { + // TODO Auto-generated method stub + + } + + public void shutdown(ConfigurationContext arg0) throws AxisFault { + // TODO Auto-generated method stub + + } + + //This method calls the init method of the handlers that we want to initialize. + //Currently only the handlers in the OutFlow and FaultOutFlow are initialized + //by this code. If handlers in other flows need to be initialized then code will + //need to be added to do so. + private void initHandlers(AxisModule axisModule) { + Flow flow = axisModule.getOutFlow(); + if(log.isTraceEnabled()){ + log.trace("initHandlers: Initializing handlers in out flow."); + } + for (int i = 0, size = flow.getHandlerCount(); i < size; i++) { + HandlerDescription description = flow.getHandler(i); + Handler handler = description.getHandler(); + handler.init(description); + } + + flow = axisModule.getFaultOutFlow(); + if(log.isTraceEnabled()){ + log.trace("initHandlers: Initializing handlers in fault out flow."); + } + for (int i = 0, size = flow.getHandlerCount(); i < size; i++) { + HandlerDescription description = flow.getHandler(i); + Handler handler = description.getHandler(); + handler.init(description); + } + } +} Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?view=diff&rev=497964&r1=497963&r2=497964 ============================================================================== --- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java (original) +++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Fri Jan 19 13:44:23 2007 @@ -27,7 +27,6 @@ import org.apache.axiom.soap.SOAPHeader; import org.apache.axiom.soap.SOAPHeaderBlock; import org.apache.axis2.AxisFault; -import org.apache.axis2.Constants; import org.apache.axis2.addressing.AddressingConstants; import org.apache.axis2.addressing.AddressingFaultsHelper; import org.apache.axis2.addressing.EndpointReference; @@ -35,6 +34,7 @@ import org.apache.axis2.addressing.RelatesTo; import org.apache.axis2.client.Options; import org.apache.axis2.context.MessageContext; +import org.apache.axis2.description.HandlerDescription; import org.apache.axis2.description.Parameter; import org.apache.axis2.handlers.AbstractHandler; import org.apache.axis2.util.JavaUtils; @@ -53,6 +53,24 @@ private static final Log log = LogFactory.getLog(AddressingOutHandler.class); + /** + * This variable should only be updated inside the {@link #init(HandlerDescription)} method. + */ + private boolean includeOptionalHeaders = false; + + /** + * Initialize the addressing out handler. + */ + public void init(HandlerDescription arg0) { + super.init(arg0); + + //Determine whether to include optional addressing headers in the output message. + //The default is not to include any headers that can be safely omitted. + Parameter param = arg0.getParameter(INCLUDE_OPTIONAL_HEADERS); + String value = Utils.getParameterValue(param); + includeOptionalHeaders = JavaUtils.isTrueExplicitly(value); + } + public InvocationResponse invoke(MessageContext msgContext) throws AxisFault { // it should be able to disable addressing by some one. Object property = msgContext.getProperty(DISABLE_ADDRESSING_FOR_OUT_MESSAGES); @@ -70,13 +88,6 @@ namespace = Submission.WSA_NAMESPACE; } - //Determine whether to include optional addressing headers in the output message. - //The default is not to include any headers that can be safely omitted. - boolean includeOptionalHeaders = false; - Parameter param = msgContext.getModuleParameter(INCLUDE_OPTIONAL_HEADERS, Constants.MODULE_ADDRESSING, getHandlerDesc()); - String value = Utils.getParameterValue(param); - includeOptionalHeaders = JavaUtils.isTrueExplicitly(value); - SOAPFactory factory = (SOAPFactory) msgContext.getEnvelope().getOMFactory(); OMNamespace addressingNamespaceObject = factory.createOMNamespace(namespace, WSA_DEFAULT_PREFIX); @@ -100,22 +111,19 @@ // Lets have a parameter to control that. The default behavior is you won't replace addressing // headers if there are any (this was the case so far). Object replaceHeadersParam = msgContext.getProperty(REPLACE_ADDRESSING_HEADERS); - boolean replaceHeaders = false; - if (replaceHeadersParam != null) { - replaceHeaders = JavaUtils.isTrueExplicitly(replaceHeadersParam); - } + boolean replaceHeaders = JavaUtils.isTrueExplicitly(replaceHeadersParam); // processing WSA To - processToEPR(messageContextOptions, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + processToEPR(messageContextOptions, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); // processing WSA replyTo - processReplyTo(envelope, messageContextOptions, msgContext, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + processReplyTo(envelope, messageContextOptions, msgContext, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); // processing WSA From - processFromEPR(messageContextOptions, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + processFromEPR(messageContextOptions, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); // processing WSA FaultTo - processFaultToEPR(messageContextOptions, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + processFaultToEPR(messageContextOptions, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); // processing WSA MessageID processMessageID(messageContextOptions, envelope, msgContext, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); @@ -124,7 +132,7 @@ processWSAAction(messageContextOptions, envelope, msgContext, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); // processing WSA RelatesTo - processRelatesTo(envelope, messageContextOptions, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + processRelatesTo(envelope, messageContextOptions, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); // process fault headers, if present processFaultsInfoIfPresent(envelope, msgContext, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); @@ -227,7 +235,7 @@ } } - private void processRelatesTo(SOAPEnvelope envelope, Options messageContextOptions, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace, boolean includeOptionalHeaders) { + private void processRelatesTo(SOAPEnvelope envelope, Options messageContextOptions, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) { if (!isAddressingHeaderAlreadyAvailable(WSA_RELATES_TO, envelope, addressingNamespaceObject, replaceHeaders, true)) { RelatesTo[] relatesTo = messageContextOptions.getRelationships(); @@ -249,13 +257,13 @@ if (Final.WSA_DEFAULT_RELATIONSHIP_TYPE.equals(relationshipType) || Submission.WSA_DEFAULT_RELATIONSHIP_TYPE.equals(relationshipType)) { - if (!includeOptionalHeaders) { - continue; //Omit the relationship type - } - else { + if (includeOptionalHeaders) { relationshipType = isFinalAddressingNamespace ? Final.WSA_DEFAULT_RELATIONSHIP_TYPE : Submission.WSA_DEFAULT_RELATIONSHIP_TYPE; } + else { + continue; //Omit the relationship type + } } relatesToHeader.addAttribute(WSA_RELATES_TO_RELATIONSHIP_TYPE, @@ -267,38 +275,38 @@ } } - private void processFaultToEPR(Options messageContextOptions, SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace, boolean includeOptionalHeaders) throws AxisFault { + private void processFaultToEPR(Options messageContextOptions, SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) throws AxisFault { EndpointReference epr = messageContextOptions.getFaultTo(); String headerName = AddressingConstants.WSA_FAULT_TO; //Omit the header if the epr is null. if (epr != null && !isAddressingHeaderAlreadyAvailable(headerName, envelope, addressingNamespaceObject, replaceHeaders, false)) { - addToSOAPHeader(epr, headerName, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + addToSOAPHeader(epr, headerName, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); } } - private void processFromEPR(Options messageContextOptions, SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace, boolean includeOptionalHeaders) throws AxisFault { + private void processFromEPR(Options messageContextOptions, SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) throws AxisFault { EndpointReference epr = messageContextOptions.getFrom(); String headerName = AddressingConstants.WSA_FROM; //Omit the header if the epr is null. if (epr != null && !isAddressingHeaderAlreadyAvailable(headerName, envelope, addressingNamespaceObject, replaceHeaders, false)) { - addToSOAPHeader(epr, headerName, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + addToSOAPHeader(epr, headerName, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); } } - private void processReplyTo(SOAPEnvelope envelope, Options messageContextOptions, MessageContext msgContext, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace, boolean includeOptionalHeaders) throws AxisFault { + private void processReplyTo(SOAPEnvelope envelope, Options messageContextOptions, MessageContext msgContext, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) throws AxisFault { EndpointReference epr = messageContextOptions.getReplyTo(); String headerName = AddressingConstants.WSA_REPLY_TO; //Don't check epr for null here as addToSOAPHeader() will provide an appropriate default. //This default is especially useful for client side outbound processing. if (!isAddressingHeaderAlreadyAvailable(headerName, envelope, addressingNamespaceObject, replaceHeaders, false)) { - addToSOAPHeader(epr, headerName, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace, includeOptionalHeaders); + addToSOAPHeader(epr, headerName, envelope, addressingNamespaceObject, replaceHeaders, isFinalAddressingNamespace); } } - private void processToEPR(Options messageContextOptions, SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace, boolean includeOptionalHeaders) { + private void processToEPR(Options messageContextOptions, SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) { EndpointReference epr = messageContextOptions.getTo(); if (epr != null && !isAddressingHeaderAlreadyAvailable(WSA_TO, envelope, addressingNamespaceObject, replaceHeaders, false)) { @@ -342,7 +350,7 @@ private void addToSOAPHeader(EndpointReference epr, String headerName, - SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace, boolean includeOptionalHeaders) throws AxisFault { + SOAPEnvelope envelope, OMNamespace addressingNamespaceObject, boolean replaceHeaders, boolean isFinalAddressingNamespace) throws AxisFault { String namespace = addressingNamespaceObject.getNamespaceURI(); String prefix = addressingNamespaceObject.getPrefix(); String anonymous = isFinalAddressingNamespace ? --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org