Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 25032 invoked from network); 19 Feb 2007 16:31:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Feb 2007 16:31:26 -0000 Received: (qmail 95746 invoked by uid 500); 19 Feb 2007 16:31:33 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 95646 invoked by uid 500); 19 Feb 2007 16:31:33 -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 95635 invoked by uid 500); 19 Feb 2007 16:31:33 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 95632 invoked by uid 99); 19 Feb 2007 16:31:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Feb 2007 08:31:33 -0800 X-ASF-Spam-Status: No, hits=-99.5 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; Mon, 19 Feb 2007 08:31:24 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id C90621A981D; Mon, 19 Feb 2007 08:31:04 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r509242 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: description/WSDL11ToAxisServiceBuilder.java wsdl/util/WSDL4JImportedWSDLHelper.java Date: Mon, 19 Feb 2007 16:31:04 -0000 To: axis2-cvs@ws.apache.org From: davidillsley@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070219163104.C90621A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davidillsley Date: Mon Feb 19 08:31:04 2007 New Revision: 509242 URL: http://svn.apache.org/viewvc?view=rev&rev=509242 Log: Factor out some WSDL4J processing code with specific functionality to allow reuse and reduce the complexity of WSDL11ToAxisServiceBuilder Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/wsdl/util/WSDL4JImportedWSDLHelper.java Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java 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=509242&r1=509241&r2=509242 ============================================================================== --- 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 Mon Feb 19 08:31:04 2007 @@ -57,6 +57,7 @@ import org.apache.axis2.wsdl.SoapAddress; import org.apache.axis2.wsdl.WSDLConstants; import org.apache.axis2.wsdl.WSDLUtil; +import org.apache.axis2.wsdl.util.WSDL4JImportedWSDLHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.neethi.Constants; @@ -543,8 +544,7 @@ } // process the imports - processImports(wsdl4jDefinition); - + WSDL4JImportedWSDLHelper.processImports(wsdl4jDefinition); // Adding the policies in the Definition to the the PolicyRegistry processPoliciesInDefintion(wsdl4jDefinition); @@ -1861,103 +1861,6 @@ } } - - private void getImportedDefinitions(Definition definition, Map importedDefs) { - Map wsdlImports = definition.getImports(); - - Import wsdl_import; - Definition imported_def; - String import_def_key; - - for (Iterator iterator = wsdlImports.values().iterator(); iterator.hasNext();) { - - Vector imports = (Vector) iterator.next(); - Iterator iter2 = imports.iterator(); - while (iter2.hasNext()) { - wsdl_import = (Import) iter2.next(); - imported_def = wsdl_import.getDefinition(); - - import_def_key = imported_def.getDocumentBaseURI(); - - if (import_def_key == null) { - import_def_key = imported_def.getTargetNamespace(); - } - - if (!importedDefs.containsKey(import_def_key)) { - importedDefs.put(import_def_key, imported_def); - getImportedDefinitions(imported_def, importedDefs); - } - } - } - } - - - /** - * The intention of this procedure is to process the imports. When - * processing the imports the imported documents will be populating the - * items in the main document recursivley - * - * @param wsdl4JDefinition - */ - private void processImports(Definition wsdl4JDefinition) { - - Map imported_defs = new HashMap(); - getImportedDefinitions(wsdl4JDefinition, imported_defs); - - for (Iterator iterator = imported_defs.values().iterator(); iterator.hasNext();) { - Definition imported_def = (Definition) iterator.next(); - - Map def_namespaces = wsdl4jDefinition.getNamespaces(); - Map imported_def_namespaces = imported_def.getNamespaces(); - - Object prefix; - - - for (Iterator prefix_iterator = imported_def_namespaces.keySet().iterator(); prefix_iterator.hasNext();) { - prefix = prefix_iterator.next(); - - if (!def_namespaces.containsKey(prefix)) { - def_namespaces.put(prefix, imported_def_namespaces.get(prefix)); - } - } - - // copy types - Types imported_def_types = imported_def.getTypes(); - - if (imported_def_types != null) { - Types def_types = wsdl4jDefinition.getTypes(); - - if (def_types == null) { - def_types = wsdl4jDefinition.createTypes(); - wsdl4jDefinition.setTypes(def_types); - } - - for (Iterator types_iterator = - imported_def_types.getExtensibilityElements().iterator(); - types_iterator.hasNext();) { - // CHECKME - def_types.addExtensibilityElement((ExtensibilityElement) types_iterator.next()); - } - } - - // add messages - wsdl4JDefinition.getMessages().putAll(imported_def.getMessages()); - - // add portTypes - wsdl4JDefinition.getPortTypes().putAll(imported_def.getPortTypes()); - - // add bindings - wsdl4JDefinition.getBindings().putAll(imported_def.getBindings()); - - // add services - wsdl4JDefinition.getServices().putAll(imported_def.getServices()); - - // add ExtensibilityElements - wsdl4JDefinition.getExtensibilityElements() - .addAll(imported_def.getExtensibilityElements()); - } - } - /** * Read the WSDL file given the inputstream for the WSDL source Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/wsdl/util/WSDL4JImportedWSDLHelper.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/wsdl/util/WSDL4JImportedWSDLHelper.java?view=auto&rev=509242 ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/wsdl/util/WSDL4JImportedWSDLHelper.java (added) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/wsdl/util/WSDL4JImportedWSDLHelper.java Mon Feb 19 08:31:04 2007 @@ -0,0 +1,137 @@ +/* +* 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.wsdl.util; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +import javax.wsdl.Definition; +import javax.wsdl.Import; +import javax.wsdl.Types; +import javax.wsdl.extensions.ExtensibilityElement; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class provides support for processing a WSDL4J defintion which includes imports. + * It allows the imports to be processed into a single WSDL4J Definition object + */ +public class WSDL4JImportedWSDLHelper { + + protected static final Log log = LogFactory.getLog(WSDL4JImportedWSDLHelper.class); + private static final boolean isTraceEnabled = log.isTraceEnabled(); + + /** + * The intention of this procedure is to process the imports. When + * processing the imports the imported documents will be populating the + * items in the main document recursivley + * + * @param wsdl4JDefinition + */ + public static void processImports(Definition wsdl4JDefinition) { + if(isTraceEnabled){ + log.trace("processImports: wsdl4JDefinition="+wsdl4JDefinition); + } + Map imported_defs = new HashMap(); + getImportedDefinitions(wsdl4JDefinition, imported_defs); + + for (Iterator iterator = imported_defs.values().iterator(); iterator.hasNext();) { + Definition imported_def = (Definition) iterator.next(); + + Map def_namespaces = wsdl4JDefinition.getNamespaces(); + Map imported_def_namespaces = imported_def.getNamespaces(); + + Object prefix; + + + for (Iterator prefix_iterator = imported_def_namespaces.keySet().iterator(); prefix_iterator.hasNext();) { + prefix = prefix_iterator.next(); + + if (!def_namespaces.containsKey(prefix)) { + def_namespaces.put(prefix, imported_def_namespaces.get(prefix)); + } + } + + // copy types + Types imported_def_types = imported_def.getTypes(); + + if (imported_def_types != null) { + Types def_types = wsdl4JDefinition.getTypes(); + + if (def_types == null) { + def_types = wsdl4JDefinition.createTypes(); + wsdl4JDefinition.setTypes(def_types); + } + + for (Iterator types_iterator = + imported_def_types.getExtensibilityElements().iterator(); + types_iterator.hasNext();) { + // CHECKME + def_types.addExtensibilityElement((ExtensibilityElement) types_iterator.next()); + } + } + + // add messages + wsdl4JDefinition.getMessages().putAll(imported_def.getMessages()); + + // add portTypes + wsdl4JDefinition.getPortTypes().putAll(imported_def.getPortTypes()); + + // add bindings + wsdl4JDefinition.getBindings().putAll(imported_def.getBindings()); + + // add services + wsdl4JDefinition.getServices().putAll(imported_def.getServices()); + + // add ExtensibilityElements + wsdl4JDefinition.getExtensibilityElements() + .addAll(imported_def.getExtensibilityElements()); + } + } + + private static void getImportedDefinitions(Definition definition, Map importedDefs) { + Map wsdlImports = definition.getImports(); + + Import wsdl_import; + Definition imported_def; + String import_def_key; + + for (Iterator iterator = wsdlImports.values().iterator(); iterator.hasNext();) { + Vector imports = (Vector) iterator.next(); + Iterator iter2 = imports.iterator(); + while (iter2.hasNext()) { + wsdl_import = (Import) iter2.next(); + if(isTraceEnabled){ + log.trace("getImportedDefinitions: import uri="+wsdl_import.getLocationURI()); + } + imported_def = wsdl_import.getDefinition(); + + import_def_key = imported_def.getDocumentBaseURI(); + + if (import_def_key == null) { + import_def_key = imported_def.getTargetNamespace(); + } + + if (!importedDefs.containsKey(import_def_key)) { + importedDefs.put(import_def_key, imported_def); + getImportedDefinitions(imported_def, importedDefs); + } + } + } + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org For additional commands, e-mail: axis-cvs-help@ws.apache.org