如何在doPost方法中生成新作业?

时间:2017-06-09 20:34:42

标签: java cq5 aem

我无法将请求对象添加到传递给JobManager的地图中,以生成由匹配的JobConsumer执行的新Job。 JobManager的值为null(问题)。有人可以帮我解决出错的问题吗?

到目前为止我尝试过的,

import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.event.jobs.JobManager;
import org.gs4tr.aem.event.JobConsumerConstraints;

@Component
public class CreateSubmissionTaskHandler extends BaseSubmissionTaskHandler {

    private static final Log _logger = LogFactory.getLog(CreateSubmissionTaskHandler.class);

    @Reference
    private JobManager _jobManager;

    private JobManager getJobManager() {
        return _jobManager;
    }

    public String doPost(SlingHttpServletRequest request) {

        Map<String, Object> props = new HashMap<String, Object>();

        props.put("request", request);

        getJobManager().addJob(
            JobConsumerConstraints.SEND_SUBMISSION_DIALOG_JOB_CONSUMER, props);

        return null;

  }

    @Override
    protected Log getLogger() {
        return _logger;
    }
}

0 个答案:

没有答案