Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Finkbeiner2016-12-16 11:51:31 -0500
committerAndrew M. Finkbeiner2016-12-16 11:51:31 -0500
commit590ad385f215dcde5274e3ca9e5d3561461e7af0 (patch)
treecba333e2a73c351c338d3428873f1f4f425112a4
parente7dcf4c97939e090e2eec58dd6ddb39daae3d194 (diff)
downloadorg.eclipse.osee-590ad385f215dcde5274e3ca9e5d3561461e7af0.tar.gz
org.eclipse.osee-590ad385f215dcde5274e3ca9e5d3561461e7af0.tar.xz
org.eclipse.osee-590ad385f215dcde5274e3ca9e5d3561461e7af0.zip
feature: Cleanup the subscription logicOTE_02_07_2017
-rw-r--r--plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/AbstractMessageDataBase.java8
-rw-r--r--plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/MessageServiceSupport.java14
2 files changed, 17 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/AbstractMessageDataBase.java b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/AbstractMessageDataBase.java
index 75e5842d16..da18e02e2d 100644
--- a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/AbstractMessageDataBase.java
+++ b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/AbstractMessageDataBase.java
@@ -15,6 +15,8 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
import java.util.logging.Level;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -38,6 +40,8 @@ public abstract class AbstractMessageDataBase {
private final ConcurrentHashMap<Integer, MessageInstance> idToMsgMap =
new ConcurrentHashMap<Integer, MessageInstance>();
+ private Executor worker = Executors.newSingleThreadExecutor();
+
private IMsgToolServiceClient client;
private volatile boolean connected = false;
private final DataReader reader = new DataReader(null, null, true, null, new EntityFactory() {
@@ -168,7 +172,7 @@ public abstract class AbstractMessageDataBase {
}
private boolean doInstanceAttach(MessageInstance instance) throws Exception {
- new Thread(new Runnable() {
+ worker.execute(new Runnable() {
@Override
public void run() {
Integer id;
@@ -181,7 +185,7 @@ public abstract class AbstractMessageDataBase {
e.printStackTrace();
}
}
- }).start();
+ });
return true;
}
diff --git a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/MessageServiceSupport.java b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/MessageServiceSupport.java
index e961d39e4a..325afa785d 100644
--- a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/MessageServiceSupport.java
+++ b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/MessageServiceSupport.java
@@ -52,11 +52,13 @@ public class MessageServiceSupport {
return send;
}
+ /**
+ * @deprecated use {@link #subscribeToMessage(SubscribeToMessage, SubscriptionHandler)}
+ * @param subscribeToMessage
+ * @return
+ */
@Deprecated
public static SubscriptionDetails subscribeToMessage(SubscribeToMessage subscribeToMessage) {
- if(Thread.currentThread().getName().contains("main")){
- System.out.println("bad");
- }
SerializedSubscriptionDetailsMessage resp = new SerializedSubscriptionDetailsMessage();
try{
SerializedSubscribeToMessage cmd = new SerializedSubscribeToMessage(subscribeToMessage);
@@ -73,6 +75,12 @@ public class MessageServiceSupport {
}
}
+ /**
+ * Subscribes to a message and notifies the user in a callback so that we do not block any UI threads.
+ *
+ * @param subscribeToMessage
+ * @param handler
+ */
public static void subscribeToMessage(SubscribeToMessage subscribeToMessage, SubscriptionHandler handler) {
worker.execute(new Runnable(){
@Override

Back to the top