use of org.xwiki.extension.distribution.internal.job.DefaultDistributionJob in project xwiki-platform by xwiki.
the class DefaultDistributionManager method startFarmJob.
@Override
public DefaultDistributionJob startFarmJob() {
try {
this.farmDistributionJob = this.componentManager.getInstance(Job.class, DefaultDistributionJob.HINT);
XWikiContext xcontext = this.xcontextProvider.get();
final DistributionRequest request = new DistributionRequest();
request.setId(getFarmJobId());
request.setWiki(xcontext.getMainXWiki());
request.setUserReference(xcontext.getUserReference());
request.setInteractive(this.configuration.getProperty("distribution.job.interactive", true));
Thread distributionJobThread = new Thread(new Runnable() {
@Override
public void run() {
// Create a clean Execution Context
ExecutionContext context = new ExecutionContext();
try {
executionContextManager.initialize(context);
} catch (ExecutionContextException e) {
throw new RuntimeException("Failed to initialize farm distribution job execution context", e);
}
farmDistributionJob.initialize(request);
farmDistributionJob.run();
}
});
distributionJobThread.setDaemon(true);
distributionJobThread.setName("Farm distribution initialization");
distributionJobThread.start();
// Wait until the job is ready (or finished)
this.farmDistributionJob.awaitReady();
return this.farmDistributionJob;
} catch (Exception e) {
this.logger.error("Failed to create farm distribution job", e);
}
return null;
}
Aggregations