axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prad...@apache.org
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 GMT
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 @@
-<module name="addressing">
+<module name="addressing" class="org.apache.axis2.addressing.AddressingModule">
     <Description>This is WS-Addressing implementation on Axis2. Currently we have implemented
Submission version (2004/08) and Proposed Recommendation. </Description>
     <InFlow>
         <handler name="AddressingFinalInHandler" class="org.apache.axis2.handlers.addressing.AddressingFinalInHandler">

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


Mime
View raw message