Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2010-04-15 12:56:18 -0400
committerddunne2010-04-15 12:56:18 -0400
commit6b0d655b6f3b4416cbf1fe04f6d93286e5a0c4c9 (patch)
tree74110bff21bf8a9e995589b651157da8365bcb08 /plugins/org.eclipse.osee.framework.messaging.event.res
parent6ebf423292be94f098d34f0b70785b80a51b6ef7 (diff)
downloadorg.eclipse.osee-6b0d655b6f3b4416cbf1fe04f6d93286e5a0c4c9.tar.gz
org.eclipse.osee-6b0d655b6f3b4416cbf1fe04f6d93286e5a0c4c9.tar.xz
org.eclipse.osee-6b0d655b6f3b4416cbf1fe04f6d93286e5a0c4c9.zip
events
Diffstat (limited to 'plugins/org.eclipse.osee.framework.messaging.event.res')
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/FrameworkEventListener.java51
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IFrameworkEventListener.java6
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResEventManager.java123
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessages.java79
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessagingTracker.java55
6 files changed, 261 insertions, 56 deletions
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.messaging.event.res/META-INF/MANIFEST.MF
index 145bb6696b..1cd5df270b 100644
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/META-INF/MANIFEST.MF
@@ -8,7 +8,8 @@ Bundle-Activator: org.eclipse.osee.framework.messaging.event.res.Activator
Require-Bundle: org.eclipse.osee.framework.jdk.core,
org.eclipse.osee.framework.plugin.core,
org.eclipse.osee.framework.core,
- org.eclipse.core.runtime;bundle-version="3.5.0"
+ org.eclipse.core.runtime;bundle-version="3.5.0",
+ org.eclipse.osee.framework.messaging
Bundle-ActivationPolicy: lazy
Bundle-Description: Skynet Event Service - Skynet Cache Network Manager
Bundle-Vendor: Eclipse.org
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/FrameworkEventListener.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/FrameworkEventListener.java
deleted file mode 100644
index b3d13425f0..0000000000
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/FrameworkEventListener.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.messaging.event.res;
-
-import java.rmi.RemoteException;
-
-/**
- * Client call back
- *
- * @author Donald G. Dunne
- */
-public abstract class FrameworkEventListener implements IFrameworkEventListener {
-
- private static final long serialVersionUID = -3051021974908944273L;
- private final Long uid;
-
- public FrameworkEventListener() {
- this.uid = (long) (Math.random() * Long.MAX_VALUE);
- }
-
- /**
- * Since the listeners are hashed on the service side, it is necessary to force the equals and hashcode operators to
- * work in a particular manner.
- */
- @Override
- public final boolean equals(Object obj) {
- if (obj instanceof FrameworkEventListener) {
- return ((FrameworkEventListener) obj).uid.equals(this.uid);
- }
- return false;
- }
-
- @Override
- public final int hashCode() {
- return uid.hashCode();
- }
-
- /**
- * Callback for the client
- */
- public abstract void onEvent(RemoteEvent[] events) throws RemoteException;
-
-}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IFrameworkEventListener.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IFrameworkEventListener.java
index e448792a24..320af36010 100644
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IFrameworkEventListener.java
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IFrameworkEventListener.java
@@ -10,15 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.framework.messaging.event.res;
-import java.io.Serializable;
-import java.rmi.Remote;
import java.rmi.RemoteException;
/**
* @author Donald G. Dunne
*/
-public interface IFrameworkEventListener extends Remote, Serializable {
+public interface IFrameworkEventListener {
- public abstract void onEvent(RemoteEvent[] events) throws RemoteException;
+ public abstract void onEvent(RemoteEvent remoteEvent) throws RemoteException;
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResEventManager.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResEventManager.java
new file mode 100644
index 0000000000..3dfe0aea6f
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResEventManager.java
@@ -0,0 +1,123 @@
+/*
+ * Created on Mar 22, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.event.res;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.messaging.ConnectionNode;
+import org.eclipse.osee.framework.messaging.OseeMessagingListener;
+import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback;
+import org.eclipse.osee.framework.messaging.ReplyConnection;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteTransactionEvent1;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ResEventManager implements OseeMessagingStatusCallback {
+
+ private static ResEventManager instance;
+ private ConnectionNode connectionNode;
+ private ResMessagingTracker resMessagingTracker;
+ private IFrameworkEventListener frameworkEventListener;
+
+ private ResEventManager() {
+ }
+
+ public static ResEventManager getInstance() {
+ if (instance == null) {
+ instance = new ResEventManager();
+ }
+ return instance;
+ }
+
+ public static void dispose() {
+ if (instance != null) {
+ instance.stopListeningForRemoteCoverageEvents();
+ instance.resMessagingTracker.close();
+ instance = null;
+ }
+ }
+
+ private void startListeningForRemoteCoverageEvents() {
+ if (resMessagingTracker == null) {
+ System.out.println("Registering Client for Remote Events\n");
+ resMessagingTracker = new ResMessagingTracker();
+ resMessagingTracker.open(true);
+ addingRemoteEventService(resMessagingTracker.getConnectionNode());
+ }
+ }
+
+ private void stopListeningForRemoteCoverageEvents() {
+ System.out.println("De-Registering Client for Remote Events\n");
+ resMessagingTracker.close();
+ resMessagingTracker = null;
+ }
+
+ public boolean isConnected() {
+ return resMessagingTracker != null;
+ }
+
+ public void addingRemoteEventService(ConnectionNode connectionNode) {
+ this.connectionNode = connectionNode;
+ connectionNode.subscribe(ResMessages.RemoteTransactionEvent1, new RemoteTransactionEvent1Listener(), instance);
+ }
+
+ public void kick(RemoteEvent remoteEvent) throws Exception {
+ if (remoteEvent instanceof RemoteTransactionEvent1) {
+ sendRemoteEvent(ResMessages.RemoteTransactionEvent1, remoteEvent);
+ } else {
+ System.out.println("ResEventManager: Unhandled remote event " + remoteEvent);
+ }
+ }
+
+ public void sendRemoteEvent(ResMessages resMessage, RemoteEvent remoteEvent) throws Exception {
+ System.out.println(String.format(getClass().getSimpleName() + " - sending [%s]", remoteEvent));
+ if (connectionNode != null) {
+ connectionNode.send(resMessage, remoteEvent, instance);
+ }
+ }
+
+ public void start(IFrameworkEventListener frameworkEventListener) throws OseeCoreException {
+ this.frameworkEventListener = frameworkEventListener;
+ startListeningForRemoteCoverageEvents();
+ }
+
+ public void stop() throws OseeCoreException {
+ this.frameworkEventListener = null;
+ stopListeningForRemoteCoverageEvents();
+ }
+
+ @Override
+ public void fail(Throwable th) {
+ System.err.println(getClass().getSimpleName() + " - fail: " + th.getLocalizedMessage());
+ th.printStackTrace();
+ }
+
+ @Override
+ public void success() {
+ }
+
+ public class RemoteTransactionEvent1Listener extends OseeMessagingListener {
+
+ public RemoteTransactionEvent1Listener() {
+ super(RemoteTransactionEvent1.class);
+ }
+
+ @Override
+ public void process(final Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
+ RemoteTransactionEvent1 remoteTransactionEvent1 = (RemoteTransactionEvent1) message;
+ System.err.println(String.format(getClass().getSimpleName() + " - received [%s]",
+ message.getClass().getSimpleName()));
+ try {
+ frameworkEventListener.onEvent(remoteTransactionEvent1);
+ } catch (RemoteException ex) {
+ System.err.println(getClass().getSimpleName() + " - process: " + ex.getLocalizedMessage());
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessages.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessages.java
new file mode 100644
index 0000000000..be3ac4f00d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessages.java
@@ -0,0 +1,79 @@
+package org.eclipse.osee.framework.messaging.event.res;
+
+import org.eclipse.osee.framework.messaging.MessageID;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteAccessControlArtifactsEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteAttributeChange1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBasicGuidArtifact1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBasicModifiedGuidArtifact1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBranchEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBranchRenameEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBroadcastEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteChangeTypeArtifactsEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteNetworkSender1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemotePurgedArtifactsEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteTransactionDeletedEvent1;
+import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteTransactionEvent1;
+
+public enum ResMessages implements MessageID {
+ RemoteAccessControlArtifactsEvent1(true, "Aylfa1sC4iArrIaXxugA", "topic:org.eclipse.osee.coverage.msgs.RemoteAccessControlArtifactsEvent1", RemoteAccessControlArtifactsEvent1.class, false),
+ RemoteAttributeChange1(true, "Aylfa1tqjhm0dvCeWVQA", "topic:org.eclipse.osee.coverage.msgs.RemoteAttributeChange1", RemoteAttributeChange1.class, false),
+ RemoteBasicGuidArtifact1(true, "Aylfa1uaknpjHWHAw8QA", "topic:org.eclipse.osee.coverage.msgs.RemoteBasicGuidArtifact1", RemoteBasicGuidArtifact1.class, false),
+ RemoteBasicModifiedGuidArtifact1(true, "Aylfa1vJfz6i30DiUMQA", "topic:org.eclipse.osee.coverage.msgs.RemoteBasicModifiedGuidArtifact1", RemoteBasicModifiedGuidArtifact1.class, false),
+ RemoteBranchEvent1(true, "Aylfa1wlKXIbX2gOrVgA", "topic:org.eclipse.osee.coverage.msgs.RemoteBranchEvent1", RemoteBranchEvent1.class, false),
+ RemoteBranchRenameEvent1(true, "Aylfa1yHYFczc6m9GoAA", "topic:org.eclipse.osee.coverage.msgs.RemoteBranchRenameEvent1", RemoteBranchRenameEvent1.class, false),
+ RemoteBroadcastEvent1(true, "Aylfa1y3ZBSIGbVU3JgA", "topic:org.eclipse.osee.coverage.msgs.RemoteBroadcastEvent1", RemoteBroadcastEvent1.class, false),
+ RemoteChangeTypeArtifactsEvent1(true, "Aylfa1znaBzUzmyid9gA", "topic:org.eclipse.osee.coverage.msgs.RemoteChangeTypeArtifactsEvent1", RemoteChangeTypeArtifactsEvent1.class, false),
+ RemoteNetworkSender1(true, "Aylfa10VPjPhpdOzeLQA", "topic:org.eclipse.osee.coverage.msgs.RemoteNetworkSender1", RemoteNetworkSender1.class, false),
+ RemotePurgedArtifactsEvent1(true, "Aylfa11DE1DsqNVGkEgA", "topic:org.eclipse.osee.coverage.msgs.RemotePurgedArtifactsEvent1", RemotePurgedArtifactsEvent1.class, false),
+ RemoteTransactionDeletedEvent1(true, "AISIbRbFbXOVTBRJsqQA", "topic:org.eclipse.osee.coverage.msgs.RemoteTransactionDeletedEvent1", RemoteTransactionDeletedEvent1.class, false),
+ RemoteTransactionEvent1(true, "AISIbRj0KGBv62x2pMAA", "topic:org.eclipse.osee.coverage.msgs.RemoteTransactionEvent1", RemoteTransactionEvent1.class, false);
+
+ private String name;
+ private Class<?> clazz;
+ boolean isReplyRequired;
+ private String guid;
+ private String destination;
+ private boolean isTopic;
+
+ ResMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired) {
+ this.guid = guid;
+ this.name = name;
+ this.clazz = clazz;
+ this.isReplyRequired = isReplyRequired;
+ this.isTopic = isTopic;
+ if (isTopic) {
+ destination = "topic:" + guid;
+ } else {
+ destination = guid;
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Class<?> getSerializationClass() {
+ return clazz;
+ }
+
+ @Override
+ public boolean isReplyRequired() {
+ return isReplyRequired;
+ }
+
+ @Override
+ public String getGuid() {
+ return guid;
+ }
+
+ @Override
+ public String getMessageDestination() {
+ return destination;
+ }
+
+ public boolean isTopic() {
+ return isTopic;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessagingTracker.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessagingTracker.java
new file mode 100644
index 0000000000..85ecfe2cb2
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessagingTracker.java
@@ -0,0 +1,55 @@
+/*
+ * Created on Mar 11, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.event.res;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.messaging.ConnectionNode;
+import org.eclipse.osee.framework.messaging.MessageService;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ResMessagingTracker extends ServiceTracker {
+
+ private ConnectionNode connectionNode;
+
+ public ResMessagingTracker() {
+ super(Activator.getInstance().getBundle().getBundleContext(), MessageService.class.getName(), null);
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ MessageService service = (MessageService) super.addingService(reference);
+ try {
+ connectionNode = service.getDefault();
+ } catch (OseeCoreException ex) {
+ System.err.println("Can't add RES messaging service " + ex.getLocalizedMessage());
+ ex.printStackTrace();
+ }
+ return service;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service) {
+ super.removedService(reference, service);
+ }
+
+ @Override
+ public MessageService getService() {
+ return (MessageService) super.getService();
+ }
+
+ public ConnectionNode getConnectionNode() {
+ return connectionNode;
+ }
+
+ public void setConnectionNode(ConnectionNode connectionNode) {
+ this.connectionNode = connectionNode;
+ }
+
+}

Back to the top