use of act.job.JobManager in project actframework by actframework.
the class ReflectedCommandExecutor method execute.
@Override
public Object execute(CliContext context) {
context.handlerMethod(method);
if (null != dateFormatPattern) {
context.dateFormatPattern(dateFormatPattern);
}
context.fastjsonFeatures(features);
context.fastjsonFilters(filters);
context.prepare(parsingContext);
paramLoaderService.preParseOptions(method, methodMetaInfo, context);
final Object cmd = commanderInstance(context);
final Object[] params = params(cmd, context);
if (async) {
JobManager jobManager = context.app().jobManager();
String jobId = jobManager.prepare(new TrackableWorker() {
@Override
protected void run(ProgressGauge progressGauge) {
invoke(cmd, params);
}
});
context.setJobId(jobId);
jobManager.now(jobId);
if (null != reportProgress) {
context.attribute(ReportProgress.CTX_ATTR_KEY, reportProgress);
return context.progress();
} else {
return "Async job started: " + jobId;
}
}
return invoke(cmd, params);
}
use of act.job.JobManager 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));
}
}
});
}
}
}
Aggregations