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 de...@apache.org on 2006/04/21 15:46:19 UTC

svn commit: r395884 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/codegen/ core/src/org/apache/axis2/context/ core/src/org/apache/axis2/description/

Author: deepal
Date: Fri Apr 21 06:46:17 2006
New Revision: 395884

URL: http://svn.apache.org/viewcvs?rev=395884&view=rev
Log:
-fixing http://issues.apache.org/jira/browse/AXIS2-596
- added a method to message context to check whether a given module is engage 
  - first check whether it is globally
  - then current service group (if available in msg)
  - current service (if available in msg)
  - current operation (if available in msg)

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java Fri Apr 21 06:46:17 2006
@@ -5,9 +5,9 @@
 import org.apache.axis2.wsdl.util.CommandLineOptionConstants;
 
 import java.io.File;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.HashMap;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -26,9 +26,9 @@
 
 class CodegenConfigLoader implements CommandLineOptionConstants {
 
-    public static void loadConfig(CodeGenConfiguration config, Map optionMap){
+    public static void loadConfig(CodeGenConfiguration config, Map optionMap) {
         String outputLocation = "."; //default output directory is the current working directory
-        CommandLineOption outputLocationOption = loadOption(WSDL2JavaConstants.OUTPUT_LOCATION_OPTION, WSDL2JavaConstants.OUTPUT_LOCATION_OPTION_LONG,optionMap);
+        CommandLineOption outputLocationOption = loadOption(WSDL2JavaConstants.OUTPUT_LOCATION_OPTION, WSDL2JavaConstants.OUTPUT_LOCATION_OPTION_LONG, optionMap);
 
         if (outputLocationOption != null) {
             outputLocation = outputLocationOption.getOptionValue();
@@ -45,16 +45,16 @@
             outputLocationFile.mkdirs();
         }
 
-        config.setServerSide(loadOption(WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION, WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION_LONG,optionMap) != null);
+        config.setServerSide(loadOption(WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION, WSDL2JavaConstants.SERVER_SIDE_CODE_OPTION_LONG, optionMap) != null);
         config.setGenerateDeployementDescriptor(loadOption(WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION,
-                WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION_LONG,optionMap) !=
+                WSDL2JavaConstants.GENERATE_SERVICE_DESCRIPTION_OPTION_LONG, optionMap) !=
                 null);
-        config.setWriteTestCase(loadOption(WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION, WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION,optionMap) != null);
+        config.setWriteTestCase(loadOption(WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION, WSDL2JavaConstants.GENERATE_TEST_CASE_OPTION, optionMap) != null);
 
         boolean asyncFlagPresent =
-                (loadOption(WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION, WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION_LONG,optionMap) !=  null);
+                (loadOption(WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION, WSDL2JavaConstants.CODEGEN_ASYNC_ONLY_OPTION_LONG, optionMap) != null);
         boolean syncFlagPresent =
-                (loadOption(WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION, WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION_LONG,optionMap) !=   null);
+                (loadOption(WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION, WSDL2JavaConstants.CODEGEN_SYNC_ONLY_OPTION_LONG, optionMap) != null);
         if (asyncFlagPresent) {
             config.setAsyncOn(true);
             config.setSyncOn(false);
@@ -64,37 +64,37 @@
             config.setSyncOn(true);
         }
 
-        CommandLineOption packageOption = loadOption(WSDL2JavaConstants.PACKAGE_OPTION, WSDL2JavaConstants.PACKAGE_OPTION_LONG,optionMap);
+        CommandLineOption packageOption = loadOption(WSDL2JavaConstants.PACKAGE_OPTION, WSDL2JavaConstants.PACKAGE_OPTION_LONG, optionMap);
         if (packageOption != null) {
             config.setPackageName(packageOption.getOptionValue());
         }
 
-        CommandLineOption langOption = loadOption(WSDL2JavaConstants.STUB_LANGUAGE_OPTION, WSDL2JavaConstants.STUB_LANGUAGE_OPTION_LONG,optionMap);
+        CommandLineOption langOption = loadOption(WSDL2JavaConstants.STUB_LANGUAGE_OPTION, WSDL2JavaConstants.STUB_LANGUAGE_OPTION_LONG, optionMap);
         //The language here
         if (langOption != null) {
             config.setOutputLanguage(langOption.getOptionValue());
         }
 
-        CommandLineOption dataBindingOption = loadOption(WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION, WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION_LONG,optionMap);
+        CommandLineOption dataBindingOption = loadOption(WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION, WSDL2JavaConstants.DATA_BINDING_TYPE_OPTION_LONG, optionMap);
         if (dataBindingOption != null) {
             config.setDatabindingType(dataBindingOption.getOptionValue());
         }
 
-        CommandLineOption unwrapClassesOption = loadOption(WSDL2JavaConstants.UNPACK_CLASSES_OPTION, WSDL2JavaConstants.UNPACK_CLASSES_OPTION_LONG,optionMap);
+        CommandLineOption unwrapClassesOption = loadOption(WSDL2JavaConstants.UNPACK_CLASSES_OPTION, WSDL2JavaConstants.UNPACK_CLASSES_OPTION_LONG, optionMap);
         if (unwrapClassesOption != null) {
             config.setPackClasses(false);
         }
 
-        CommandLineOption portNameOption = loadOption(WSDL2JavaConstants.PORT_NAME_OPTION, WSDL2JavaConstants.PORT_NAME_OPTION_LONG,optionMap);
-        config.setPortName(portNameOption!=null?portNameOption.getOptionValue():null);
+        CommandLineOption portNameOption = loadOption(WSDL2JavaConstants.PORT_NAME_OPTION, WSDL2JavaConstants.PORT_NAME_OPTION_LONG, optionMap);
+        config.setPortName(portNameOption != null ? portNameOption.getOptionValue() : null);
 
-        CommandLineOption serviceNameOption = loadOption(WSDL2JavaConstants.SERVICE_NAME_OPTION, WSDL2JavaConstants.SERVICE_NAME_OPTION_LONG,optionMap);
-        config.setServiceName(serviceNameOption!=null?serviceNameOption.getOptionValue():null);
+        CommandLineOption serviceNameOption = loadOption(WSDL2JavaConstants.SERVICE_NAME_OPTION, WSDL2JavaConstants.SERVICE_NAME_OPTION_LONG, optionMap);
+        config.setServiceName(serviceNameOption != null ? serviceNameOption.getOptionValue() : null);
 
         CommandLineOption repositoryPathOption = loadOption(WSDL2JavaConstants.REPOSITORY_PATH_OPTION, WSDL2JavaConstants.REPOSITORY_PATH_OPTION_LONG, optionMap);
-        config.setRepositoryPath(repositoryPathOption != null ? repositoryPathOption.getOptionValue(): null);
+        config.setRepositoryPath(repositoryPathOption != null ? repositoryPathOption.getOptionValue() : null);
 
-        CommandLineOption generateAllOption = loadOption(WSDL2JavaConstants.GENERATE_ALL_OPTION, WSDL2JavaConstants.GENERATE_ALL_OPTION_LONG,optionMap);
+        CommandLineOption generateAllOption = loadOption(WSDL2JavaConstants.GENERATE_ALL_OPTION, WSDL2JavaConstants.GENERATE_ALL_OPTION_LONG, optionMap);
         if (generateAllOption != null) {
             config.setGenerateAll(true);
         }
@@ -103,20 +103,22 @@
                 WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION,
                 WSDL2JavaConstants.NAME_SPACE_TO_PACKAGE_OPTION_LONG,
                 optionMap);
-        if (ns2packageOption!=null){
+        if (ns2packageOption != null) {
             //the syntax for the value of the namespaces and packages is
             //to be a comma seperated list with uri,packagename,uri,packagename...
             String value = ns2packageOption.getOptionValue();
-            String valuepairs[]  = value.split(",");
-            if (valuepairs.length >0 && valuepairs.length%2==0){
-                //put them in the hash map
-                HashMap map = new HashMap(valuepairs.length);
-                for (int i = 0; i < valuepairs.length; i=i+2) {
-                    map.put(valuepairs[i],valuepairs[i+1]);
+            if (value != null) {
+                String valuepairs[] = value.split(",");
+                if (valuepairs.length > 0 && valuepairs.length % 2 == 0) {
+                    //put them in the hash map
+                    HashMap map = new HashMap(valuepairs.length);
+                    for (int i = 0; i < valuepairs.length; i = i + 2) {
+                        map.put(valuepairs[i], valuepairs[i + 1]);
+                    }
+                    config.setUri2PackageNameMap(map);
+                } else {
+                    //todo throw an exception here
                 }
-                config.setUri2PackageNameMap(map);
-            }else{
-               //todo throw an exception here
             }
         }
 
@@ -133,20 +135,19 @@
         }
 
 
-
     }
 
-    private static CommandLineOption loadOption(String shortOption, String longOption,Map options) {
+    private static CommandLineOption loadOption(String shortOption, String longOption, Map options) {
         //short option gets precedence
         CommandLineOption option = null;
-        if (longOption!=null){
-            option =(CommandLineOption)options.get(longOption);
-            if (option!=null) {
+        if (longOption != null) {
+            option = (CommandLineOption) options.get(longOption);
+            if (option != null) {
                 return option;
             }
         }
-        if (shortOption!= null){
-            option = (CommandLineOption)options.get(shortOption);
+        if (shortOption != null) {
+            option = (CommandLineOption) options.get(shortOption);
         }
 
         return option;

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/MessageContext.java Fri Apr 21 06:46:17 2006
@@ -23,15 +23,7 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.client.Options;
-import org.apache.axis2.description.AxisModule;
-import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.HandlerDescription;
-import org.apache.axis2.description.ModuleConfiguration;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 
 import javax.xml.namespace.QName;
@@ -911,5 +903,39 @@
 
     public void setRelationships(RelatesTo[] list) {
         options.setRelationships(list);
+    }
+
+    public boolean isEngaged(QName moduleName) {
+        boolean enegage;
+        if (configurationContext != null) {
+            AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
+            AxisModule module = axisConfig.getModule(moduleName);
+            if (module == null) {
+                return false;
+            }
+            enegage = axisConfig.isEngaged(moduleName);
+            if (enegage) {
+                return true;
+            }
+            if (axisServiceGroup != null) {
+                enegage = axisServiceGroup.isEngaged(moduleName);
+                if (enegage) {
+                    return true;
+                }
+            }
+            if (axisService != null) {
+                enegage = axisService.isEngaged(moduleName);
+                if (enegage) {
+                    return true;
+                }
+            }
+            if (axisOperation != null) {
+                enegage = axisOperation.isEngaged(module);
+                if (enegage) {
+                    return true;
+                }
+            }
+        }
+        return false;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java Fri Apr 21 06:46:17 2006
@@ -515,4 +515,15 @@
     public void setSoapAction(String soapAction) {
         this.soapAction = soapAction;
     }
+
+    public boolean isEngaged(AxisModule module) {
+        Iterator engagedModuleItr = engagedModules.iterator();
+        while (engagedModuleItr.hasNext()) {
+            AxisModule axisModule = (AxisModule) engagedModuleItr.next();
+            if (axisModule.getName().getLocalPart().equals(module.getName().getLocalPart())) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java Fri Apr 21 06:46:17 2006
@@ -135,6 +135,7 @@
         moduleRefs = new ArrayList();
         engagedModules = new ArrayList();
         schemaList = new ArrayList();
+        serviceClassLoader = Thread.currentThread().getContextClassLoader();
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisServiceGroup.java Fri Apr 21 06:46:17 2006
@@ -201,4 +201,19 @@
     public Object getKey() {
         return getServiceGroupName();
     }
+
+    public boolean isEngaged(QName moduleName) {
+        AxisModule module = getAxisDescription().getModule(moduleName);
+        if (module == null) {
+            return false;
+        }
+        Iterator engagedModuleItr = engagedModules.iterator();
+        while (engagedModuleItr.hasNext()) {
+            AxisModule axisModule = (AxisModule) engagedModuleItr.next();
+            if (axisModule.getName().getLocalPart().equals(module.getName().getLocalPart())) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOnlyAxisOperation.java Fri Apr 21 06:46:17 2006
@@ -1,3 +1,18 @@
+/*
+* Copyright 2004,2006 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.description;
 
 import org.apache.axis2.AxisFault;
@@ -9,12 +24,6 @@
 import javax.xml.namespace.QName;
 import java.util.ArrayList;
 import java.util.HashMap;
-
-/**
- * Author: Deepal Jayasinghe
- * Date: Oct 3, 2005
- * Time: 2:06:31 PM
- */
 public class InOnlyAxisOperation extends AxisOperation {
     private AxisMessage inFaultMessage;
 //    private AxisMessage inMessage;

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/InOutAxisOperation.java Fri Apr 21 06:46:17 2006
@@ -1,3 +1,18 @@
+/*
+* Copyright 2004,2006 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.description;
 
 import org.apache.axis2.AxisFault;
@@ -10,11 +25,6 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 
-/**
- * Author: Deepal Jayasinghe
- * Date: Oct 3, 2005
- * Time: 2:07:15 PM
- */
 public class InOutAxisOperation extends AxisOperation {
     private AxisMessage inFaultMessage;
 //    private AxisMessage inMessage;

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutInAxisOperation.java Fri Apr 21 06:46:17 2006
@@ -1,3 +1,18 @@
+/*
+* Copyright 2004,2006 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.description;
 
 import org.apache.axiom.om.OMElement;
@@ -25,10 +40,6 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-
-/**
- * Author: Deepal Jayasinghe Date: Oct 3, 2005 Time: 6:01:33 PM
- */
 public class OutInAxisOperation extends InOutAxisOperation {
     public OutInAxisOperation() {
         super();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java?rev=395884&r1=395883&r2=395884&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/OutOnlyAxisOperation.java Fri Apr 21 06:46:17 2006
@@ -1,3 +1,18 @@
+/*
+* Copyright 2004,2006 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.description;
 
 import org.apache.axiom.om.OMElement;