diff options
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 75e5842d16e..da18e02e2d9 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 e961d39e4af..325afa785d6 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 |