}
for (final Class clzz : ctClasses) {
if (clzz.getAnnotation(Singleton.class) != null) {
logger.info("load service with @Singleton => " + clzz.getName());
moduleList.add(new AbstractModule() {
@Override
protected void configure() {
bind(clzz).in(Scopes.SINGLETON);
}
});
continue;
}
final Service service = (Service) clzz.getAnnotation(Service.class);
if (service == null) continue;
if (clzz.isInterface() && service.implementedBy() == null)
throw new AnnotationException(format("{} no implemented class configured", clzz.getName()));
moduleList.add(new AbstractModule() {
@Override
protected void configure() {
if (clzz.isInterface()) {
logger.info("load service with @Service => " + clzz.getName() + " to " + service.implementedBy().getName() + " in " + service.value().getName());
bind(clzz).to(service.implementedBy()).in(service.value());
} else {
logger.info("load service with @Service => " + clzz.getName() + " in " + service.value().getName());
bind(clzz).in(service.value());
}
}
});
}
for (final Map.Entry<String, String> entry : settings.getByPrefix("application.dynamic.implemented.singleton").getAsMap().entrySet()) {
moduleList.add(new AbstractModule() {
@Override
protected void configure() {
try {
Class clzz = Class.forName(entry.getValue());
bind(Class.forName(entry.getKey())).to(clzz).in(Scopes.SINGLETON);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
});
}
for (final Map.Entry<String, String> entry : settings.getByPrefix("application.dynamic.implemented.prototype").getAsMap().entrySet()) {
moduleList.add(new AbstractModule() {
@Override
protected void configure() {
try {
Class clzz = Class.forName(entry.getValue());
bind(Class.forName(entry.getKey())).to(clzz).in(Scopes.NO_SCOPE);