@ SuppressWarnings ( "unchecked" ) private T createInstance ( final String className , final Object ... arguments ) { try { Class < ? > implementation = Class . forName ( className , false , classLoader ) ; if ( service . isAssignableFrom ( implementation ) ) { return ( T ) implementation . getDeclaredConstructor ( argumentTypes ) . newInstance ( arguments ) ; } else { InternalLogger . log ( Level . ERROR , "Class '" + className + "' does not implement servcie interface '" + service + "'" ) ; } } catch ( ClassNotFoundException ex ) { InternalLogger . log ( Level . ERROR , "Service implementation '" + className + "' not found" ) ; } catch ( NoSuchMethodException ex ) { InternalLogger . log ( Level . ERROR , "Service implementation '" + className + "' has no matching constructor" ) ; } catch ( InstantiationException ex ) { InternalLogger . log ( Level . ERROR , "Service implementation '" + className + "' is not instantiable" ) ; } catch ( IllegalAccessException ex ) { InternalLogger . log ( Level . ERROR , "Constructor of service implementation '" + className + "' is not accessible" ) ; } catch ( IllegalArgumentException ex ) { InternalLogger . log ( Level . ERROR , "Illegal arguments for constructor of service implementation '" + className + "'" ) ; } catch ( InvocationTargetException ex ) { InternalLogger . log ( Level . ERROR , ex . getTargetException ( ) , "Failed creating service implementation '" + className + "'" ) ; } return null ; }
Creates a new instance of a class .