}
private void createSchedulable() {
if (mSchedulableClass == null)
{
throw new InvalidParameterException("Schedulable Class not set");
}
if (mSchedulableArgumentList.length != mSchedulableArgumentTypeList.length)
{
throw new InvalidParameterException(
"Schedulable Class Arguments and Types do not match in length"
);
}
// Create all the Objects for the Constructor to be called
Object[] lArgumentList = new Object[mSchedulableArgumentTypeList.length];
try
{
for (int i = 0; i < mSchedulableArgumentTypeList.length; i++)
{
Class lClass = mSchedulableArgumentTypeList[i];
if (lClass == Boolean.TYPE)
{
lArgumentList[i] = new Boolean(mSchedulableArgumentList[i]);
}
else if (lClass == Integer.TYPE)
{
lArgumentList[i] = new Integer(mSchedulableArgumentList[i]);
}
else if (lClass == Long.TYPE)
{
lArgumentList[i] = new Long(mSchedulableArgumentList[i]);
}
else if (lClass == Short.TYPE)
{
lArgumentList[i] = new Short(mSchedulableArgumentList[i]);
}
else if (lClass == Float.TYPE)
{
lArgumentList[i] = new Float(mSchedulableArgumentList[i]);
}
else if (lClass == Double.TYPE)
{
lArgumentList[i] = new Double(mSchedulableArgumentList[i]);
}
else if (lClass == Byte.TYPE)
{
lArgumentList[i] = new Byte(mSchedulableArgumentList[i]);
}
else if (lClass == Character.TYPE)
{
lArgumentList[i] = new Character(mSchedulableArgumentList[i].charAt(0));
}
else
{
Constructor lConstructor = lClass.getConstructor(new Class[]{String.class});
lArgumentList[i] = lConstructor.newInstance(new Object[]{mSchedulableArgumentList[i]});
}
}
}
catch (Exception e)
{
log.error("Could not load or create constructor argument", e);
throw new InvalidParameterException("Could not load or create a constructor argument");
}
try
{
// Check if constructor is found
Constructor lSchedulableConstructor = mSchedulableClass.getConstructor(mSchedulableArgumentTypeList);
// Create an instance of it
mSchedulable = (Schedulable) lSchedulableConstructor.newInstance(lArgumentList);
}
catch (Exception e)
{
log.error("Could not find the constructor or create Schedulable instance", e);
throw new InvalidParameterException("Could not find the constructor or create the Schedulable Instance");
}
}