use of act.event.SysEventListenerBase 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);
}
});
}
}
use of act.event.SysEventListenerBase in project actframework by actframework.
the class SubTypeFinder method applyTo.
@Override
public final void applyTo(final App app) {
app.eventBus().bind(bindingEvent, new SysEventListenerBase() {
@Override
public void on(EventObject event) throws Exception {
ClassInfoRepository repo = app.classLoader().classInfoRepository();
ClassNode parent = repo.node(targetType.getName());
parent.visitPublicNotAbstractTreeNodes(new $.Visitor<ClassNode>() {
@Override
public void visit(ClassNode classNode) throws $.Break {
final Class<T> c = $.classForName(classNode.name(), app.classLoader());
found(c, app);
}
});
}
});
}
use of act.event.SysEventListenerBase in project actframework by actframework.
the class Job method run.
@Override
public void run() {
invokeParallelJobs();
runPrecedenceJobs();
try {
if (Act.isDev() && app.isStarted()) {
app.checkUpdates(false);
}
doJob();
} catch (Throwable e) {
boolean isFatal = FATAL_EXCEPTIONS.contains(e.getClass());
Throwable cause = e;
if (!isFatal) {
cause = e.getCause();
while (null != cause) {
isFatal = FATAL_EXCEPTIONS.contains(cause.getClass());
if (isFatal) {
break;
}
cause = cause.getCause();
}
}
if (isFatal) {
if (Act.isDev()) {
app.setBlockIssue(e);
} else {
Act.shutdown(App.instance());
destroy();
if (App.instance().isMainThread()) {
if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
}
throw E.unexpected(e);
} else {
logger.fatal(cause, "Fatal error executing job %s", id());
}
}
return;
}
// TODO inject Job Exception Handling mechanism here
logger.warn(e, "error executing job %s", id());
} finally {
if (!isDestroyed()) {
executed = true;
if (isOneTime()) {
App app = App.instance();
if (app.isStarted()) {
manager.removeJob(this);
} else {
app.eventBus().bind(SysEventId.POST_START, new SysEventListenerBase() {
@Override
public void on(EventObject event) throws Exception {
manager.removeJob(Job.this);
}
});
}
}
progress.destroy();
}
}
runFollowingJobs();
}
Aggregations