/*
 * Copyright 2017-2018 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.core.internal.validation;

import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import com.b2international.snowowl.core.IDisposableService;
import com.b2international.snowowl.core.events.util.Promise;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;

/**
 * @since 6.0
 */
public final class ValidationThreadPool implements IDisposableService {

	private final AtomicBoolean disposed = new AtomicBoolean(false);
	private final ListeningExecutorService executor;
	
	public ValidationThreadPool(int nThreads) {
		this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(nThreads));
	}
	
	@Override
	public boolean isDisposed() {
		return disposed.get();
	}
	
	@Override
	public void dispose() {
		if (disposed.compareAndSet(false, true)) {
			MoreExecutors.shutdownAndAwaitTermination(executor, 1, TimeUnit.MINUTES);
		}
	}
	
	public Promise<Boolean> submit(Callable<Boolean> callable) {
		return Promise.wrap(executor.submit(callable));
	}
	
}

@@ -695,164 +695,91 @@
 ort 
-java.util.concurrent.Callable;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.concurrent.atomic.AtomicBoolean
+org.eclipse.core.internal.jobs.JobManager;%0Aimport org.eclipse.core.runtime.jobs.Job
 ;%0A%0Ai
@@ -817,33 +817,34 @@
 wl.core.
-IDisposableServic
+events.util.Promis
 e;%0Aimpor
@@ -882,856 +882,641 @@
 ore.
-events.util.Promise;%0Aimport com.google.common.util.concurrent.ListeningExecutorService;%0Aimport com.google.common.util.concurrent.MoreExecutors;%0A%0A/**%0A * @since 6.0%0A */%0Apublic final class ValidationThreadPool implements IDisposableService %7B%0A%0A%09private final AtomicBoolean disposed = new AtomicBoolean(false);%0A%09private final ListeningExecutorService executor;%0A%09%0A%09public ValidationThreadPool(int nThreads) %7B%0A%09%09this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(nThreads));%0A%09%7D%0A%09%0A%09@Override%0A%09public boolean isDisposed() %7B%0A%09%09return disposed.get();%0A%09%7D%0A%09%0A%09@Override%0A%09public void dispose() %7B%0A%09%09if (disposed.compareAndSet(false, true)) %7B%0A%09%09%09MoreExecutors.shutdownAndAwaitTermination(executor, 1, TimeUnit.MINUTES);%0A%09%09%7D%0A%09%7D%0A%09%0A%09public Promise%3CBoolean%3E submit(Callable%3CBoolean%3E callable) %7B%0A%09%09return Promise.wrap(executor.submit(callable)
+validation.rule.ValidationRule.CheckType;%0A%0A/**%0A * @since 6.0%0A */%0Apublic final class ValidationThreadPool %7B%0A%0A%09public ValidationThreadPool(int nThreads) %7B%0A%09%7D%0A%09%0A%09public Promise%3CBoolean%3E submit(CheckType checkType, Runnable runnable) %7B%0A%09%09final ValidationJob job = new ValidationJob(checkType.getName(), runnable);%0A%09%09final ValidationRuleSchedulingRule schedulingRule = new ValidationRuleSchedulingRule(checkType);%0A%09%09job.setSystem(true);%0A%09%09job.setRule(schedulingRule);%0A%09%09job.schedule();%0A%09%09final JobManager manager = (JobManager) Job.getJobManager();%0A%09%09Job%5B%5D find = manager.find(checkType.getName());%0A%09%09return Promise.immediate(Boolean.TRUE
 );%0A%09

Refactor ValidationThreadPool to use the Job API instead of ...