use of act.db.DbService in project act-ebean by actframework.
the class EbeanDao method getService.
private EbeanService getService(String dbId, DbServiceManager mgr) {
DbService svc = mgr.dbService(dbId);
E.invalidConfigurationIf(null == svc, "Cannot find db service by id: %s", dbId);
E.invalidConfigurationIf(!(svc instanceof EbeanService), "The db service[%s|%s] is not ebean service", dbId, svc.getClass());
return $.cast(svc);
}
use of act.db.DbService in project act-ebean by actframework.
the class EbeanDaoInjectionListener method onInjection.
@Override
public void onInjection(Object injectee, BeanSpec spec) {
final EbeanDao dao = $.cast(injectee);
if (dao.ebeanServerProvided()) {
return;
}
List<Type> typeParameters = spec.typeParams();
if (typeParameters.isEmpty()) {
typeParameters = Generics.typeParamImplementations(spec.rawType(), EbeanDao.class);
}
if (null == typeParameters) {
logger.warn("No type parameter information provided");
return;
}
final $.T2<Class, String> resolved = resolve(typeParameters);
DbService dbService = App.instance().dbServiceManager().dbService(resolved._2);
if (dbService instanceof EbeanService) {
final EbeanService service = $.cast(dbService);
Act.eventBus().bind(SysEventId.DB_SVC_LOADED, new SysEventListenerBase() {
@Override
public void on(EventObject eventObject) throws Exception {
dao.ebean(service.ebean());
dao.modelType(resolved._1);
}
});
}
}
Aggregations