You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by mc...@apache.org on 2008/04/15 15:40:29 UTC

svn commit: r648251 - /incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java

Author: mcombellack
Date: Tue Apr 15 06:40:28 2008
New Revision: 648251

URL: http://svn.apache.org/viewvc?rev=648251&view=rev
Log:
TUSCANY-2228 When an attempt to inject an invalid value into a property is made, the exception that is thrown now contains the name of the Proerty in Exception message to aid in diagnosing the problem

Modified:
    incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java

Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java?rev=648251&r1=648250&r2=648251&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java Tue Apr 15 06:40:28 2008
@@ -220,7 +220,15 @@
         @SuppressWarnings("unchecked")
         public Object getInstance() throws ObjectCreationException {
             if (isSimpleType) {
-                return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+                try {
+                    return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+                } catch (NumberFormatException ex) {
+                    throw new ObjectCreationException("Failed to create instance for property " 
+                            + property.getName() + " with value " + propertyValue, ex);
+                } catch (IllegalArgumentException ex) {
+                    throw new ObjectCreationException("Failed to create instance for property " 
+                            + property.getName() + " with value " + propertyValue, ex);
+                }
             } else {
                 return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
                 // return null;
@@ -238,7 +246,17 @@
             if (isSimpleType) {
                 List<Object> values = new ArrayList<Object>();
                 for (String aValue : (List<String>)propertyValue) {
-                    values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                    try {
+                        values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                    } catch (NumberFormatException ex) {
+                        throw new ObjectCreationException("Failed to create instance for property " 
+                                + property.getName() + " with value " + aValue 
+                                + " from value list of " + propertyValue, ex);
+                    } catch (IllegalArgumentException ex) {
+                        throw new ObjectCreationException("Failed to create instance for property " 
+                                + property.getName() + " with value " + aValue 
+                                + " from value list of " + propertyValue, ex);
+                    }
                 }
                 return values;
             } else {
@@ -262,7 +280,17 @@
                 int count = 0;
                 Object values = Array.newInstance(javaType, ((List<Object>)propertyValue).size());
                 for (String aValue : (List<String>)propertyValue) {
-                    Array.set(values, count++, simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                    try {
+                        Array.set(values, count++, simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                    } catch (NumberFormatException ex) {
+                        throw new ObjectCreationException("Failed to create instance for property " 
+                                + property.getName() + " with value " + aValue
+                                + " from value list of " + propertyValue, ex);
+                    } catch (IllegalArgumentException ex) {
+                        throw new ObjectCreationException("Failed to create instance for property " 
+                                + property.getName() + " with value " + aValue
+                                + " from value list of " + propertyValue, ex);
+                    }
                 }
                 return values;
             } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org