}
private void installScheduler(DeploymentPhaseContext phaseContext, boolean singleton) {
DeploymentUnit unit = phaseContext.getDeploymentUnit();
ServiceName serviceName = JobsServices.scheduler(unit, singleton);
JobSchedulerMetaData schedulerMetaData = unit.getAttachment(JobSchedulerMetaData.ATTACHMENT_KEY);
if (schedulerMetaData == null) {
// It seems that there are no jobs defined at the deployment time
// (in deployment descriptors) or no jobs subsystem configuration
// is provided, let's create a default one.
log.debug("No jobs subsystem configuration is found, using defaults");
schedulerMetaData = new JobSchedulerMetaData();
unit.putAttachment(JobSchedulerMetaData.ATTACHMENT_KEY, schedulerMetaData);
}
log.debugf("Setting job scheduler concurrency to %s", schedulerMetaData.getThreadCount());
JobScheduler scheduler = new JobScheduler(serviceName.getCanonicalName(), schedulerMetaData.getThreadCount());
ServiceBuilder<BaseJobScheduler> builder = phaseContext.getServiceTarget().addService(serviceName, scheduler);
// Add dependency to the jobs pool
builder.addDependency(CoreServices.runtimePoolName(unit, "jobs"), RubyRuntimePool.class, scheduler.getRubyRuntimePoolInjector());