All Downloads are FREE. Search and download functionalities are using the official Maven repository.

play.inject.DefaultBeanSource Maven / Gradle / Ivy

There is a newer version: 2.6.2
Show newest version
package play.inject;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class DefaultBeanSource implements BeanSource {
  @Override
  public  T getBeanOfType(Class clazz) {
    try {
      Constructor constructor = clazz.getDeclaredConstructor();
      constructor.setAccessible(true);
      return constructor.newInstance();
    } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
      throw new RuntimeException("Cannot instantiate " + clazz, e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy