lcsim/src/org/lcsim/job
diff -u -r1.39 -r1.40
--- JobControlManager.java 18 May 2010 21:04:48 -0000 1.39
+++ JobControlManager.java 21 May 2010 17:44:48 -0000 1.40
@@ -871,17 +871,48 @@
}
propertyType = setter.getParameterTypes()[0];
}
- // No method found. Parameter name is probably wrong.
- else if (methodCandidates.size() == 0)
- {
- throw new RuntimeException("No set method found for parameter: " + pname);
- }
- // Overloaded method. Don't bother trying to disambiguate. Just throw an error.
+ // Overloaded method. Try to disambiguate.
else if (methodCandidates.size() > 1)
{
- throw new RuntimeException("Multiple set methods found for parameter: " + pname);
- }
+ if (parameterElement.getAttribute("type") == null)
+ throw new RuntimeException("Parameter " + pname + " in Driver " + driverClass.getCanonicalName()
+ + " is overloaded, but a type field is missing from the parameter's XML element.");
+ try
+ {
+ // Try a primitive type first.
+ propertyType = getPrimitiveType(parameterElement.getAttribute("type").getValue());
+
+ // If type is null, then parameter is an Object and not a primitive, or it is not a valid type.
+ if (propertyType == null)
+ propertyType = Class.forName(parameterElement.getAttribute("type").getValue());
+ }
+ catch (ClassNotFoundException x)
+ {
+ throw new RuntimeException("Bad user type " + parameterElement.getAttribute("type").getValue() + " for parameter " + pname + ".");
+ }
+ // Find a method that matches the user type.
+ for (Method candidateMethod : methodCandidates)
+ {
+ if (candidateMethod.getParameterTypes().length == 1 &&
+ candidateMethod.getParameterTypes()[0].equals(propertyType))
+ {
+ setter = candidateMethod;
+ break;
+ }
+ }
+ }
+ // No method found. Parameter name is probably wrong.
+ else if (methodCandidates.size() == 0)
+ {
+ throw new RuntimeException("No set method found for parameter: " + pname);
+ }
+
+ // Need to check if ultimately found a valid set method.
+ if (setter == null)
+ throw new RuntimeException("Unable to find set method for parameter: " + pname);
+
+ // Convert the parameter to the appropriate type.
IParameterConverter converter = paramConverter.getConverterForType(propertyType);
if (converter == null)
{