Search in sources :

Example 1 with SimpleEventListenerMetaInfo

use of act.event.meta.SimpleEventListenerMetaInfo in project actframework by actframework.

the class SimpleEventListenerByteCodeScanner method scanFinished.

@Override
public void scanFinished(String className) {
    if (!metaInfoList.isEmpty()) {
        final EventBus eventBus = app().eventBus();
        JobManager jobManager = app().jobManager();
        for (final SimpleEventListenerMetaInfo metaInfo : metaInfoList) {
            SysEventId hookOn = metaInfo.beforeAppStart() ? SysEventId.DEPENDENCY_INJECTOR_PROVISIONED : SysEventId.PRE_START;
            jobManager.on(hookOn, new Runnable() {

                @Override
                public void run() {
                    for (final Object event : metaInfo.events()) {
                        final boolean isStatic = metaInfo.isStatic();
                        eventBus.bind(event, new ReflectedSimpleEventListener(metaInfo.className(), metaInfo.methodName(), metaInfo.paramTypes(), isStatic));
                    }
                }
            });
        }
    }
}
Also used : SysEventId(act.app.event.SysEventId) JobManager(act.job.JobManager) SimpleEventListenerMetaInfo(act.event.meta.SimpleEventListenerMetaInfo)

Aggregations

SysEventId (act.app.event.SysEventId)1 SimpleEventListenerMetaInfo (act.event.meta.SimpleEventListenerMetaInfo)1 JobManager (act.job.JobManager)1