public static final <T> T instantiate(String clazzname, Object... constructorArgs) { try { Class clazz = Class.forName(clazzname); Constructor constructor = clazz.getConstructor(Configuration.class); T instance = (T) constructor.newInstance(constructorArgs); return instance; } catch (ClassNotFoundException e) { throw new IllegalArgumentException("Could not find implementation class: " + clazzname); } catch (NoSuchMethodException e) { throw new IllegalArgumentException( "Configured backend implementation does not have required constructor: " + clazzname); } catch (InstantiationException e) { throw new IllegalArgumentException("Could not instantiate implementation: " + clazzname, e); } catch (IllegalAccessException e) { throw new IllegalArgumentException("Could not instantiate implementation: " + clazzname, e); } catch (InvocationTargetException e) { throw new IllegalArgumentException("Could not instantiate implementation: " + clazzname, e); } catch (ClassCastException e) { throw new IllegalArgumentException("Could not instantiate implementation: " + clazzname, e); } }