Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-12-02 21:18:50 +0000
committerAngel Avila2014-12-02 21:18:50 +0000
commit9f47598b91f745f1581db5c5d104f496fc9a340f (patch)
treef476bb1bffaec986fd4383f1e8953df48bccecc0 /plugins/org.eclipse.osee.framework.core.client
parentf7b611da85d00b1bab4ecb43fe0036eabae8970f (diff)
downloadorg.eclipse.osee-9f47598b91f745f1581db5c5d104f496fc9a340f.tar.gz
org.eclipse.osee-9f47598b91f745f1581db5c5d104f496fc9a340f.tar.xz
org.eclipse.osee-9f47598b91f745f1581db5c5d104f496fc9a340f.zip
refactor: Remove unused client task scheduler
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.client')
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ProgressMonitorTask.java59
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ScheduledTask.java51
-rw-r--r--plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/Scheduler.java91
4 files changed, 1 insertions, 203 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
index b9e4d3803ec..98264ef5bc8 100644
--- a/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.core.client/META-INF/MANIFEST.MF
@@ -23,6 +23,5 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.plugin.core.util,
org.osgi.framework
Export-Package: org.eclipse.osee.framework.core.client,
- org.eclipse.osee.framework.core.client.server,
- org.eclipse.osee.framework.core.client.task
+ org.eclipse.osee.framework.core.client.server
Service-Component: OSGI-INF/*.xml
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ProgressMonitorTask.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ProgressMonitorTask.java
deleted file mode 100644
index 43e7f9ce2ad..00000000000
--- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ProgressMonitorTask.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.client.task;
-
-import java.sql.Statement;
-import java.util.concurrent.TimeUnit;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ProgressMonitorTask extends ScheduledTask {
- private final IProgressMonitor monitor;
- private final Statement statement;
-
- private ProgressMonitorTask(IProgressMonitor monitor, Statement statement, String name) {
- super(name);
- this.monitor = monitor;
- this.statement = statement;
- }
-
- @Override
- protected void innerRun() throws Exception {
- if (monitor != null) {
- if (monitor.isCanceled()) {
- if (statement != null) {
- statement.cancel();
- }
- unscheduleTask();
- }
- } else {
- unscheduleTask();
- }
- }
-
- private void unscheduleTask() {
- Thread stopThread = new Thread() {
- @Override
- public void run() {
- Scheduler.cancelTask(ProgressMonitorTask.this);
- }
- };
- stopThread.start();
- }
-
- public static ScheduledTask monitor(String name, IProgressMonitor monitor, Statement statement, long millis) {
- ProgressMonitorTask task = new ProgressMonitorTask(monitor, statement, name);
- Scheduler.scheduleAtFixedRate(task, 0, millis, TimeUnit.MILLISECONDS);
- return task;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ScheduledTask.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ScheduledTask.java
deleted file mode 100644
index e7a5bd78c6f..00000000000
--- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/ScheduledTask.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.client.task;
-
-import java.util.concurrent.ScheduledFuture;
-
-/**
- * @author Roberto E. Escobar
- */
-public abstract class ScheduledTask implements Runnable {
- private final String name;
- private ScheduledFuture<ScheduledTask> futureTask;
-
- protected ScheduledTask(String name) {
- this.name = name;
- this.futureTask = null;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public final void run() {
- try {
- innerRun();
- } catch (Throwable th) {
- th.printStackTrace();
- }
- }
-
- @SuppressWarnings("unchecked")
- void setScheduledFuture(ScheduledFuture<?> futureTask) {
- this.futureTask = (ScheduledFuture<ScheduledTask>) futureTask;
- }
-
- protected ScheduledFuture<ScheduledTask> getFutureTask() {
- return futureTask;
- }
-
- protected abstract void innerRun() throws Exception;
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/Scheduler.java b/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/Scheduler.java
deleted file mode 100644
index 89e2065e7e0..00000000000
--- a/plugins/org.eclipse.osee.framework.core.client/src/org/eclipse/osee/framework/core/client/task/Scheduler.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.client.task;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Roberto E. Escobar
- */
-public class Scheduler {
-
- private static final InternalScheduler scheduler = new InternalScheduler();
-
- private Scheduler() {
- }
-
- public static void scheduleAtFixedRate(ScheduledTask command, long initialDelay, long period, TimeUnit unit) {
- scheduler.scheduleAtFixedRate(command, initialDelay, period, unit);
- }
-
- public static void scheduleWithFixedDelay(ScheduledTask command, long initialDelay, long delay, TimeUnit unit) {
- scheduler.scheduleWithFixedDelay(command, initialDelay, delay, unit);
- }
-
- public static void cancelTask(ScheduledTask command) {
- scheduler.cancelTask(command);
- }
-
- public static void shutdown() {
- scheduler.shutdown();
- }
-
- private static final class InternalScheduler {
- private final Map<Runnable, ScheduledFuture<?>> futures;
- private final ScheduledExecutorService executor;
-
- public InternalScheduler() {
- futures = Collections.synchronizedMap(new HashMap<Runnable, ScheduledFuture<?>>());
- executor = Executors.newSingleThreadScheduledExecutor(new SchedulerThreadFactory());
- }
-
- public void scheduleAtFixedRate(ScheduledTask command, long initialDelay, long period, TimeUnit unit) {
- ScheduledFuture<?> futureTask = executor.scheduleAtFixedRate(command, initialDelay, period, unit);
- futures.put(command, futureTask);
- command.setScheduledFuture(futureTask);
- }
-
- public void scheduleWithFixedDelay(ScheduledTask command, long initialDelay, long delay, TimeUnit unit) {
- ScheduledFuture<?> futureTask = executor.scheduleWithFixedDelay(command, initialDelay, delay, unit);
- futures.put(command, futureTask);
- command.setScheduledFuture(futureTask);
- }
-
- public void cancelTask(ScheduledTask command) {
- ScheduledFuture<?> future = futures.get(command);
- if (future != null) {
- if (future.cancel(true)) {
- futures.remove(command);
- }
- }
- }
-
- public void shutdown() {
- executor.shutdownNow();
- }
- }
-
- private static final class SchedulerThreadFactory implements ThreadFactory {
-
- @Override
- public Thread newThread(Runnable runnable) {
- return new Thread(((ScheduledTask) runnable).getName());
- }
-
- }
-}

Back to the top