/** * Create a new instance of the found Service. <br> * Verifies that the found ServiceImpl implements Service. * * @param <T> * @param serviceType The Service interface * @param className The name of the implementation class * @param loader The ClassLoader to load the ServiceImpl from * @return A new instance of the ServiceImpl * @throws Exception If problems creating a new instance */ private <T> T createInstance(Class<? extends T> serviceImplClass) { try { Constructor<? extends T> constructor = SecurityActions.getConstructor(serviceImplClass); if (!constructor.isAccessible()) { constructor.setAccessible(true); } return constructor.newInstance(); } catch (Exception e) { throw new RuntimeException( "Could not create a new instance of Service implementation " + serviceImplClass.getName(), e); } }