public final class MethodFactory implements ObjectFactory
{
public Object instantiate(ObjectBinder context, Object value, Type targetType, Class targetClass)
{
TimeCollector timeCollector= ServiceLocator.getInstance().getTimeCollector();
timeCollector.registerStart("instantiate method");
String methodSignature= (String) value;
String className= methodSignature.substring(0, methodSignature.lastIndexOf("."));
String methodName= methodSignature.substring(methodSignature.lastIndexOf(".") + 1, methodSignature.lastIndexOf(":"));
int parametersCount= Integer.parseInt(methodSignature.substring(methodSignature.lastIndexOf(":") + 1));
try
{
Method[] methods= Class.forName(className).getMethods();
for (Method method : methods)
{
if (method.getName().equals(methodName) && method.getParameterTypes().length == parametersCount)
return method;
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
timeCollector.registerEnd();
}
return null;
}