Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-08-23 15:57:24 -0400
committerrescobar2010-08-23 15:57:24 -0400
commit1378e118ea5006b764c9ea902773456c817e9a50 (patch)
tree00ca2e881f4a72e4e21e37b489017f211a563cfc /plugins/org.eclipse.osee.framework.messaging.event.res
parentf5b90f0676d83705154ef331f32e1a0d5b56d17c (diff)
downloadorg.eclipse.osee-1378e118ea5006b764c9ea902773456c817e9a50.tar.gz
org.eclipse.osee-1378e118ea5006b764c9ea902773456c817e9a50.tar.xz
org.eclipse.osee-1378e118ea5006b764c9ea902773456c817e9a50.zip
Event System registration cleanup
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.MF17
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/Activator.java34
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IOseeCoreModelEventService.java31
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/RemoteEventUtil.java6
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResEventManager.java233
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessagingTracker.java60
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/Activator.java35
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/FrameworkRelayMessagingListener.java82
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceImpl.java130
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceRegHandler.java67
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/ResMessages.java (renamed from plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessages.java)9
11 files changed, 365 insertions, 339 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 afa1e4499f..3d7c51f356 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
@@ -4,16 +4,19 @@ Bundle-Name: Framework Event Service (Incubation)
Bundle-SymbolicName: org.eclipse.osee.framework.messaging.event.res;singleton:=true
Bundle-Version: 0.9.5.qualifier
Eclipse-ExtensibleAPI: true
-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,
- org.eclipse.osee.framework.messaging
+Bundle-Activator: org.eclipse.osee.framework.messaging.event.res.internal.Activator
Bundle-ActivationPolicy: lazy
Bundle-Description: Skynet Event Service - Skynet Cache Network Manager
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.eclipse.osee.framework.core.enums
+Import-Package: org.eclipse.core.runtime,
+ org.eclipse.osee.framework.core.enums,
+ org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.util,
+ org.eclipse.osee.framework.jdk.core.type,
+ org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.framework.logging,
+ org.eclipse.osee.framework.messaging,
+ org.osgi.framework
Export-Package: org.eclipse.osee.framework.messaging.event.res,
org.eclipse.osee.framework.messaging.event.res.msgs
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/Activator.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/Activator.java
deleted file mode 100644
index ecf0694211..0000000000
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/Activator.java
+++ /dev/null
@@ -1,34 +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 org.eclipse.osee.framework.plugin.core.OseeActivator;
-
-/**
- * @author Donald G. Dunne
- */
-public class Activator extends OseeActivator {
-
- private static Activator pluginInstance;
- public static final String PLUGIN_ID = "org.eclipse.osee.framework.messaging.event.res";
-
- public Activator() {
- super();
- pluginInstance = this;
- }
-
- /**
- * Returns the shared instance.
- */
- public static Activator getInstance() {
- return pluginInstance;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IOseeCoreModelEventService.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IOseeCoreModelEventService.java
new file mode 100644
index 0000000000..7b9f383bfa
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/IOseeCoreModelEventService.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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 org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.messaging.ConnectionListener;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IOseeCoreModelEventService {
+
+ void addFrameworkListener(IFrameworkEventListener frameworkEventListener);
+
+ void removeFrameworkListener(IFrameworkEventListener frameworkEventListener);
+
+ void addConnectionListener(ConnectionListener connectionListener);
+
+ void removeConnectionListener(ConnectionListener connectionListener);
+
+ void sendRemoteEvent(RemoteEvent remoteEvent) throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/RemoteEventUtil.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/RemoteEventUtil.java
index 83a7051142..b7a14a53e4 100644
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/RemoteEventUtil.java
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/RemoteEventUtil.java
@@ -15,7 +15,11 @@ import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteNetworkSender1;
/**
* @author Donald G. Dunne
*/
-public class RemoteEventUtil {
+public final class RemoteEventUtil {
+
+ private RemoteEventUtil() {
+ // Utility class
+ }
public static RemoteNetworkSender1 getNetworkSender(String sourceObject, String sessionId, String machineName, String userId, String machineIp, int port, String clientVersion) {
RemoteNetworkSender1 networkSender = new RemoteNetworkSender1();
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
deleted file mode 100644
index 9f1a9e134c..0000000000
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResEventManager.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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;
-import java.util.Map;
-import org.eclipse.osee.framework.messaging.ConnectionListener;
-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.RemoteAccessControlEvent1;
-import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBranchEvent1;
-import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBroadcastEvent1;
-import org.eclipse.osee.framework.messaging.event.res.msgs.RemotePersistEvent1;
-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 ConnectionListener connectionListener;
-
- private ResEventManager() {
- // private
- }
-
- 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 void addingRemoteEventService(ConnectionNode connectionNode) {
- this.connectionNode = connectionNode;
- connectionNode.addConnectionListener(connectionListener);
-
- connectionNode.subscribe(ResMessages.RemoteTransactionEvent1, new RemoteTransactionEvent1Listener(), instance);
- connectionNode.subscribe(ResMessages.RemotePersistEvent1, new RemotePersistEvent1Listener(), instance);
- connectionNode.subscribe(ResMessages.RemoteBranchEvent1, new RemoteBranchEvent1Listener(), instance);
- connectionNode.subscribe(ResMessages.RemoteBroadcastEvent1, new RemoteBroadcastEvent1Listener(), instance);
- connectionNode.subscribe(ResMessages.RemoteAccessControlEvent1, new RemoteAccessControlEvent1Listener(), instance);
- }
-
- public void kick(RemoteEvent remoteEvent) throws Exception {
- if (remoteEvent instanceof RemotePersistEvent1) {
- sendRemoteEvent(ResMessages.RemotePersistEvent1, remoteEvent);
- } else if (remoteEvent instanceof RemoteTransactionEvent1) {
- sendRemoteEvent(ResMessages.RemoteTransactionEvent1, remoteEvent);
- } else if (remoteEvent instanceof RemoteBranchEvent1) {
- sendRemoteEvent(ResMessages.RemoteBranchEvent1, remoteEvent);
- } else if (remoteEvent instanceof RemoteBroadcastEvent1) {
- sendRemoteEvent(ResMessages.RemoteBroadcastEvent1, remoteEvent);
- } else if (remoteEvent instanceof RemoteAccessControlEvent1) {
- sendRemoteEvent(ResMessages.RemoteAccessControlEvent1, 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.getClass().getSimpleName()));
- if (connectionNode != null) {
- connectionNode.send(resMessage, remoteEvent, instance);
- }
- }
-
- public void start(IFrameworkEventListener frameworkEventListener) {
- this.frameworkEventListener = frameworkEventListener;
- startListeningForRemoteCoverageEvents();
- }
-
- public void stop() {
- this.frameworkEventListener = null;
- stopListeningForRemoteCoverageEvents();
- }
-
- @Override
- public void fail(Throwable th) {
- System.err.println(getClass().getSimpleName() + " - fail: " + th.getLocalizedMessage());
- th.printStackTrace();
- }
-
- @Override
- public void success() {
- // do nothing
- }
-
- public class RemoteAccessControlEvent1Listener extends OseeMessagingListener {
-
- public RemoteAccessControlEvent1Listener() {
- super(RemoteAccessControlEvent1.class);
- }
-
- @Override
- public void process(final Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
- RemoteAccessControlEvent1 remoteTransactionEvent1 = (RemoteAccessControlEvent1) 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());
- }
- }
- }
-
- 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());
- }
- }
- }
-
- public class RemotePersistEvent1Listener extends OseeMessagingListener {
-
- public RemotePersistEvent1Listener() {
- super(RemotePersistEvent1.class);
- }
-
- @Override
- public void process(final Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
- RemotePersistEvent1 remotePersistEvent1 = (RemotePersistEvent1) message;
- // System.err.println(String.format(getClass().getSimpleName() + " - received [%s]",
- // message.getClass().getSimpleName()));
- try {
- frameworkEventListener.onEvent(remotePersistEvent1);
- } catch (RemoteException ex) {
- System.err.println(getClass().getSimpleName() + " - process: " + ex.getLocalizedMessage());
- }
- }
- }
-
- public class RemoteBranchEvent1Listener extends OseeMessagingListener {
-
- public RemoteBranchEvent1Listener() {
- super(RemoteBranchEvent1.class);
- }
-
- @Override
- public void process(final Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
- RemoteBranchEvent1 remoteBranchEvent1 = (RemoteBranchEvent1) message;
- System.err.println(String.format(getClass().getSimpleName() + " - received [%s]",
- message.getClass().getSimpleName()));
- try {
- frameworkEventListener.onEvent(remoteBranchEvent1);
- } catch (RemoteException ex) {
- System.err.println(getClass().getSimpleName() + " - process: " + ex.getLocalizedMessage());
- }
- }
- }
-
- public class RemoteBroadcastEvent1Listener extends OseeMessagingListener {
-
- public RemoteBroadcastEvent1Listener() {
- super(RemoteBroadcastEvent1.class);
- }
-
- @Override
- public void process(final Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
- RemoteBroadcastEvent1 remoteBroadcastEvent1 = (RemoteBroadcastEvent1) message;
- System.err.println(String.format(getClass().getSimpleName() + " - received [%s]",
- message.getClass().getSimpleName()));
- try {
- frameworkEventListener.onEvent(remoteBroadcastEvent1);
- } catch (RemoteException ex) {
- System.err.println(getClass().getSimpleName() + " - process: " + ex.getLocalizedMessage());
- }
- }
- }
-
- public ConnectionListener getConnectionListener() {
- return connectionListener;
- }
-
- public void setConnectionListener(ConnectionListener connectionListener) {
- this.connectionListener = connectionListener;
- if (connectionNode != null) {
- connectionNode.addConnectionListener(connectionListener);
- }
- }
-
-}
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
deleted file mode 100644
index c75b3115e3..0000000000
--- a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/ResMessagingTracker.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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 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;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/Activator.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/Activator.java
new file mode 100644
index 0000000000..664ff1b2fd
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/Activator.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.internal;
+
+import org.eclipse.osee.framework.core.util.ServiceDependencyTracker;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class Activator implements BundleActivator {
+
+ private ServiceDependencyTracker tracker;
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ tracker = new ServiceDependencyTracker(context, new OseeCoreModelEventServiceRegHandler());
+ tracker.open();
+ }
+
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ Lib.close(tracker);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/FrameworkRelayMessagingListener.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/FrameworkRelayMessagingListener.java
new file mode 100644
index 0000000000..6e91bfaa92
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/FrameworkRelayMessagingListener.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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.internal;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+import org.eclipse.osee.framework.messaging.OseeMessagingListener;
+import org.eclipse.osee.framework.messaging.ReplyConnection;
+import org.eclipse.osee.framework.messaging.event.res.IFrameworkEventListener;
+import org.eclipse.osee.framework.messaging.event.res.RemoteEvent;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class FrameworkRelayMessagingListener<T extends RemoteEvent> extends OseeMessagingListener {
+
+ private final IFrameworkEventListener frameworkEventListener;
+ private final boolean isVerbose;
+
+ protected FrameworkRelayMessagingListener(Class<?> clazz, IFrameworkEventListener frameworkEventListener, boolean isVerbose) {
+ super(clazz);
+ this.frameworkEventListener = frameworkEventListener;
+ this.isVerbose = isVerbose;
+ }
+
+ @Override
+ public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
+ if (isVerbose) {
+ System.err.println(String.format(getClass().getSimpleName() + " - received [%s]",
+ message.getClass().getSimpleName()));
+ }
+ try {
+ T remoteEvent = asCastedMessage(message);
+ frameworkEventListener.onEvent(remoteEvent);
+ } catch (RemoteException ex) {
+ System.err.println(getClass().getSimpleName() + " - process: " + ex.getLocalizedMessage());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private T asCastedMessage(Object message) {
+ return (T) message;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((frameworkEventListener == null) ? 0 : frameworkEventListener.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ FrameworkRelayMessagingListener<?> other = (FrameworkRelayMessagingListener<?>) obj;
+ if (frameworkEventListener == null) {
+ if (other.frameworkEventListener != null) {
+ return false;
+ }
+ } else if (!frameworkEventListener.equals(other.frameworkEventListener)) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceImpl.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceImpl.java
new file mode 100644
index 0000000000..96dd50a778
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceImpl.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
+import org.eclipse.osee.framework.messaging.ConnectionListener;
+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.event.res.IFrameworkEventListener;
+import org.eclipse.osee.framework.messaging.event.res.IOseeCoreModelEventService;
+import org.eclipse.osee.framework.messaging.event.res.RemoteEvent;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class OseeCoreModelEventServiceImpl implements OseeMessagingStatusCallback, IOseeCoreModelEventService {
+
+ private final Map<IFrameworkEventListener, HashCollection<ResMessages, OseeMessagingListener>> subscriptions =
+ new HashMap<IFrameworkEventListener, HashCollection<ResMessages, OseeMessagingListener>>();
+ private final Map<ResMessages, Boolean> messages;
+ private final ConnectionNode connectionNode;
+
+ public OseeCoreModelEventServiceImpl(ConnectionNode connectionNode, Map<ResMessages, Boolean> messages) {
+ this.connectionNode = connectionNode;
+ this.messages = messages;
+ }
+
+ @Override
+ public void success() {
+ // do nothing
+ }
+
+ @Override
+ public void fail(Throwable th) {
+ System.err.println(getClass().getSimpleName() + " - fail: " + th.getLocalizedMessage());
+ th.printStackTrace();
+ }
+
+ @Override
+ public void sendRemoteEvent(RemoteEvent remoteEvent) throws OseeCoreException {
+ ResMessages resMessage = getResMessageType(remoteEvent);
+ if (resMessage != null) {
+ System.out.println(String.format("ResEventManager: Unhandled remote event ", remoteEvent));
+ } else if (connectionNode != null) {
+ System.out.println(String.format(
+ "ResEventManager: Connection node was null - unable to send remote event [%s] ", resMessage));
+ } else {
+ connectionNode.send(resMessage, remoteEvent, this);
+ }
+ }
+
+ private ResMessages getResMessageType(RemoteEvent remoteEvent) {
+ ResMessages resMessage = null;
+ if (remoteEvent != null) {
+ for (ResMessages allowedMessage : messages.keySet()) {
+ Class<?> messageClass = allowedMessage.getSerializationClass();
+ if (messageClass.isAssignableFrom(remoteEvent.getClass())) {
+ resMessage = allowedMessage;
+ break;
+ }
+ }
+ }
+ return resMessage;
+ }
+
+ @Override
+ public void addConnectionListener(ConnectionListener connectionListener) {
+ connectionNode.addConnectionListener(connectionListener);
+ }
+
+ @Override
+ public void removeConnectionListener(ConnectionListener connectionListener) {
+ connectionNode.removeConnectionListener(connectionListener);
+ }
+
+ @Override
+ public void addFrameworkListener(IFrameworkEventListener frameworkEventListener) {
+ System.out.println("Registering Client for Remote Events\n");
+
+ for (Entry<ResMessages, Boolean> messageEntries : messages.entrySet()) {
+ ResMessages resMessageID = messageEntries.getKey();
+ boolean isVerbose = messageEntries.getValue();
+ subscribe(resMessageID, resMessageID.getSerializationClass(), isVerbose, frameworkEventListener);
+ }
+ }
+
+ @Override
+ public void removeFrameworkListener(IFrameworkEventListener frameworkEventListener) {
+ System.out.println("De-Registering Client for Remote Events\n");
+
+ HashCollection<ResMessages, OseeMessagingListener> listeners = subscriptions.get(frameworkEventListener);
+ if (listeners != null) {
+ for (ResMessages messageID : listeners.keySet()) {
+ Collection<OseeMessagingListener> listernerList = listeners.getValues(messageID);
+ if (listernerList != null) {
+ for (OseeMessagingListener listener : listernerList) {
+ connectionNode.unsubscribe(messageID, listener, this);
+ }
+ }
+ }
+ subscriptions.remove(frameworkEventListener);
+ }
+ }
+
+ private <T extends RemoteEvent> void subscribe(ResMessages messageId, Class<T> clazz, boolean isVerbose, IFrameworkEventListener frameworkEventListener) {
+ OseeMessagingListener listener = new FrameworkRelayMessagingListener<T>(clazz, frameworkEventListener, isVerbose);
+ connectionNode.subscribe(messageId, listener, this);
+ HashCollection<ResMessages, OseeMessagingListener> listeners = subscriptions.get(frameworkEventListener);
+ if (listeners == null) {
+ listeners = new HashCollection<ResMessages, OseeMessagingListener>(true, HashSet.class);
+ subscriptions.put(frameworkEventListener, listeners);
+ }
+ listeners.put(messageId, listener);
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceRegHandler.java b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceRegHandler.java
new file mode 100644
index 0000000000..dafdab435c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.event.res/src/org/eclipse/osee/framework/messaging/event/res/internal/OseeCoreModelEventServiceRegHandler.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.internal;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.ConnectionNode;
+import org.eclipse.osee.framework.messaging.MessageService;
+import org.eclipse.osee.framework.messaging.event.res.IOseeCoreModelEventService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OseeCoreModelEventServiceRegHandler extends AbstractTrackingHandler {
+
+ private static final Class<?>[] DEPENDENCIES = new Class<?>[] {MessageService.class};
+
+ private final Map<ResMessages, Boolean> eventMessageConfig = new HashMap<ResMessages, Boolean>();
+ private ServiceRegistration registration;
+
+ public OseeCoreModelEventServiceRegHandler() {
+ eventMessageConfig.put(ResMessages.RemoteAccessControlEvent1, Boolean.TRUE);
+ eventMessageConfig.put(ResMessages.RemoteBranchEvent1, Boolean.TRUE);
+ eventMessageConfig.put(ResMessages.RemoteBroadcastEvent1, Boolean.TRUE);
+ eventMessageConfig.put(ResMessages.RemotePersistEvent1, Boolean.FALSE);
+ eventMessageConfig.put(ResMessages.RemoteTransactionEvent1, Boolean.TRUE);
+ }
+
+ @Override
+ public Class<?>[] getDependencies() {
+ return DEPENDENCIES;
+ }
+
+ @Override
+ public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
+ MessageService messageService = getService(MessageService.class, services);
+ try {
+ ConnectionNode connectionNode = messageService.getDefault();
+ IOseeCoreModelEventService service = new OseeCoreModelEventServiceImpl(connectionNode, eventMessageConfig);
+ registration = context.registerService(IOseeCoreModelEventService.class.getName(), service, null);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(Activator.class, Level.SEVERE, ex);
+ }
+ }
+
+ @Override
+ public void onDeActivate() {
+ if (registration != null) {
+ registration.unregister();
+ }
+ }
+
+}
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/internal/ResMessages.java
index b04aec89f7..9200dc090b 100644
--- 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/internal/ResMessages.java
@@ -8,9 +8,10 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.framework.messaging.event.res;
+package org.eclipse.osee.framework.messaging.event.res.internal;
import org.eclipse.osee.framework.messaging.MessageID;
+import org.eclipse.osee.framework.messaging.event.res.RemoteEvent;
import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteAccessControlEvent1;
import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBranchEvent1;
import org.eclipse.osee.framework.messaging.event.res.msgs.RemoteBroadcastEvent1;
@@ -25,12 +26,12 @@ public enum ResMessages implements MessageID {
RemoteAccessControlEvent1(true, "AFRkIhdPkwExx96ioXgA", "topic:org.eclipse.osee.coverage.msgs.RemoteAccessControlEvent1", RemoteAccessControlEvent1.class, false);
private String name;
- private Class<?> clazz;
+ private Class<? extends RemoteEvent> clazz;
boolean isReplyRequired;
private String guid;
private boolean isTopic;
- ResMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired) {
+ ResMessages(boolean isTopic, String guid, String name, Class<? extends RemoteEvent> clazz, boolean isReplyRequired) {
this.guid = guid;
this.name = name;
this.clazz = clazz;
@@ -44,7 +45,7 @@ public enum ResMessages implements MessageID {
}
@Override
- public Class<?> getSerializationClass() {
+ public Class<? extends RemoteEvent> getSerializationClass() {
return clazz;
}

Back to the top