openamf/src/java/org/openamf/invoker JavaServiceInvoker.java,1.6,1.7

[email protected]
Newsgroups gmane.comp.java.openamf.cvs
Message-ID <[email protected]>
Update of /cvsroot/openamf/openamf/src/java/org/openamf/invoker
In directory sc8-pr-cvs1:/tmp/cvs-serv23963/src/java/org/openamf/invoker

Modified Files:
	JavaServiceInvoker.java 
Log Message:
fixed bug in convertHashMapToBean

Index: JavaServiceInvoker.java
===================================================================
RCS file: /cvsroot/openamf/openamf/src/java/org/openamf/invoker/JavaServiceInvoker.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** JavaServiceInvoker.java	26 Apr 2003 17:02:41 -0000	1.6
--- JavaServiceInvoker.java	28 Apr 2003 06:00:22 -0000	1.7
***************
*** 22,26 ****
  		ServiceRequest request,
  		ServletContext servletContex) {
! 			
  		super(request, servletContex);
  	}
--- 22,26 ----
  		ServiceRequest request,
  		ServletContext servletContex) {
! 
  		super(request, servletContex);
  	}
***************
*** 176,206 ****
  		Object bean = beanClass.newInstance();
  
! 		PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(beanClass);
  		for (int i = 0; i < properties.length; i++) {
  			if (!properties[i].getName().equals("class")) {
  				String propertyName = properties[i].getName();
  				Method writeMethod = properties[i].getWriteMethod();
! 				Class[] parameterTypes = writeMethod.getParameterTypes();
! 				if (parameterTypes.length == 1) {
! 					Object value = data.get(propertyName);
! 					log.debug(
! 						"propertyName = "
! 							+ propertyName
! 							+ ", value = "
! 							+ value);
! 					Class parameterType = parameterTypes[0];
! 					if (!parameterType.isInstance(value)) {
! 						//try to convert types
! 						log.debug("types don't match, try to convert");
! 						log.debug("parameterType = " + parameterType);
! 						if (parameterType.equals(Integer.TYPE)
! 							&& value instanceof Double) {
! 							log.debug("Converting Double to Integer");
! 							value = new Integer(((Double) value).intValue());
  						}
  					}
- 					writeMethod.invoke(bean, new Object[] { value });
- 				} else {
- 					throw new IllegalArgumentException("write method has more than one parameter");
  				}
  
--- 176,212 ----
  		Object bean = beanClass.newInstance();
  
! 		PropertyDescriptor[] properties =
! 			PropertyUtils.getPropertyDescriptors(beanClass);
  		for (int i = 0; i < properties.length; i++) {
  			if (!properties[i].getName().equals("class")) {
  				String propertyName = properties[i].getName();
+ 				log.debug("propertyName: " + propertyName);
  				Method writeMethod = properties[i].getWriteMethod();
! 				log.debug("writeMethod: " + writeMethod);
! 				if (writeMethod != null) {
! 					Class[] parameterTypes = writeMethod.getParameterTypes();
! 					if (parameterTypes.length == 1) {
! 						Object value = data.get(propertyName);
! 						log.debug(
! 							"propertyName = "
! 								+ propertyName
! 								+ ", value = "
! 								+ value);
! 						Class parameterType = parameterTypes[0];
! 						if (!parameterType.isInstance(value)) {
! 							//try to convert types
! 							log.debug("types don't match, try to convert");
! 							log.debug("parameterType = " + parameterType);
! 							if (parameterType.equals(Integer.TYPE)
! 								&& value instanceof Double) {
! 								log.debug("Converting Double to Integer");
! 								value =
! 									new Integer(((Double) value).intValue());
! 							}
  						}
+ 						writeMethod.invoke(bean, new Object[] { value });
+ 					} else {
+ 						throw new IllegalArgumentException("write method has more than one parameter");
  					}
  				}
  




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.