axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ow...@apache.org
Subject cvs commit: xml-axis-wsif/java/test/async AsyncTest.java
Date Tue, 11 Jun 2002 15:14:51 GMT
owenb       2002/06/11 08:14:51

  Modified:    java/src/org/apache/wsif WSIFServiceImpl.java
                        WSIFClientProxy.java
               java/samples/clients DynamicInvoker.java
               java/test/faults FaultMsgTest.java
               java/test/providers ProvidersInitialisationTest.java
               java/src/org/apache/wsif/providers WSIFDynamicTypeMap.java
               java/src/org/apache/wsif/providers/jms JMSMessage.java
               java/test/headers HeadersTest.java
               java/test/async AsyncTest.java
  Added:       java/src/org/apache/wsif/util WSIFUtils.java
  Removed:     java/src/org/apache/wsif/stub WSIFUtils.java
  Log:
  Moved org.apache.wsif.stub.WSIFUtils to org.apache.wsif.util.WSIFUtils
  and changed references accordingly
  
  Revision  Changes    Path
  1.2       +1 -1      xml-axis-wsif/java/src/org/apache/wsif/WSIFServiceImpl.java
  
  Index: WSIFServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFServiceImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSIFServiceImpl.java	6 Jun 2002 08:28:48 -0000	1.1
  +++ WSIFServiceImpl.java	11 Jun 2002 15:14:50 -0000	1.2
  @@ -95,9 +95,9 @@
   import org.apache.wsif.logging.Tr;
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
   import org.apache.wsif.spi.WSIFProvider;
  -import org.apache.wsif.stub.WSIFUtils;
   import org.apache.wsif.util.WSIFDefaultMessageFactory;
   import org.apache.wsif.util.WSIFProperties;
  +import org.apache.wsif.util.WSIFUtils;
   import org.apache.wsif.wsdl.extensions.ejb.EJBBindingSerializer;
   import org.apache.wsif.wsdl.extensions.format.FormatBindingSerializer;
   import org.apache.wsif.wsdl.extensions.java.JavaBindingSerializer;
  
  
  
  1.3       +1 -1      xml-axis-wsif/java/src/org/apache/wsif/WSIFClientProxy.java
  
  Index: WSIFClientProxy.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/WSIFClientProxy.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFClientProxy.java	10 Jun 2002 17:03:54 -0000	1.2
  +++ WSIFClientProxy.java	11 Jun 2002 15:14:50 -0000	1.3
  @@ -78,7 +78,7 @@
   import org.apache.wsif.logging.Tr;
   import org.apache.wsif.providers.WSIFDynamicTypeMap;
   import org.apache.wsif.providers.WSIFDynamicTypeMapping;
  -import org.apache.wsif.stub.WSIFUtils;
  +import org.apache.wsif.util.WSIFUtils;
   
   /**
    * @author Owen Burroughs <owenb@apache.org>
  
  
  
  1.2       +1 -1      xml-axis-wsif/java/samples/clients/DynamicInvoker.java
  
  Index: DynamicInvoker.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/clients/DynamicInvoker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DynamicInvoker.java	6 Jun 2002 08:28:46 -0000	1.1
  +++ DynamicInvoker.java	11 Jun 2002 15:14:50 -0000	1.2
  @@ -77,7 +77,7 @@
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  -import org.apache.wsif.stub.WSIFUtils;
  +import org.apache.wsif.util.WSIFUtils;
   
   /**
    * This sample shows how to use WSIF for completely dynamic invocations
  
  
  
  1.1                  xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java
  
  Index: WSIFUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.wsif.util;
  
  import java.io.Reader;
  import java.io.StringReader;
  import java.io.Writer;
  import java.lang.reflect.Method;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.security.AccessController;
  import java.security.PrivilegedAction;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  import java.util.Properties;
  import java.util.Set;
  import java.util.StringTokenizer;
  
  import javax.wsdl.Binding;
  import javax.wsdl.Definition;
  import javax.wsdl.Import;
  import javax.wsdl.Message;
  import javax.wsdl.Operation;
  import javax.wsdl.Part;
  import javax.wsdl.PortType;
  import javax.wsdl.QName;
  import javax.wsdl.Service;
  import javax.wsdl.WSDLException;
  import javax.wsdl.extensions.ExtensibilityElement;
  import javax.wsdl.factory.WSDLFactory;
  import javax.wsdl.xml.WSDLReader;
  import javax.wsdl.xml.WSDLWriter;
  import org.apache.wsif.WSIFConstants;
  import org.apache.wsif.WSIFException;
  import org.apache.wsif.WSIFService;
  import org.apache.wsif.WSIFServiceImpl;
  import org.apache.wsif.format.WSIFFormatHandler;
  import org.apache.wsif.logging.MessageLogger;
  import org.apache.wsif.logging.Tr;
  import org.apache.wsif.wsdl.extensions.format.TypeMapping;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.xml.sax.InputSource;
  
  import com.ibm.wsdl.Constants;
  
  /**
   * This class provides utilities for WSIF runtime and generated stubs.
   *
   * @author Alekander Slominski
   * @author Matthew J. Duftler
   * @author Sanjiva Weerawarana
   * @author Owen Burroughs <owenb@apache.org>
   * @author Ant Elder <antelder@apache.org>
   * @author Jeremy Hughes <hughesj@apache.org>
   * @author Mark Whitlock <whitlock@apache.org>
   */
  public class WSIFUtils {
      private final static String DEF_FACTORY_PROPERTY_NAME =
          "javax.wsdl.factory.WSDLFactory";
          
      private static Class initContextClass;
      private static final String SLASH = "/";
      private static final String DOT = ".";
      private static final String FORMAT_HANDLER = "FormatHandler";
      private static final String ELEMENT_FORMAT_HANDLER = "ElementFormatHandler";
      private static final String PHYSICALREP = "physicalrep/";
      private static final String FORMATBINDING = "formatbinding/";
      private static final String XMLSEPARATORS =
          "\u002D\u002E\u003A\u005F\u00B7\u0387\u06DD\u06DE";
          
      private static final String lookupPrefix = "java:comp/env/";
      private static final String emptyString = "";
  
      /**
       * This checks whether JNDI classes are available at runtime.
       * If the return value is true, then generated stubs should
       * invoke lookupFactoryFromJNDI to get the WSIFService.
       * If not, then there's no need to do so.
       */
      public static boolean isJNDIAvailable() {
          Tr.entry(null);
          initContextClass =
              (Class) AccessController.doPrivileged(new PrivilegedAction() {
              public Object run() {
                  try {
                      return Class.forName(
                          "javax.naming.InitialContext",
                          true,
                          Thread.currentThread().getContextClassLoader());
                  } catch (Throwable ignored) {
                  }
                  return null;
              }
          });
  
          boolean b = true;
          if (initContextClass == null)
              b = false;
          Tr.exit(b);
          return b;
      }
  
      /**
       * Given the service and portType identification, return a factory
       * that can produce WSIFPorts for that service/portType combination.
       */
      public static WSIFService lookupFactoryFromJNDI(
          String serviceNS,
          String serviceName,
          String portTypeNS,
          String portTypeName)
          throws WSIFException {
          Tr.entry(null, serviceNS, serviceName, portTypeNS, portTypeName);
          if (serviceNS == null)
              throw new IllegalArgumentException("service namespace can not be null");
          if (serviceName == null)
              throw new IllegalArgumentException("service name can not be null");
          if (portTypeNS == null)
              throw new IllegalArgumentException("port type namespace can not be null");
          if (portTypeName == null)
              throw new IllegalArgumentException("port type name can not be null");
  
          WSIFService ws = null;
          try {
              if (initContextClass == null) {
                  initContextClass =
                      Class.forName(
                          "javax.naming.InitialContext",
                          true,
                          WSIFUtils.class.getClassLoader());
              }
              Object ic = initContextClass.newInstance();
              Class[] lookupSig = new Class[] { String.class };
              Object[] lookupArgs =
                  new String[] {
                       serviceNS + "::" + serviceName + "::" + portTypeNS + "::" + portTypeName
};
              Method m = initContextClass.getMethod("lookup", lookupSig);
              ws = (WSIFService) m.invoke(ic, lookupArgs);
          } catch (Exception e) {
              throw new WSIFException(
                  "Exception while looking up JNDI factory: " + e.getMessage(),
                  e);
          }
          Tr.exit(ws);
          return ws;
      }
  
      public static Service selectService(
          Definition def,
          String serviceNS,
          String serviceName)
          throws WSIFException {
          Tr.entry(null, def, serviceNS, serviceName);
          Map services = getAllItems(def, "Service");
          QName serviceQName =
              ((serviceNS != null && serviceName != null)
                  ? new QName(serviceNS, serviceName)
                  : null);
          Service service = (Service) getNamedItem(services, serviceQName, "Service");
  
          Tr.exit(service);
          return service;
      }
  
      public static PortType selectPortType(
          Definition def,
          String portTypeNS,
          String portTypeName)
          throws WSIFException {
          Tr.entry(null, def, portTypeNS, portTypeName);
          Map portTypes = getAllItems(def, "PortType");
          QName portTypeQName =
              ((portTypeNS != null && portTypeName != null)
                  ? new QName(portTypeNS, portTypeName)
                  : null);
          PortType portType =
              (PortType) getNamedItem(portTypes, portTypeQName, "PortType");
  
          Tr.exit(portType);
          return portType;
      }
  
      public static void addDefinedItems(
          Map fromItems,
          String itemType,
          Map toItems) {
          Tr.entry(null, fromItems, itemType, toItems);
  
          if (fromItems != null) {
              Iterator entryIterator = fromItems.entrySet().iterator();
  
              if (itemType.equals("Message")) {
                  while (entryIterator.hasNext()) {
                      Map.Entry entry = (Map.Entry) entryIterator.next();
                      Message message = (Message) entry.getValue();
  
                      if (!message.isUndefined()) {
                          toItems.put(entry.getKey(), message);
                      }
                  }
              } else if (itemType.equals("Operation")) {
                  while (entryIterator.hasNext()) {
                      Map.Entry entry = (Map.Entry) entryIterator.next();
                      Operation operation = (Operation) entry.getValue();
  
                      if (!operation.isUndefined()) {
                          toItems.put(entry.getKey(), operation);
                      }
                  }
              } else if (itemType.equals("PortType")) {
                  while (entryIterator.hasNext()) {
                      Map.Entry entry = (Map.Entry) entryIterator.next();
                      PortType portType = (PortType) entry.getValue();
  
                      if (!portType.isUndefined()) {
                          toItems.put(entry.getKey(), portType);
                      }
                  }
              } else if (itemType.equals("Binding")) {
                  while (entryIterator.hasNext()) {
                      Map.Entry entry = (Map.Entry) entryIterator.next();
                      Binding binding = (Binding) entry.getValue();
  
                      if (!binding.isUndefined()) {
                          toItems.put(entry.getKey(), binding);
                      }
                  }
              } else if (itemType.equals("Service")) {
                  while (entryIterator.hasNext()) {
                      Map.Entry entry = (Map.Entry) entryIterator.next();
                      Service service = (Service) entry.getValue();
  
                      toItems.put(entry.getKey(), service);
                  }
              }
          }
          Tr.exit();
      }
  
      private static void getAllItems(Definition def, String itemType, Map toItems) {
          Tr.entry(null, def, itemType, toItems);
          Map items = null;
  
          if (itemType.equals("PortType")) {
              items = def.getPortTypes();
          } else if (itemType.equals("Service")) {
              items = def.getServices();
          } else {
              throw new IllegalArgumentException(
                  "Don't know how to find all " + itemType + "s.");
          }
  
          addDefinedItems(items, itemType, toItems);
  
          Map imports = def.getImports();
  
          if (imports != null) {
              Iterator valueIterator = imports.values().iterator();
  
              while (valueIterator.hasNext()) {
                  List importList = (List) valueIterator.next();
  
                  if (importList != null) {
                      Iterator importIterator = importList.iterator();
  
                      while (importIterator.hasNext()) {
                          Import tempImport = (Import) importIterator.next();
  
                          if (tempImport != null) {
                              Definition importedDef = tempImport.getDefinition();
  
                              if (importedDef != null) {
                                  getAllItems(importedDef, itemType, toItems);
                              }
                          }
                      }
                  }
              }
          }
          Tr.exit();
      }
  
      public static Map getAllItems(Definition def, String itemType) {
          Tr.entry(null, def, itemType);
          Map ret = new HashMap();
  
          getAllItems(def, itemType, ret);
  
          Tr.exit(ret);
          return ret;
      }
  
      public static Object getNamedItem(Map items, QName qname, String itemType)
          throws WSIFException {
          Tr.entry(null, items, qname, itemType);
          if (qname != null) {
              Object item = items.get(qname);
  
              if (item != null) {
                  Tr.exit(item);
                  return item;
              } else {
                  throw new WSIFException(
                      itemType
                          + " '"
                          + qname
                          + "' not found. Choices are: "
                          + getCommaListFromQNameMap(items));
              }
          } else {
              int size = items.size();
  
              if (size == 1) {
                  Iterator valueIterator = items.values().iterator();
  
                  Object o = valueIterator.next();
                  Tr.exit(o);
                  return o;
              } else if (size == 0) {
                  throw new WSIFException("WSDL document contains no " + itemType + "s.");
              } else {
                  throw new WSIFException(
                      "Please specify a "
                          + itemType
                          + ". Choices are: "
                          + getCommaListFromQNameMap(items));
              }
          }
      }
  
      private static String getCommaListFromQNameMap(Map qnameMap) {
          StringBuffer strBuf = new StringBuffer("{");
          Set keySet = qnameMap.keySet();
          Iterator keyIterator = keySet.iterator();
          int index = 0;
  
          while (keyIterator.hasNext()) {
              QName key = (QName) keyIterator.next();
  
              strBuf.append((index > 0 ? ", " : "") + key);
              index++;
          }
  
          strBuf.append("}");
  
          return strBuf.toString();
      }
  
      /**
       * Read WSDL - it is different from standard readWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.
       */
      public static Definition readWSDL(String contextURL, String wsdlLoc)
          throws WSDLException {
          Tr.entry(null, contextURL, wsdlLoc);
  
          initializeProviders();
  
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader wsdlReader = factory.newWSDLReader();
          wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
          try {
              Definition def = wsdlReader.readWSDL(contextURL, wsdlLoc);
  
              if (oldPropValue != null) {
                  props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
              } else {
                  props.remove(DEF_FACTORY_PROPERTY_NAME);
              }
              Tr.exitExpandWsdl(def);
              return def;
          } catch (WSDLException e) {
              // Log message
              MessageLogger messageLog =
                  MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
              messageLog.message(
                  WSIFConstants.TYPE_ERROR,
                  "WSIF.0002E",
                  new Object[] { wsdlLoc });
              messageLog.destroy();
              // End message
              throw e;
          }
      }
  
      /**
       * Read WSDL - it is different from standard readWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.  It also uses the accompanying class loader to load imported WSDL
       * resources.
       */
      public static Definition readWSDL(
          URL contextURL,
          Reader reader,
          ClassLoader cl)
          throws WSDLException {
          Tr.entry(null, contextURL, reader, cl);
  
          initializeProviders();
  
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader wsdlReader = factory.newWSDLReader();
          wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
          try {
              String url = (contextURL == null) ? null : contextURL.toString();
              Definition def = wsdlReader.readWSDL(url, new InputSource(reader), cl);
  
              if (oldPropValue != null) {
                  props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
              } else {
                  props.remove(DEF_FACTORY_PROPERTY_NAME);
              }
              Tr.exitExpandWsdl(def);
              return def;
          } catch (WSDLException e) {
              // Log message
              MessageLogger messageLog =
                  MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
              messageLog.message(
                  WSIFConstants.TYPE_ERROR,
                  "WSIF.0002E",
                  new Object[] { contextURL });
              messageLog.destroy();
              // End message
              throw e;
          }
      }
  
      /**
       * Read WSDL - it is different from standard readWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.  It also uses the accompanying class loader to load imported WSDL
       * resources.
       */
      public static Definition readWSDL(
          URL contextURL,
          String wsdlLoc,
          ClassLoader cl)
          throws WSDLException {
          Tr.entry(null, contextURL, wsdlLoc, cl);
  
          initializeProviders();
  
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader wsdlReader = factory.newWSDLReader();
          wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
  
          try {
              String url = (contextURL == null) ? null : contextURL.toString();
              Definition def = wsdlReader.readWSDL(url, wsdlLoc, cl);
  
              if (oldPropValue != null) {
                  props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
              } else {
                  props.remove(DEF_FACTORY_PROPERTY_NAME);
              }
              Tr.exitExpandWsdl(def);
              return def;
          } catch (WSDLException e) {
              // Log message
              MessageLogger messageLog =
                  MessageLogger.newMessageLogger("WSIF", "org.apache.wsif.catalog.Messages");
              messageLog.message(
                  WSIFConstants.TYPE_ERROR,
                  "WSIF.0002E",
                  new Object[] { wsdlLoc });
              messageLog.destroy();
              // End message
              throw e;
          }
      }
  
      /**
       * Read WSDL - it is different from standard readWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.
       */
      public static Definition readWSDL(String contextURL, Reader reader)
          throws WSDLException {
          Tr.entry(null, contextURL, reader);
  
          initializeProviders();
  
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader wsdlReader = factory.newWSDLReader();
          wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
          Definition def = wsdlReader.readWSDL(contextURL, new InputSource(reader));
  
          if (oldPropValue != null) {
              props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
          } else {
              props.remove(DEF_FACTORY_PROPERTY_NAME);
          }
  
          Tr.exitExpandWsdl(def);
          return def;
      }
  
      /**
       * Read WSDL - it is different from standard readWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.
       */
      public static Definition readWSDL(String contextURL, Document wsdlDocument)
          throws WSDLException {
          Tr.entry(null, contextURL, wsdlDocument);
  
          initializeProviders();
  
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader wsdlReader = factory.newWSDLReader();
          wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
          Definition def = wsdlReader.readWSDL(contextURL, wsdlDocument);
  
          if (oldPropValue != null) {
              props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
          } else {
              props.remove(DEF_FACTORY_PROPERTY_NAME);
          }
  
          Tr.exitExpandWsdl(def);
          return def;
      }
  
      /**
       * Read WSDL - it is different from standard readWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.
       */
      public static Definition readWSDL(
          String contextURL,
          Element wsdlServicesElement)
          throws WSDLException {
          Tr.entry(null, contextURL, wsdlServicesElement);
  
          initializeProviders();
  
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLReader wsdlReader = factory.newWSDLReader();
          wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
          Definition def = wsdlReader.readWSDL(contextURL, wsdlServicesElement);
  
          if (oldPropValue != null) {
              props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
          } else {
              props.remove(DEF_FACTORY_PROPERTY_NAME);
          }
  
          Tr.exitExpandWsdl(def);
          return def;
      }
  
      /**
       * Write WSDL - it is different from standard writeWSDL method as it is
       * using extensibility elements that were registered for dynamic port
       * factory.
       */
      public static void writeWSDL(Definition def, Writer sink)
          throws WSDLException {
          Tr.entry(null, def, sink);
          Properties props = System.getProperties();
          String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  
          props.setProperty(DEF_FACTORY_PROPERTY_NAME, WSIFConstants.WSIF_WSDLFACTORY);
  
          WSDLFactory factory = WSDLFactory.newInstance();
          WSDLWriter wsdlWriter = factory.newWSDLWriter();
          wsdlWriter.writeWSDL(def, sink);
  
          if (oldPropValue != null) {
              props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
          } else {
              props.remove(DEF_FACTORY_PROPERTY_NAME);
          }
          Tr.exit();
      }
  
      public static Definition getDefinitionFromLocation(
          String contextURL,
          String location)
          throws WSIFException {
          Tr.entry(null, contextURL, location);
  
          if (location == null) {
              throw new WSIFException("WSDL location must not be null.");
          }
  
          Definition def = null;
          try {
              def = WSIFUtils.readWSDL(contextURL, location);
          } catch (WSDLException e) {
              throw new WSIFException("Problem reading WSDL document.", e);
          }
          Tr.exitExpandWsdl(def);
          return def;
      }
  
      public static Definition getDefinitionFromContent(
          String contextURL,
          String content)
          throws WSIFException {
          Tr.entry(null, contextURL, content);
          if (content == null) {
              throw new WSIFException("WSDL content must not be null.");
          }
  
          Definition def = null;
          try {
              def = WSIFUtils.readWSDL(contextURL, new StringReader(content));
          } catch (WSDLException e) {
              throw new WSIFException("Problem reading WSDL document.", e);
          }
          Tr.exitExpandWsdl(def);
          return def;
      }
  
      private static Boolean providersInitialized = new Boolean(false);
  
      /**
       * Initialize the WSIF providers. Each provider initializes its WSDL
       * extension registries. This has no effect if AutoLoad providers has
       * been turned off on WSIFServiceImpl ... in that case it is the
       * responsibility of the application to initialize providers.
       */
      private static void initializeProviders() {
          synchronized (providersInitialized) {
              if (!providersInitialized.booleanValue()) {
                  WSIFServiceImpl.getDynamicWSIFProvider("/");
                  providersInitialized = new Boolean(true);
              }
          }
      }
  
      // the following code copied from JCAUtils
      public static WSIFFormatHandler getFormatHandler(
          Part part,
          Definition definition,
          javax.wsdl.Binding binding)
          throws
              java.lang.InstantiationException,
              java.lang.IllegalAccessException,
              java.lang.ClassNotFoundException {
          Tr.entry(null, part, definition, binding);
          WSIFFormatHandler formatHandler = null;
          javax.wsdl.QName partTypeQName = part.getTypeName();
          if (partTypeQName == null)
              partTypeQName = part.getElementName();
          if (partTypeQName == null)
              throw new ClassNotFoundException(part.getName());
  
          String typePackageName =
              getPackageNameFromNamespaceURI(partTypeQName.getNamespaceURI());
          String formatHandlerName = typePackageName;
  
          String bindingShortName =
              getPackageNameFromXMLName(definition.getPrefix(getBindingNamespace(binding)));
          if (bindingShortName != null)
              formatHandlerName = formatHandlerName + DOT + bindingShortName;
  
          if (getFormatStylePackage(binding) != null)
              formatHandlerName = formatHandlerName + DOT + getFormatStylePackage(binding);
  
          String formatHandlerShortName =
              formatHandlerName
                  + DOT
                  + getJavaClassNameFromXMLName(partTypeQName.getLocalPart());
  
          try {
              ClassLoader cl = Thread.currentThread().getContextClassLoader();
              formatHandler =
                  (WSIFFormatHandler) cl
                      .loadClass(formatHandlerShortName + FORMAT_HANDLER)
                      .newInstance();
          } catch (ClassNotFoundException exn1) {
              try {
                  ClassLoader cl = Thread.currentThread().getContextClassLoader();
                  formatHandler =
                      (WSIFFormatHandler) cl
                          .loadClass(formatHandlerShortName + ELEMENT_FORMAT_HANDLER)
                          .newInstance();
              } catch (ClassNotFoundException exn2) {
                  try {
                      formatHandler =
                          (WSIFFormatHandler) Class
                              .forName(formatHandlerShortName + FORMAT_HANDLER)
                              .newInstance();
                  } catch (ClassNotFoundException exn3) {
                      //try {
                      formatHandler =
                          (WSIFFormatHandler) Class
                              .forName(formatHandlerShortName + ELEMENT_FORMAT_HANDLER)
                              .newInstance();
                      //}
                      //catch (ClassNotFoundException exn4) {
                      //	throw new ClassNotFoundException(JCAResource.get("IWAA0101E", formatHandlerName));
                      //}
                  }
              }
          }
          //catch (Throwable exn3) {
          //throw new ClassNotFoundException(JCAResource.get("IWAA0102E", formatHandlerName,
exn3.getLocalizedMessage()));
          //}
          if (formatHandler == null)
              //throw new ClassNotFoundException(JCAResource.get("IWAA0101E", formatHandlerName));
              throw new ClassNotFoundException(formatHandlerName);
          else {
              Tr.exit(formatHandler);
              return formatHandler;
          }
      }
  
      public static String getPackageNameFromNamespaceURI(String namespaceURI) {
          Tr.entry(null, namespaceURI);
          // Get the segments in the namespace URI
          List segments = getNamespaceURISegments(namespaceURI);
  
          StringBuffer packageNameBuffer = new StringBuffer();
          for (int i = 0; i < segments.size(); i++) {
              String name;
  
              // The first segment is the host name
              if (i == 0) {
  
                  // Turn segment into a valid package segment name
                  name = getPackageNameFromXMLName((String) segments.get(i));
  
                  // Reverse its components
                  StringTokenizer tokenizer = new StringTokenizer(name, ".");
                  List host = new ArrayList();
                  for (; tokenizer.hasMoreTokens();) {
                      host.add(0, tokenizer.nextToken());
                  }
                  StringBuffer buffer = new StringBuffer();
                  for (Iterator hi = host.iterator(); hi.hasNext();) {
                      if (buffer.length() != 0)
                          buffer.append('.');
                      String nextSegment = (String) hi.next();
                      if (!Character.isJavaIdentifierStart(nextSegment.toCharArray()[0]))
                          nextSegment = "_" + nextSegment;
                      buffer.append(nextSegment);
                  }
                  name = buffer.toString();
              } else {
  
                  // Turn segment into a valid java name
                  name = getJavaNameFromXMLName((String) segments.get(i));
                  if (!Character.isJavaIdentifierStart(name.toCharArray()[0]))
                      name = "_" + name;
  
              }
  
              // Concatenate segments, separated by '.'
              if (name.length() == 0)
                  continue;
              if (packageNameBuffer.length() != 0)
                  packageNameBuffer.append('.');
              packageNameBuffer.append(name);
          }
          Tr.exit(packageNameBuffer.toString());
          return packageNameBuffer.toString();
      }
  
      public static String getJavaNameFromXMLName(String xmlName, String delims) {
          Tr.entry(null, xmlName, delims);
          StringTokenizer tokenizer = new StringTokenizer(xmlName, delims);
          StringBuffer buffer = new StringBuffer();
          while (tokenizer.hasMoreTokens()) {
              buffer.append(tokenizer.nextToken());
          }
          String result = buffer.toString();
          if (!Character.isJavaIdentifierStart(result.toCharArray()[0]))
              result = "_" + result;
          Tr.exit(result);
          return result;
      }
  
      public static String getJavaNameFromXMLName(String xmlName) {
          Tr.entry(null, xmlName);
          String s =
              getJavaNameFromXMLName(
                  xmlName,
                  "\u002D\u002E\u003A\u005F\u00B7\u0387\u06DD\u06DE");
          Tr.exit(s);
          return s;
      }
  
      public static String getPackageNameFromXMLName(String xmlName) {
          Tr.entry(null, xmlName);
  
          // Tokenize, don't consider '.' as a delimiter here
          String name =
              getJavaNameFromXMLName(xmlName, "\u002D\u003A\u005F\u00B7\u0387\u06DD\u06DE");
  
          // Tokenize using delimiter '.' and add the tokens separated by '.'
          // This is to ensure that we have no heading/trailing/dup '.' in the string
          StringTokenizer tokenizer = new StringTokenizer(name, ".");
          StringBuffer buffer = new StringBuffer();
          for (; tokenizer.hasMoreTokens();) {
              if (buffer.length() != 0)
                  buffer.append('.');
              // -->				
              String nextSegment = (String) tokenizer.nextToken();
              if (!Character.isJavaIdentifierStart(nextSegment.toCharArray()[0]))
                  nextSegment = "_" + nextSegment;
              buffer.append(nextSegment);
  
              //			buffer.append(tokenizer.nextToken());
              // <--				
          }
          Tr.exit(buffer.toString());
          return buffer.toString();
      }
  
      private static List getNamespaceURISegments(String namespaceURI) {
          Tr.entry(null, namespaceURI);
  
          // Tokenize
          List segments = new ArrayList();
          StringTokenizer tokenizer = new StringTokenizer(namespaceURI, ":/");
          while (tokenizer.hasMoreTokens()) {
              segments.add(tokenizer.nextToken());
          }
  
          // Remove protocol
          if (!segments.isEmpty()) {
              try {
                  URL url = new URL(namespaceURI);
                  if (segments.get(0).equals(url.getProtocol()))
                      segments.remove(0);
              } catch (MalformedURLException exn) {
              }
          }
          Tr.exit(segments);
          return segments;
      }
  
      private static String getBindingNamespace(Binding bindingModel) {
          Tr.entry(null, bindingModel);
          Iterator iterator = bindingModel.getExtensibilityElements().iterator();
          String returnNamespace = null;
          while (iterator.hasNext()) {
              ExtensibilityElement ee = (ExtensibilityElement) iterator.next();
              if (returnNamespace == null) {
                  String namespace = ee.getElementType().getNamespaceURI();
                  if (!namespace.endsWith(PHYSICALREP) && !namespace.endsWith(FORMATBINDING))
{
                      returnNamespace = namespace;
                  }
              }
          }
          Tr.exit(returnNamespace);
          return returnNamespace;
      }
  
      public static String getFormatStylePackage(Binding bindingModel) {
          Tr.entry(null, bindingModel);
  
          Iterator iterator = bindingModel.getExtensibilityElements().iterator();
          String formatPackageName = null;
          while (iterator.hasNext()) {
              ExtensibilityElement ee = (ExtensibilityElement) iterator.next();
              if (ee instanceof TypeMapping) {
                  TypeMapping typeMapping = (TypeMapping) ee;
                  formatPackageName = typeMapping.getEncoding();
                  if (typeMapping.getStyle() != null)
                      formatPackageName += typeMapping.getStyle();
              }
              if (formatPackageName != null)
                  break;
          }
          String s = null;
          if (formatPackageName != null) {
              //			return getJavaNameFromXMLName(formatPackageName);
              s = getPackageNameFromXMLName(formatPackageName);
          } else {
              s = formatPackageName;
          }
          Tr.exit(s);
          return s;
      }
  
      public static String getFormatHandlerName(
          Part part,
          Definition definition,
          Binding binding)
          throws
              java.lang.InstantiationException,
              java.lang.IllegalAccessException,
              java.lang.ClassNotFoundException {
          Tr.entry(null, part, definition, binding);
  
          javax.wsdl.QName partTypeQName = part.getTypeName();
          if (partTypeQName == null)
              partTypeQName = part.getElementName();
          if (partTypeQName == null)
              throw new ClassNotFoundException(part.getName());
  
          String typePackageName =
              getPackageNameFromNamespaceURI(partTypeQName.getNamespaceURI());
          String formatHandlerName = typePackageName;
  
          String bindingShortName =
              getPackageNameFromXMLName(definition.getPrefix(getBindingNamespace(binding)));
          if (bindingShortName != null)
              formatHandlerName = formatHandlerName + DOT + bindingShortName;
  
          if (getFormatStylePackage(binding) != null)
              formatHandlerName = formatHandlerName + DOT + getFormatStylePackage(binding);
  
          formatHandlerName =
              formatHandlerName
                  + DOT
                  + getJavaClassNameFromXMLName(partTypeQName.getLocalPart())
                  + FORMAT_HANDLER;
  
          Tr.exit(formatHandlerName);
          return formatHandlerName;
      }
  
      public static String getJavaClassNameFromXMLName(String xmlName) {
          Tr.entry(null, xmlName);
          String s =
              getJavaClassNameFromXMLName(
                  xmlName,
                  "\u002D\u002E\u003A\u005F\u00B7\u0387\u06DD\u06DE");
          Tr.exit(s);
          return s;
      }
  
      public static String getJavaClassNameFromXMLName(
          String xmlName,
          String delims) {
          Tr.entry(null, xmlName, delims);
          StringTokenizer tokenizer = new StringTokenizer(xmlName, delims);
          StringBuffer buffer = new StringBuffer();
          while (tokenizer.hasMoreTokens()) {
              String nextSegment = (String) tokenizer.nextToken();
              if (nextSegment.length() > 0) {
                  nextSegment =
                      Character.toUpperCase((nextSegment.toCharArray())[0])
                          + nextSegment.substring(1);
              }
              buffer.append(nextSegment);
          }
          String result = buffer.toString();
          if (!Character.isJavaIdentifierStart(result.toCharArray()[0]))
              result = "_" + result;
          Tr.exit(result);
          return result;
      }
  }
  
  
  1.2       +2 -1      xml-axis-wsif/java/test/faults/FaultMsgTest.java
  
  Index: FaultMsgTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/faults/FaultMsgTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FaultMsgTest.java	6 Jun 2002 08:28:55 -0000	1.1
  +++ FaultMsgTest.java	11 Jun 2002 15:14:51 -0000	1.2
  @@ -74,7 +74,8 @@
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  -import org.apache.wsif.stub.WSIFUtils;
  +import org.apache.wsif.util.WSIFUtils;
  +
   import util.TestUtilities;
   
   /**
  
  
  
  1.2       +2 -1      xml-axis-wsif/java/test/providers/ProvidersInitialisationTest.java
  
  Index: ProvidersInitialisationTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/providers/ProvidersInitialisationTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProvidersInitialisationTest.java	6 Jun 2002 08:28:58 -0000	1.1
  +++ ProvidersInitialisationTest.java	11 Jun 2002 15:14:51 -0000	1.2
  @@ -67,7 +67,8 @@
   import org.apache.wsif.WSIFPort;
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
  -import org.apache.wsif.stub.WSIFUtils;
  +import org.apache.wsif.util.WSIFUtils;
  +
   import util.TestUtilities;
   
   public class ProvidersInitialisationTest extends TestCase {
  
  
  
  1.2       +1 -1      xml-axis-wsif/java/src/org/apache/wsif/providers/WSIFDynamicTypeMap.java
  
  Index: WSIFDynamicTypeMap.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/WSIFDynamicTypeMap.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSIFDynamicTypeMap.java	6 Jun 2002 08:28:50 -0000	1.1
  +++ WSIFDynamicTypeMap.java	11 Jun 2002 15:14:51 -0000	1.2
  @@ -64,7 +64,7 @@
   
   import javax.wsdl.QName;
   import org.apache.wsif.logging.Tr;
  -import org.apache.wsif.stub.WSIFUtils;
  +import org.apache.wsif.util.WSIFUtils;
   
   /**
    * Container for type mappings that can be used by dynamic providers.
  
  
  
  1.2       +2 -2      xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSMessage.java
  
  Index: JMSMessage.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSMessage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMSMessage.java	6 Jun 2002 08:28:51 -0000	1.1
  +++ JMSMessage.java	11 Jun 2002 15:14:51 -0000	1.2
  @@ -83,8 +83,8 @@
   import org.apache.wsif.WSIFException;
   import org.apache.wsif.format.jms.JMSFormatHandler;
   import org.apache.wsif.logging.Tr;
  -import org.apache.wsif.stub.WSIFUtils;
   import org.apache.wsif.util.WSIFDefaultMessage;
  +import org.apache.wsif.util.WSIFUtils;
   import org.apache.wsif.wsdl.extensions.format.TypeMapping;
   import org.apache.xml.serialize.OutputFormat;
   import org.apache.xml.serialize.TextSerializer;
  @@ -677,7 +677,7 @@
               else
                   fh = (org.apache.wsif.format.jms.JMSFormatHandler)
                       //antxxx     			org.apache.wsif.jca.util.JCAUtil.getFormatHandler(
  -    org.apache.wsif.stub.WSIFUtils.getFormatHandler(
  +    org.apache.wsif.util.WSIFUtils.getFormatHandler(
           partModel,
           this.fieldDefinitionModel,
           this.fieldBindingModel);
  
  
  
  1.2       +2 -1      xml-axis-wsif/java/test/headers/HeadersTest.java
  
  Index: HeadersTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/headers/HeadersTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HeadersTest.java	7 Jun 2002 08:25:45 -0000	1.1
  +++ HeadersTest.java	11 Jun 2002 15:14:51 -0000	1.2
  @@ -72,8 +72,9 @@
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  -import org.apache.wsif.stub.WSIFUtils;
   import org.apache.wsif.util.WSIFDefaultMessage;
  +import org.apache.wsif.util.WSIFUtils;
  +
   import util.TestUtilities;
   
   /**
  
  
  
  1.6       +1 -1      xml-axis-wsif/java/test/async/AsyncTest.java
  
  Index: AsyncTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AsyncTest.java	10 Jun 2002 10:35:29 -0000	1.5
  +++ AsyncTest.java	11 Jun 2002 15:14:51 -0000	1.6
  @@ -75,8 +75,8 @@
   import org.apache.wsif.util.WSIFDefaultMessage;
   import org.apache.wsif.util.WSIFDefaultCorrelationService;
   import org.apache.wsif.util.WSIFCorrelationServiceLocator;
  +import org.apache.wsif.util.WSIFUtils;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
  -import org.apache.wsif.stub.WSIFUtils;
   import util.TestUtilities;
   import org.apache.wsif.util.jms.JMSAsyncListener;
   
  
  
  

Mime
View raw message