Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew M. Finkbeiner2016-12-15 20:03:07 -0500
committerAndrew M. Finkbeiner2016-12-15 20:05:33 -0500
commite7dcf4c97939e090e2eec58dd6ddb39daae3d194 (patch)
tree3cf723b76a0915033a5e9f8f80a1980d3dd72520
parenteb9ce0a1cb75e91cc1d28b9c2f85eeef452b0d9a (diff)
downloadorg.eclipse.osee-e7dcf4c97939e090e2eec58dd6ddb39daae3d194.tar.gz
org.eclipse.osee-e7dcf4c97939e090e2eec58dd6ddb39daae3d194.tar.xz
org.eclipse.osee-e7dcf4c97939e090e2eec58dd6ddb39daae3d194.zip
bug: Fix a subscribe issue
-rw-r--r--plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/AbstractMessageDataBase.java20
-rw-r--r--plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/MessageInstance.java1
-rw-r--r--plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/MessageServiceSupport.java32
-rw-r--r--plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/SubscriptionHandler.java9
4 files changed, 55 insertions, 7 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 44df86c62e..75e5842d16 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
@@ -168,12 +168,20 @@ public abstract class AbstractMessageDataBase {
}
private boolean doInstanceAttach(MessageInstance instance) throws Exception {
- Integer id = instance.attachToService(client);
- if (id == null) {
- // can't subscribe because environment does not support this type
- return false;
- }
- idToMsgMap.put(id, instance);
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ Integer id;
+ try {
+ id = instance.attachToService(client);
+ if (id != null) {
+ idToMsgMap.put(id, instance);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
return true;
}
diff --git a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/MessageInstance.java b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/MessageInstance.java
index 062cdd848e..4800f403ad 100644
--- a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/MessageInstance.java
+++ b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/db/MessageInstance.java
@@ -68,6 +68,7 @@ public class MessageInstance {
} else {
details = MessageServiceSupport.subscribeToMessage(new SubscribeToMessage(msg.getClass().getName(), type, mode,
client.getAddressByType(msg.getClass().getName(), type), client.getTestSessionKey()));
+
}
if (details == null) {
supported = false;
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 d1dd1d7a9a..e961d39e4a 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
@@ -4,6 +4,8 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
import org.eclipse.osee.ote.OTEException;
import org.eclipse.osee.ote.core.ServiceUtility;
@@ -34,6 +36,7 @@ public class MessageServiceSupport {
private static EventAdmin admin;
private static OteSendEventMessage send;
+ private static Executor worker = Executors.newSingleThreadExecutor();
private static EventAdmin getEventAdmin(){
if(admin == null){
@@ -49,8 +52,11 @@ public class MessageServiceSupport {
return send;
}
-
+ @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);
@@ -66,6 +72,30 @@ public class MessageServiceSupport {
throw new OTEException("Serialization Error", e);
}
}
+
+ public static void subscribeToMessage(SubscribeToMessage subscribeToMessage, SubscriptionHandler handler) {
+ worker.execute(new Runnable(){
+ @Override
+ public void run() {
+ SerializedSubscriptionDetailsMessage resp = new SerializedSubscriptionDetailsMessage();
+ try{
+ SerializedSubscribeToMessage cmd = new SerializedSubscribeToMessage(subscribeToMessage);
+ resp = get().synchSendAndResponse(resp, cmd, 10000);
+ if(resp == null){
+ throw new OTEException("Timed out waiting for message response");
+ }
+ SubscriptionDetails details = resp.getObject();
+ handler.onSubscriptionComplete(details);
+ } catch (IOException ex){
+ throw new OTEException("Serialization Error", ex);
+ } catch (ClassNotFoundException e) {
+ throw new OTEException("Serialization Error", e);
+ }
+ }
+
+ });
+
+ }
public static void unsubscribeToMessage(UnSubscribeToMessage unSubscribeToMessage) {
SerializedUnSubscribeMessage cmd;
diff --git a/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/SubscriptionHandler.java b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/SubscriptionHandler.java
new file mode 100644
index 0000000000..a9ddc64404
--- /dev/null
+++ b/plugins/org.eclipse.osee.ote.client.msg/src/org/eclipse/osee/ote/client/msg/core/internal/SubscriptionHandler.java
@@ -0,0 +1,9 @@
+package org.eclipse.osee.ote.client.msg.core.internal;
+
+import org.eclipse.osee.ote.message.tool.SubscriptionDetails;
+
+public interface SubscriptionHandler {
+
+ void onSubscriptionComplete(SubscriptionDetails details);
+
+}

Back to the top