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/src/org/apache/wsif/providers/java WSIFOperation_Java.java
Date Wed, 04 Dec 2002 17:27:02 GMT
owenb       2002/12/04 09:27:01

  Modified:    java/src/org/apache/wsif/providers/ejb
                        WSIFOperation_EJB.java
               java/src/org/apache/wsif/providers/java
                        WSIFOperation_Java.java
  Added:       java/src/org/apache/wsif/providers ProviderUtils.java
  Log:
  Updates to compatibility methods so that the Java and EJB providers better interoperate
with the SOAP providers:
  - Allow arrays of Strings* to be passed as part values when the method argument is an array
of chars or Characters
    * All the Strings must have length 1
  - Convert all return values of type Character (char) to Strings
  - Move common methods to a new ProviderUtils class
  
  These conversions are useful because the XML schema does not define a char type
  
  Revision  Changes    Path
  1.1                  xml-axis-wsif/java/src/org/apache/wsif/providers/ProviderUtils.java
  
  Index: ProviderUtils.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.providers;
  
  import java.lang.reflect.Array;
  
  import org.apache.wsif.WSIFException;
  
  /**
   * A class of static utility methods for use across multiple providers
   * 
   * @author Owen Burroughs <owenb@apache.org>
   */
  public class ProviderUtils {
  	
  	/**
  	 * Convert an array of any dimensions containing only Strings of length 1, to an array
  	 * of java.lang.Characters which has the same dimensions.
  	 * @param obj The array of Strings
  	 * @return The Character array
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
  	public static Object stringArrayToCharacterArray(Object obj) throws WSIFException {
  		return stringArrayToCharacterArray(obj, null);
  	}
  	
  	/**
  	 * Convert an array of any dimensions containing only Strings of length 1, to an array
  	 * of java.lang.Characters which has the same dimensions.
  	 * @param obj The array of Strings
  	 * @param ret temporary array used in rescursion. The first call should be passed null.
  	 * @return The Character array
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
      protected static Object stringArrayToCharacterArray(Object obj, Object ret) throws WSIFException
{
      	if (obj.getClass().isArray()) {    		
      		Object[] objs = (Object[]) obj;
      		ret = new Object[objs.length];
      		for (int i=0; i<objs.length; i++) {
      			Object temp = stringArrayToCharacterArray(objs[i], ((Object[]) ret)[i]);
      			if (i == 0) {
      				Class tempc = temp.getClass();
      				ret = Array.newInstance(tempc, objs.length);    				
      			}
      			((Object[]) ret)[i] = temp;
      		}
      		return ret;
      	} else if (obj instanceof String) {
      		String s = (String) obj;
      		if (s.length() == 1) {
      			ret = new Character(s.charAt(0));
      			return ret;
      		} else {
      			throw new WSIFException("String is longer than 1 character");
      		}
      	} else {
      		throw new WSIFException("Array entry is not a String or another array");
      	}
      }
  
  	/**
  	 * Convert an array of any dimensions containing only Strings of length 1, to an array
  	 * of chars which has the same dimensions.
  	 * @param obj The array of Strings
  	 * @return The char array
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
  	public static Object stringArrayToCharArray(Object obj) throws WSIFException {
  		return stringArrayToCharArray(obj, null);
  	}
  
  	/**
  	 * Convert an array of any dimensions containing only Strings of length 1, to an array
  	 * of chars which has the same dimensions.
  	 * @param obj The array of Strings
  	 * @param ret temporary array used in rescursion. The first call should be passed null.
  	 * @return The char array
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */	
      protected static Object stringArrayToCharArray(Object obj, Object ret) throws WSIFException
{
      	if (obj.getClass().isArray()) {    		
      		Object[] objs = (Object[]) obj;
      		ret = new Object[objs.length];
      		for (int i=0; i<objs.length; i++) {
      			Object temp = stringArrayToCharArray(objs[i], ((Object[]) ret)[i]);
      			if (i == 0) {
      				Class tempc = temp.getClass();
      				ret = Array.newInstance(tempc, objs.length);    				
      			}
      			((Object[]) ret)[i] = temp;
      			if (temp instanceof Character && (i == objs.length - 1)) {
  					char[] tempca = new char[objs.length];
  					for (int j=0; j<objs.length; j++) {
  						tempca[j] = ((Character[]) ret)[j].charValue();
  					}
  					ret = tempca;		    				
      			}
      		}
      		return ret;
      	} else if (obj instanceof String) {
      		String s = (String) obj;
      		if (s.length() == 1) {
      			ret = new Character(s.charAt(0));
      			return ret;
      		} else {
      			throw new WSIFException("String is longer than 1 character");
      		}
      	} else {
      		throw new WSIFException("Array entry is not a String or another array");
      	}
      }
  
  	/**
  	 * Convert an array of java.lang.Characters of any dimensions to an equivalent array 
  	 * of java.lang.Strings which has the same dimensions.
  	 * @param obj The array of Characters
  	 * @return The array of Strings
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
  	public static Object characterArrayToStringArray(Object obj) throws WSIFException {
  		return characterArrayToStringArray(obj, null);
  	}
  
  	/**
  	 * Convert an array of java.lang.Characters of any dimensions to an equivalent array 
  	 * of java.lang.Strings which has the same dimensions.
  	 * @param obj The array of Characters
  	 * @param ret temporary array used in rescursion. The first call should be passed null.
  	 * @return The array of Strings
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
      protected static Object characterArrayToStringArray(Object obj, Object ret) throws WSIFException
{
      	if (obj.getClass().isArray()) {    		
      		Object[] objs = (Object[]) obj;
      		ret = new Object[objs.length];
      		for (int i=0; i<objs.length; i++) {
      			Object temp = characterArrayToStringArray(objs[i], ((Object[]) ret)[i]);
      			if (i == 0) {
      				Class tempc = temp.getClass();
      				ret = Array.newInstance(tempc, objs.length);    				
      			}
      			((Object[]) ret)[i] = temp;
      		}
      		return ret;
      	} else if (obj instanceof Character) {
      		String s = obj.toString();
  			return s;
      	} else {
      		throw new WSIFException("Array entry is not a Character or another array");
      	}
      }
  
  	/**
  	 * Convert an array of chars of any dimensions to an equivalent array 
  	 * of java.lang.Strings which has the same dimensions.
  	 * @param obj The array of chars
  	 * @return The array of Strings
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
  	public static Object charArrayToStringArray(Object obj) throws WSIFException {
  		return charArrayToStringArray(obj, null);
  	}
  
  	/**
  	 * Convert an array of chars of any dimensions to an equivalent array 
  	 * of java.lang.Strings which has the same dimensions.
  	 * @param obj The array of chars
  	 * @param ret temporary array used in rescursion. The first call should be passed null.
  	 * @return The array of Strings
  	 * @exception A WSIFException thrown if the conversion fails for any reason.
  	 */
      protected static Object charArrayToStringArray(Object obj, Object ret) throws WSIFException
{
      	if (obj.getClass().isArray()) {
      		if (obj instanceof char[]) {
      			char[] ca = (char[]) obj;
      			Character[] chra = new Character[ca.length];
      			for (int j=0; j<ca.length; j++) {
      				chra[j] = new Character(ca[j]);
      			}
      			obj = chra;
      		}    		
      		Object[] objs = (Object[]) obj;
      		ret = new Object[objs.length];
      		for (int i=0; i<objs.length; i++) {
      			Object temp = charArrayToStringArray(objs[i], ((Object[]) ret)[i]);
      			if (i == 0) {
      				Class tempc = temp.getClass();
      				ret = Array.newInstance(tempc, objs.length);    				
      			}
      			((Object[]) ret)[i] = temp;
      		}
      		return ret;
      	} else if (obj instanceof Character) {
      		String s = obj.toString();
  			return s;
      	} else {
      		throw new WSIFException("Array entry is not a char or another array");
      	}
      }
  
  	/**
  	 * Convert a String to a Character. If the String is longer than one character
  	 * this method will return null;
  	 * @param str The String
  	 * @return The Character or null if the String was longer than one character	 
  	 */
      public static Character stringToCharacter(String str) {
          if (str.length() != 1)
              return null;
          return new Character(str.charAt(0));
      }
  
  	/**
  	 * Returns a default Object value for a given Class. If the Class is a primitive type
  	 * the method will return the default value for that primitive type wrapped up in its
  	 * object form. For example, invoking the method with int.class will return a new 
  	 * java.lang.Integer with an int value of 0. If the Class does not represent a
  	 * primitive type then null will be returned.
  	 * @param cls The Class
  	 * @return The default object value
  	 */
  	public static Object getDefaultObject(Class cls) {
  		if (cls == null) {
  			return null;
  		} else if (cls.isPrimitive()) {
  			if (cls.getName().equals("int")) {
  				return new Integer(0);
  			} else if (cls.getName().equals("char")) {
  				return new Character('0');
  			} else if (cls.getName().equals("long")) {
  				return new Long(0);
  			} else if (cls.getName().equals("short")) {
  				short s = 0;
  				return new Short(s);
  			} else if (cls.getName().equals("double")) {
  				return new Double(0);
  			} else if (cls.getName().equals("boolean")) {
  				return new Boolean(false);
  			} else if (cls.getName().equals("byte")) {
  				byte b = 0;
  				return new Byte(b);
  			} else {
  				return new Float(0);
  			}
  		} else {
  			return null;
  		}
  	}   	
  }
  
  
  
  1.23      +85 -85    xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java
  
  Index: WSIFOperation_EJB.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/ejb/WSIFOperation_EJB.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- WSIFOperation_EJB.java	22 Nov 2002 15:56:36 -0000	1.22
  +++ WSIFOperation_EJB.java	4 Dec 2002 17:27:00 -0000	1.23
  @@ -88,6 +88,7 @@
   import org.apache.wsif.base.WSIFDefaultOperation;
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Trc;
  +import org.apache.wsif.providers.ProviderUtils;
   import org.apache.wsif.wsdl.extensions.ejb.EJBOperation;
   import org.apache.wsif.wsdl.extensions.format.TypeMap;
   import org.apache.wsif.wsdl.extensions.format.TypeMapping;
  @@ -777,7 +778,7 @@
           for (int i = 0; i < parmTypes.length; i++) {
               // If the arg is a null then skip it
               if (args[i] == null) {
  -                compatibleArgs[i] = getDefaultObject(parmTypes[i]);
  +                compatibleArgs[i] = ProviderUtils.getDefaultObject(parmTypes[i]);
                   continue;
               }
               // Consider the special cas, squeezing a String into a Character
  @@ -796,10 +797,33 @@
       }
   
       protected Object getCompatibleReturn(Method method, Object returnObj) {
  -        Trc.entry(this,method,returnObj);
  -        Object o = null;
  -        if (method.getReturnType().equals(java.lang.Character.class)) {
  +    	Trc.entry(this,method,returnObj);
  +    	Object o = null;
  +    	Class rt = method.getReturnType();
  +    	Class ct = null;
  +    	int dims = 0;
  +    	if (rt.isArray()) {
  +    		ct = rt.getComponentType();
  +    		dims++;
  +        	while (ct.isArray()) {
  +        		ct = ct.getComponentType();
  +        		dims++;
  +        	}
  +    	}
  +        if (returnObj instanceof java.lang.Character) {
               o = getCompatibleObject(java.lang.String.class, returnObj);
  +        } else if (ct != null && (ct.equals(java.lang.Character.class) || ct.equals(char.class)))
{
  +        	String stringArrayClassName = "[Ljava.lang.String;";
  +        	for (int d=1; d<dims; d++) {
  +        		stringArrayClassName = "["+stringArrayClassName;
  +        	}
  +        	try {
  +        		Class stringArrayClass = Class.forName(stringArrayClassName, true, Thread.currentThread().getContextClassLoader());
  +        		o = getCompatibleObject(stringArrayClass, returnObj);
  +        	} catch(ClassNotFoundException cnf) {
  +        		Trc.ignoredException(cnf);
  +        		o = returnObj;
  +        	}
           } else {
               o = returnObj;
           }
  @@ -818,10 +842,13 @@
       //       this conversion may be needed on method args AND returns
       protected Object getCompatibleObject(Class cls, Object obj) {
           Trc.entry(this,cls,obj);
  +
  +    	if (cls.getName().equals(obj.getClass().getName())) return obj;
  +    	  	
           // String -> Character
           if ((cls.equals(java.lang.Character.class) || cls.equals(char.class))
               && obj.getClass().equals(java.lang.String.class)) {
  -            Character charArg = stringToCharacter((String) obj);
  +            Character charArg = ProviderUtils.stringToCharacter((String) obj);
               if (charArg == null) {
                   // Can't convert this string to character so return null
                   Trc.exit(null);
  @@ -830,6 +857,59 @@
               Trc.exit(charArg);
               return charArg;
           }
  +        
  +        // String arrays -> char/Character arrays and Character arrays -> String
arrays
  +        if (cls.isArray() && obj.getClass().isArray()) {
  +        	Class cct = cls.getComponentType();
  +        	Class objct = obj.getClass().getComponentType();
  +        	while (cct.isArray()) {
  +        		cct = cct.getComponentType();
  +        	}
  +        	while (objct.isArray()) {
  +        		objct = objct.getComponentType();
  +        	}         	
  +        	if (objct.equals(java.lang.String.class) && cct.equals(char.class)) {
  +        		try {
  +        			Object charArray = ProviderUtils.stringArrayToCharArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	} else if (objct.equals(java.lang.String.class) && cct.equals(java.lang.Character.class))
{
  +        		try {
  +        			Object charArray = ProviderUtils.stringArrayToCharacterArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	} else if (objct.equals(java.lang.Character.class) && cct.equals(java.lang.String.class))
{
  +        		try {
  +        			Object charArray = ProviderUtils.characterArrayToStringArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	} else if (objct.equals(char.class) && cct.equals(java.lang.String.class))
{
  +        		try {
  +        			Object charArray = ProviderUtils.charArrayToStringArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	}
  +        }
   
           if (cls.equals(java.lang.String.class)
               && obj.getClass().equals(java.lang.Character.class)) {
  @@ -841,40 +921,6 @@
           return obj;
       }
   
  -    protected Character stringToCharacter(String str) {
  -        if (str.length() != 1)
  -            return null;
  -        return new Character(str.charAt(0));
  -    }
  -
  -	protected Object getDefaultObject(Class cls) {
  -		if (cls == null) {
  -			return null;
  -		} else if (cls.isPrimitive()) {
  -			if (cls.getName().equals("int")) {
  -				return new Integer(0);
  -			} else if (cls.getName().equals("char")) {
  -				return new Character('0');
  -			} else if (cls.getName().equals("long")) {
  -				return new Long(0);
  -			} else if (cls.getName().equals("short")) {
  -				short s = 0;
  -				return new Short(s);
  -			} else if (cls.getName().equals("double")) {
  -				return new Double(0);
  -			} else if (cls.getName().equals("boolean")) {
  -				return new Boolean(false);
  -			} else if (cls.getName().equals("byte")) {
  -				byte b = 0;
  -				return new Byte(b);
  -			} else {
  -				return new Float(0);
  -			}
  -		} else {
  -			return null;
  -		}
  -	}
  -
       protected String getOutputMessageName() throws WSIFException {
           Trc.entry(this);
           if (fieldOutputMessageName == null) {
  @@ -1339,52 +1385,6 @@
   
           Trc.exit();
       }
  -
  -    /**
  -     * Creates a new input WSIFMessage. This overrides the 
  -     * WSIFDefaultOperation method to enable the use of 
  -     * compiled WSIFMessages by using a WSIFMessageFactory
  -     * to create the message.
  -     * 
  -     * @param name   the name of the message
  -     * @return a WSIFMessage instance
  -     * @see WSIFOperation#createInputMessage(String)
  -     */
  -    // defect 131672 and disable compiled msg support for now
  -    //    public WSIFMessage createInputMessage(String name) {
  -    //        Tr.entry(this, name);
  -    //        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  -    //        String ns = (d == null) ? "" : d.getTargetNamespace();
  -    //        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -    //        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -    //        if (msg != null)
  -    //            msg.setName(name);
  -    //        Tr.exit(msg);
  -    //        return msg;
  -    //    }
  -
  -    /**
  -     * Creates a new input WSIFMessage. This overrides the 
  -     * WSIFDefaultOperation method to enable the use of 
  -     * compiled WSIFMessages by using a WSIFMessageFactory
  -     * to create the message.
  -     * 
  -     * @param name   the name of the message
  -     * @return a WSIFMessage instance
  -     * @see WSIFOperation#createInputMessage(String)
  -     */
  -    // defect 131672 and disable compiled msg support for now
  -    //    public WSIFMessage createOutputMessage(String name) {
  -    //        Tr.entry(this, name);
  -    //        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  -    //        String ns = (d == null) ? "" : d.getTargetNamespace();
  -    //        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -    //        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -    //        if (msg != null)
  -    //            msg.setName(name);
  -    //        Tr.exit(msg);
  -    //        return msg;
  -    //    }
   
       public String deep() {
           String buff = "";
  
  
  
  1.25      +84 -88    xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
  
  Index: WSIFOperation_Java.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- WSIFOperation_Java.java	22 Nov 2002 15:56:36 -0000	1.24
  +++ WSIFOperation_Java.java	4 Dec 2002 17:27:01 -0000	1.25
  @@ -90,6 +90,7 @@
   import org.apache.wsif.base.WSIFServiceImpl;
   import org.apache.wsif.logging.MessageLogger;
   import org.apache.wsif.logging.Trc;
  +import org.apache.wsif.providers.ProviderUtils;
   import org.apache.wsif.wsdl.extensions.java.JavaOperation;
   
   /**
  @@ -751,7 +752,7 @@
           for (int i = 0; i < parmTypes.length; i++) {
               // If the arg is a null then skip it
               if (args[i] == null) {
  -                compatibleArgs[i] = getDefaultObject(parmTypes[i]);
  +                compatibleArgs[i] = ProviderUtils.getDefaultObject(parmTypes[i]);
                   continue;
               }
               // Consider the special cas, squeezing a String into a Character
  @@ -771,8 +772,31 @@
       protected Object getCompatibleReturn(Method method, Object returnObj) {
       	Trc.entry(this,method,returnObj);
       	Object o = null;
  -        if (method.getReturnType().equals(java.lang.Character.class)) {
  +    	Class rt = method.getReturnType();
  +    	Class ct = null;
  +    	int dims = 0;
  +    	if (rt.isArray()) {
  +    		ct = rt.getComponentType();
  +    		dims++;
  +        	while (ct.isArray()) {
  +        		ct = ct.getComponentType();
  +        		dims++;
  +        	}
  +    	}
  +        if (returnObj instanceof java.lang.Character) {
               o = getCompatibleObject(java.lang.String.class, returnObj);
  +        } else if (ct != null && (ct.equals(java.lang.Character.class) || ct.equals(char.class)))
{
  +        	String stringArrayClassName = "[Ljava.lang.String;";
  +        	for (int d=1; d<dims; d++) {
  +        		stringArrayClassName = "["+stringArrayClassName;
  +        	}
  +        	try {
  +        		Class stringArrayClass = Class.forName(stringArrayClassName, true, Thread.currentThread().getContextClassLoader());
  +        		o = getCompatibleObject(stringArrayClass, returnObj);
  +        	} catch(ClassNotFoundException cnf) {
  +        		Trc.ignoredException(cnf);
  +        		o = returnObj;
  +        	}
           } else {
               o = returnObj;
           }
  @@ -791,10 +815,13 @@
       //       this conversion may be needed on method args AND returns
       protected Object getCompatibleObject(Class cls, Object obj) {
       	Trc.entry(this,cls,obj);
  +    	
  +    	if (cls.getName().equals(obj.getClass().getName())) return obj;
  +    	  	
           // String -> Character
           if ((cls.equals(java.lang.Character.class) || cls.equals(char.class))
               && obj.getClass().equals(java.lang.String.class)) {
  -            Character charArg = stringToCharacter((String) obj);
  +            Character charArg = ProviderUtils.stringToCharacter((String) obj);
               if (charArg == null) {
                   // Can't convert this string to character so return null
                   Trc.exit(null);
  @@ -803,7 +830,60 @@
               Trc.exit(charArg);
               return charArg;
           }
  -
  +        
  +        // String arrays -> char/Character arrays and Character arrays -> String
arrays
  +        if (cls.isArray() && obj.getClass().isArray()) {
  +        	Class cct = cls.getComponentType();
  +        	Class objct = obj.getClass().getComponentType();
  +        	while (cct.isArray()) {
  +        		cct = cct.getComponentType();
  +        	}
  +        	while (objct.isArray()) {
  +        		objct = objct.getComponentType();
  +        	}         	
  +        	if (objct.equals(java.lang.String.class) && cct.equals(char.class)) {
  +        		try {
  +        			Object charArray = ProviderUtils.stringArrayToCharArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	} else if (objct.equals(java.lang.String.class) && cct.equals(java.lang.Character.class))
{
  +        		try {
  +        			Object charArray = ProviderUtils.stringArrayToCharacterArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	} else if (objct.equals(java.lang.Character.class) && cct.equals(java.lang.String.class))
{
  +        		try {
  +        			Object charArray = ProviderUtils.characterArrayToStringArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	} else if (objct.equals(char.class) && cct.equals(java.lang.String.class))
{
  +        		try {
  +        			Object charArray = ProviderUtils.charArrayToStringArray(obj);
  +        			Trc.exit(charArray);
  +        			return charArray;
  +        		} catch (Exception e) {
  +        			Trc.ignoredException(e);
  +            		Trc.exit(null);
  +            		return null;
  +        		}
  +        	}
  +        }
  +        
           if (cls.equals(java.lang.String.class)
               && obj.getClass().equals(java.lang.Character.class)) {
               Trc.exit(obj.toString());
  @@ -813,40 +893,6 @@
           return obj;
       }
   
  -    protected Character stringToCharacter(String str) {
  -        if (str.length() != 1)
  -            return null;
  -        return new Character(str.charAt(0));
  -    }
  -
  -	protected Object getDefaultObject(Class cls) {
  -		if (cls == null) {
  -			return null;
  -		} else if (cls.isPrimitive()) {
  -			if (cls.getName().equals("int")) {
  -				return new Integer(0);
  -			} else if (cls.getName().equals("char")) {
  -				return new Character('0');
  -			} else if (cls.getName().equals("long")) {
  -				return new Long(0);
  -			} else if (cls.getName().equals("short")) {
  -				short s = 0;
  -				return new Short(s);
  -			} else if (cls.getName().equals("double")) {
  -				return new Double(0);
  -			} else if (cls.getName().equals("boolean")) {
  -				return new Boolean(false);
  -			} else if (cls.getName().equals("byte")) {
  -				byte b = 0;
  -				return new Byte(b);
  -			} else {
  -				return new Float(0);
  -			}
  -		} else {
  -			return null;
  -		}
  -	}
  -
       protected String getOutputMessageName() throws WSIFException {
       	Trc.entry(this);
           if (fieldOutputMessageName == null) {
  @@ -1360,56 +1406,6 @@
   
           Trc.exit();
       }
  -
  -//    /**
  -//     * Creates a new input WSIFMessage. This overrides the 
  -//     * WSIFDefaultOperation method to enable the use of 
  -//     * compiled WSIFMessages by using a WSIFMessageFactory
  -//     * to create the message.
  -//     * 
  -//     * @param name   the name of the message
  -//     * @return a WSIFMessage instance
  -//     * @see WSIFOperation#createInputMessage(String)
  -//     */
  -// defect 131672 and disable compiled msg support for now
  -//    public WSIFMessage createInputMessage(String name) {
  -//        Tr.entry(this, name);
  -//
  -//        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  -//        String ns = (d == null) ? "" : d.getTargetNamespace();
  -//        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -//        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -//        if (msg != null)
  -//            msg.setName(name);
  -//
  -//        Tr.exit(msg);
  -//        return msg;
  -//    }
  -//
  -//    /**
  -//     * Creates a new output WSIFMessage. This overrides the 
  -//     * WSIFDefaultOperation method to enable the use of 
  -//     * compiled WSIFMessages by using a WSIFMessageFactory
  -//     * to create the message.
  -//     * 
  -//     * @param name   the name of the message
  -//     * @return a WSIFMessage instance
  -//     * @see WSIFOperation#createInputMessage(String)
  -//     */
  -// defect 131672 and disable compiled msg support for now
  -//    public WSIFMessage createOutputMessage(String name) {
  -//        Tr.entry(this, name);
  -//
  -//        Definition d = (fieldPort == null) ? null : fieldPort.getDefinition();
  -//        String ns = (d == null) ? "" : d.getTargetNamespace();
  -//        WSIFMessageFactory mf = WSIFServiceImpl.getMessageFactory();
  -//        WSIFMessage msg = mf.createMessage(ns, name + "Message");
  -//        if (msg != null)
  -//            msg.setName(name);
  -//
  -//        Tr.exit(msg);
  -//        return msg;
  -//    }
   
       public String deep() {
           String buff = "";
  
  
  

Mime
View raw message