public static Object materializeJob(final Job job, final Map<String, Class<?>> jobTypes)
throws UnpermittedJobException, Exception {
final String className = job.getClassName();
final Class<?> clazz = jobTypes.get(className);
if (clazz == null) {
throw new UnpermittedJobException(className);
}
// A bit redundant since we check when the job type is added...
if (!Runnable.class.isAssignableFrom(clazz) && !Callable.class.isAssignableFrom(clazz)) {
throw new ClassCastException("jobs must be a Runnable or a Callable: " + clazz.getName() + " - " + job);
}