Search in sources :

Example 1 with ProgressGauge

use of act.util.ProgressGauge 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);
}
Also used : TrackableWorker(act.job.TrackableWorker) ProgressGauge(act.util.ProgressGauge) JobManager(act.job.JobManager)

Aggregations

JobManager (act.job.JobManager)1 TrackableWorker (act.job.TrackableWorker)1 ProgressGauge (act.util.ProgressGauge)1