diff options
author | afinkbein | 2008-06-20 00:17:23 +0000 |
---|---|---|
committer | afinkbein | 2008-06-20 00:17:23 +0000 |
commit | b9eb44a27693a77daf5e43c9ce10eb10678a2067 (patch) | |
tree | 17a4bf42edb7fef8a799f0bb7de33ffa9313d3e5 | |
parent | eca3ef8c07d623777eb8e251fc9dd03588d3a06a (diff) | |
download | org.eclipse.osee-b9eb44a27693a77daf5e43c9ce10eb10678a2067.tar.gz org.eclipse.osee-b9eb44a27693a77daf5e43c9ce10eb10678a2067.tar.xz org.eclipse.osee-b9eb44a27693a77daf5e43c9ce10eb10678a2067.zip |
34 files changed, 1655 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.messaging.event.skynet/.classpath b/org.eclipse.osee.framework.messaging.event.skynet/.classpath new file mode 100644 index 00000000000..02159672985 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.osee.framework.messaging.event.skynet/.project b/org.eclipse.osee.framework.messaging.event.skynet/.project new file mode 100644 index 00000000000..978f420c584 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.messaging.event.skynet</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.osee.framework.messaging.event.skynet/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.osee.framework.messaging.event.skynet/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..a8020f2dc2e --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +#Fri Mar 28 14:00:57 GMT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/org.eclipse.osee.framework.messaging.event.skynet/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.messaging.event.skynet/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..8f0b9abec1a --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Skynet Event Service (Incubation) +Bundle-SymbolicName: org.eclipse.osee.framework.messaging.event.skynet;singleton:=true +Bundle-Version: 0.2.0.qualifier +Bundle-Activator: org.eclipse.osee.framework.messaging.event.skynet.SkynetEventPlugin +Require-Bundle: org.eclipse.core.runtime, + net.jini, + org.eclipse.osee.framework.jdk.core, + org.eclipse.osee.framework.jini, + org.eclipse.osee.framework.plugin.core, + org.eclipse.osee.framework.ui.plugin, + org.eclipse.ui +Eclipse-LazyStart: true +Export-Package: org.eclipse.osee.framework.messaging.event.skynet, + org.eclipse.osee.framework.messaging.event.skynet.event, + org.eclipse.osee.framework.messaging.event.skynet.filter, + org.eclipse.osee.framework.messaging.event.skynet.service +Bundle-Description: Skynet Event Service - Skynet Cache Network Manager +Bundle-Vendor: Eclipse.org +Bundle-ClassPath: skynetEvent.jar diff --git a/org.eclipse.osee.framework.messaging.event.skynet/build.properties b/org.eclipse.osee.framework.messaging.event.skynet/build.properties new file mode 100644 index 00000000000..afc89d080b3 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/build.properties @@ -0,0 +1,6 @@ +source.skynetEvent.jar = src/
+output.skynetEvent.jar = bin/
+bin.includes = META-INF/,\
+ skynetEvent.jar,\
+ plugin.xml,\
+ src/
diff --git a/org.eclipse.osee.framework.messaging.event.skynet/plugin.xml b/org.eclipse.osee.framework.messaging.event.skynet/plugin.xml new file mode 100644 index 00000000000..b37257d9042 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/plugin.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.osee.framework.jini.JiniInterface">
+ <Interface classname="org.eclipse.osee.framework.messaging.event.skynet.ISkynetEventService"/>
+ <Interface classname="org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent"/>
+ <Interface classname="org.eclipse.osee.framework.messaging.event.skynet.ISkynetEventListener"/>
+ <Interface classname="org.eclipse.osee.framework.messaging.event.skynet.event.SkynetAttributeChange"/>
+ </extension>
+ <extension
+ point="org.eclipse.osee.framework.jini.JiniInterface">
+ <RegisterBundle/>
+ </extension>
+ <extension
+ id="EventService"
+ name="EventService"
+ point="org.eclipse.core.runtime.applications">
+ <application>
+ <run class="org.eclipse.osee.framework.messaging.event.skynet.service.SkynetEventServicePlatformRunnable"/>
+ </application>
+ </extension>
+ <extension
+ id="EventServiceProd"
+ point="org.eclipse.core.runtime.products">
+ <product
+ application="org.eclipse.osee.framework.messaging.event.skynet.EventService"
+ name="EventServiceProd"/>
+ </extension>
+
+</plugin>
diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ASkynetEventListener.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ASkynetEventListener.java new file mode 100644 index 00000000000..193ee3ae62d --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ASkynetEventListener.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.skynet; + +import java.rmi.RemoteException; + +/** + * Client callback base class. + * + * @author Robert A. Fisher + */ +public abstract class ASkynetEventListener implements ISkynetEventListener { + + private final Long uid; + + public ASkynetEventListener() { + 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 ASkynetEventListener) { + return ((ASkynetEventListener) obj).uid.equals(this.uid); + } + return false; + } + + @Override + public final int hashCode() { + return uid.hashCode(); + } + + /** + * Callback for the client to process remote skynet events. The array will contain a list of events to which this + * listener is subscribed. + * + * @throws RemoteException + */ + public abstract void onEvent(ISkynetEvent[] events) throws RemoteException; + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetArtifactEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetArtifactEvent.java new file mode 100644 index 00000000000..01821d4e967 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetArtifactEvent.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * 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.skynet; + +/** + * @author Robert A. Fisher + */ +public interface ISkynetArtifactEvent extends ISkynetEvent { + + public String getFactoryName(); + + public int getArtId(); + + public int getArtTypeId(); +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEvent.java new file mode 100644 index 00000000000..d5dff3022c8 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEvent.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * 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.skynet; + +import java.io.Serializable; + +/** + * All Skynet events implement this interface. + * + * @author Robert A. Fisher + */ +@SuppressWarnings("unchecked") +public interface ISkynetEvent extends Serializable, Comparable { + public static final ISkynetEvent[] EMPTY_ARRAY = new ISkynetEvent[0]; + + public int getTransactionId(); + + public int getBranchId(); + + public int getAuthor(); +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEventListener.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEventListener.java new file mode 100644 index 00000000000..7bfa3648914 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEventListener.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.skynet; + +import java.io.Serializable; +import java.rmi.Remote; +import java.rmi.RemoteException; + +public interface ISkynetEventListener extends Remote, Serializable { + + public abstract void onEvent(ISkynetEvent[] events) throws RemoteException; +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEventService.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEventService.java new file mode 100644 index 00000000000..f19328a13ca --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetEventService.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.skynet; + +import java.rmi.Remote; +import java.rmi.RemoteException; +import org.eclipse.osee.framework.messaging.event.skynet.filter.IEventFilter; + +public interface ISkynetEventService extends Remote { + + // TODO all calls to the server go here + /** + * Register to receive events based on filters. + * + * @param filters TODO + */ + public void register(ISkynetEventListener listener, IEventFilter... filters) throws RemoteException; + + /** + * Deregister to receive events based on filters. + * + * @param filters TODO + */ + public void deregister(ISkynetEventListener listener, IEventFilter... filters) throws RemoteException; + + /** + * Pass events to the service to be disemminated. + * + * @param events + */ + public void kick(ISkynetEvent[] events, ISkynetEventListener... except) throws RemoteException; + + public boolean isAlive() throws RemoteException; +}
\ No newline at end of file diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetRelationLinkEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetRelationLinkEvent.java new file mode 100644 index 00000000000..e579f01a7b6 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/ISkynetRelationLinkEvent.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.skynet; + +/** + * @author Robert A. Fisher + */ +public interface ISkynetRelationLinkEvent extends ISkynetEvent { + + public int getArtAId(); + + public int getArtBId(); + + public Integer getRelId(); + + public Integer getGammaId(); + + public int getRelTypeId(); +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkCommitBranchEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkCommitBranchEvent.java new file mode 100644 index 00000000000..390fae08b0a --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkCommitBranchEvent.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.skynet; + +/** + * Skynet messaging event; Should not be subscribed to by OSEE applications. + * + * @author Donald G. Dunne + */ +public class NetworkCommitBranchEvent implements ISkynetEvent { + private static final long serialVersionUID = 8339596149601667894L; + private int branchId; + private int author; + + /** + * @param branchId + * @param author + */ + public NetworkCommitBranchEvent(int branchId, int author) { + this.branchId = branchId; + this.author = author; + } + + public int getBranchId() { + return branchId; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(T) + */ + public int compareTo(Object o) { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent#getAuthor() + */ + public int getAuthor() { + return author; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent#getTransactionId() + */ + public int getTransactionId() { + return 0; + } + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkDeletedBranchEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkDeletedBranchEvent.java new file mode 100644 index 00000000000..f93cc466591 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkDeletedBranchEvent.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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.skynet; + +/** + * Skynet messaging event; Should not be subscribed to by OSEE applications. + * + * @author Jeff C. Phillips + */ +public class NetworkDeletedBranchEvent implements ISkynetEvent { + private static final long serialVersionUID = 4651718722048388742L; + private int branchId; + private int author; + + public NetworkDeletedBranchEvent(int branchId, int author) { + this.branchId = branchId; + this.author = author; + } + + public int getTransactionId() { + return 0; + } + + public int getBranchId() { + return branchId; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(T) + */ + public int compareTo(Object o) { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent#getAuthor() + */ + public int getAuthor() { + return author; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkNewBranchEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkNewBranchEvent.java new file mode 100644 index 00000000000..dcf5e382b1a --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkNewBranchEvent.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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.skynet; + +/** + * Skynet messaging event; Should not be subscribed to by OSEE applications. + * + * @author Jeff C. Phillips + */ +public class NetworkNewBranchEvent implements ISkynetEvent { + private static final long serialVersionUID = 8339596149601337894L; + private int branchId; + private int author; + + public NetworkNewBranchEvent(int branchId, int author) { + this.branchId = branchId; + this.author = author; + } + + public int getTransactionId() { + return 0; + } + + public int getBranchId() { + return branchId; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(T) + */ + public int compareTo(Object o) { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent#getAuthor() + */ + public int getAuthor() { + return author; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkRenameBranchEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkRenameBranchEvent.java new file mode 100644 index 00000000000..7ce285ac8e6 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/NetworkRenameBranchEvent.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * 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.skynet; + +/** + * Skynet messaging event; Should not be subscribed to by OSEE applications. + * + * @author Donald G. Dunne + */ +public class NetworkRenameBranchEvent implements ISkynetEvent { + private static final long serialVersionUID = 8339596149601997894L; + private int branchId; + private String branchName; + private String shortName; + private final int author; + + public NetworkRenameBranchEvent(int branchId, int author, String branchName, String shortName) { + this.branchId = branchId; + this.author = author; + this.branchName = branchName; + this.shortName = shortName; + } + + public int getTransactionId() { + return 0; + } + + public int getBranchId() { + return branchId; + } + + /* (non-Javadoc) + * @see java.lang.Comparable#compareTo(T) + */ + public int compareTo(Object o) { + return 0; + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent#getAuthor() + */ + public int getAuthor() { + return author; + } + + /** + * @return the branchName + */ + public String getBranchName() { + return branchName; + } + + /** + * @param branchName the branchName to set + */ + public void setBranchName(String branchName) { + this.branchName = branchName; + } + + /** + * @return the shortName + */ + public String getShortName() { + return shortName; + } + + /** + * @param shortName the shortName to set + */ + public void setShortName(String shortName) { + this.shortName = shortName; + } + + /** + * @param branchId the branchId to set + */ + public void setBranchId(int branchId) { + this.branchId = branchId; + } + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/Sample.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/Sample.java new file mode 100644 index 00000000000..a789cab3771 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/Sample.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.skynet; + +import java.io.Serializable; +import java.rmi.RemoteException; +import java.util.Date; +import org.eclipse.osee.framework.jini.discovery.IServiceLookupListener; +import org.eclipse.osee.framework.jini.discovery.ServiceDataStore; +import org.eclipse.osee.framework.jini.util.OseeJini; +import net.jini.core.lookup.ServiceItem; + +public class Sample implements IServiceLookupListener, Serializable { + private static final long serialVersionUID = 8195127334711471268L; + + private ISkynetEventService ses; + private ASkynetEventListener listener; + + public Sample() { + super(); + + listener = new EventEchoer(); + + // TODO this may take a very long time ... like FOREVER ... perform timeout ~5s if it is an absolutely necessary service + // ServiceDataStore.getEclipseInstance(EclipseJiniClassloader.getInstance()).addListener(this, ISkynetEventService.class); + ServiceDataStore.getNonEclipseInstance().addListener(this, ISkynetEventService.class); + + for (;;) { + try { + Thread.sleep(5000); + System.out.print(new Date() + ":"); + if (ses == null) { + System.out.println("Service not connected"); + } else { + System.out.println("kick"); + try { + // ses.kick(new ISkynetEvent[]{new RemoteArtifactModifiedEvent(1, 2, 3, 4, "bob")}, listener); + } catch (Exception e) { + e.printStackTrace(); + ses = null; + } + } + } catch (InterruptedException e) { + break; + } + } + } + + public void serviceAdded(ServiceItem serviceItem) { + ses = (ISkynetEventService) serviceItem.service; + try { + ses.register((ISkynetEventListener) OseeJini.getRemoteReference(listener)); + } catch (RemoteException e) { + e.printStackTrace(); + } + } + + public void serviceChanged(ServiceItem serviceItem) { + // like when the Entry[] changes + System.out.println("***Service changed"); + serviceAdded(serviceItem); + } + + public void serviceRemoved(ServiceItem serviceItem) { + // Ensure the lookup server didn't just lose contact + // try { + // ses.someStupidCallLikeGetId(); + // } catch(RemoteException ex) { + ses = null; + // } + + } + + public static void main(String[] args) { + new Sample(); + } + + private class EventEchoer extends ASkynetEventListener { + private static final long serialVersionUID = 2251382843127874925L; + + @Override + public void onEvent(ISkynetEvent[] events) throws RemoteException { + System.out.println("Events received at " + new Date()); + + for (ISkynetEvent event : events) + System.out.println("\t" + event); + } + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/SkynetEventPlugin.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/SkynetEventPlugin.java new file mode 100644 index 00000000000..beb86505c74 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/SkynetEventPlugin.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * 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.skynet; + +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; + +/** + * The main plugin class to be used in the desktop. + */ +public class SkynetEventPlugin extends OseeUiActivator { + + private static SkynetEventPlugin pluginInstance; // The shared instance. + public static final String PLUGIN_ID = "org.eclipse.osee.framework.messaging.event.skynet"; + + public SkynetEventPlugin() { + super(); + pluginInstance = this; + } + + /** + * Returns the shared instance. + */ + public static SkynetEventPlugin getInstance() { + return pluginInstance; + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/ConfigurationModifiedEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/ConfigurationModifiedEvent.java new file mode 100644 index 00000000000..784e8bb4862 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/ConfigurationModifiedEvent.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Robert A. Fisher + */ +public class ConfigurationModifiedEvent extends SkynetEventBase { + private static final long serialVersionUID = 4199206743701390599L; + + /** + * @param branchId + * @param transactionId + * @param author TODO + */ + public ConfigurationModifiedEvent(int branchId, int transactionId, int author) { + super(branchId, transactionId, author); + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkArtifactDeletedEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkArtifactDeletedEvent.java new file mode 100644 index 00000000000..6bc576a95a6 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkArtifactDeletedEvent.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Robert A. Fisher + */ +public class NetworkArtifactDeletedEvent extends SkynetArtifactEventBase { + private static final long serialVersionUID = 568951803773151575L; + + /** + * @param branchId + * @param transactionId + * @param artId + * @param artTypeId + * @param author TODO + */ + public NetworkArtifactDeletedEvent(int branchId, int transactionId, int artId, int artTypeId, String factoryName, int author) { + super(branchId, transactionId, artId, artTypeId, factoryName, author); + } + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkArtifactModifiedEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkArtifactModifiedEvent.java new file mode 100644 index 00000000000..dbc118d1d2b --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkArtifactModifiedEvent.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * 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.skynet.event; + +import java.util.Collection; + +/** + * @author Robert A. Fisher + */ +public class NetworkArtifactModifiedEvent extends SkynetArtifactEventBase { + private static final long serialVersionUID = -4325821466558180270L; + private Collection<SkynetAttributeChange> attributeValues; + + /** + * @param branchId + * @param transactionId + * @param artId + * @param artTypeId + * @param author TODO + */ + public NetworkArtifactModifiedEvent(int branchId, int transactionId, int artId, int artTypeId, String factoryName, Collection<SkynetAttributeChange> attributeValues, int author) { + super(branchId, transactionId, artId, artTypeId, factoryName, author); + + this.attributeValues = attributeValues; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof NetworkArtifactModifiedEvent) { + return (getArtId() == (((NetworkArtifactModifiedEvent) obj).getArtId())); + } + return super.equals(obj); + } + + @Override + public int hashCode() { + return getArtId(); + } + + /** + * @return Returns the serialVersionUID. + */ + public static long getSerialVersionUID() { + return serialVersionUID; + } + + /** + * @return Returns the attributeValues. + */ + public Collection<SkynetAttributeChange> getAttributeChanges() { + return attributeValues; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkBroadcastEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkBroadcastEvent.java new file mode 100644 index 00000000000..8c7066e13ce --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkBroadcastEvent.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Robert A. Fisher + */ +public class NetworkBroadcastEvent extends SkynetEventBase { + + private static final long serialVersionUID = 4199206432501390599L; + private String message; + + /** + * @param branchId + * @param transactionId + * @param author TODO + */ + public NetworkBroadcastEvent(int branchId, int transactionId, String message, int author) { + super(branchId, transactionId, author); + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkNewRelationLinkEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkNewRelationLinkEvent.java new file mode 100644 index 00000000000..f6cafa35684 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkNewRelationLinkEvent.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Jeff C. Phillips + */ +public class NetworkNewRelationLinkEvent extends SkynetRelationLinkEventBase { + + /** + * + */ + private static final long serialVersionUID = -519877422249674503L; + + private String rationale; + private String aGuid; + private String aHumanId; + private String bHumanId; + private String bGuid; + private String descriptorName; + private int aOrder; + private int bOrder; + private int relTypeId; + + /** + * @param branchId + * @param transactionId + * @param relId + * @param artAId + * @param artBId + * @param author TODO + */ + + public NetworkNewRelationLinkEvent(int gammaId, int branchId, int transactionId, Integer relId, int artAId, int artBId, String rationale, int aOrder, int bOrder, int relTypeId, String descriptorName, int author) { + super(relTypeId, gammaId, branchId, transactionId, relId, artAId, artBId, author); + + this.rationale = rationale; + this.aOrder = aOrder; + this.bOrder = bOrder; + this.relTypeId = relTypeId; + this.descriptorName = descriptorName; + } + + /** + * @return Returns the aOrder. + */ + public int getAOrder() { + return aOrder; + } + + /** + * @return Returns the bOrder. + */ + public int getBOrder() { + return bOrder; + } + + /** + * @return Returns the rationale. + */ + public String getRationale() { + return rationale; + } + + /** + * @return Returns the relTypeId. + */ + public int getRelTypeId() { + return relTypeId; + } + + /** + * @return Returns the aGuid. + */ + public String getAGuid() { + return aGuid; + } + + /** + * @return Returns the bGuid. + */ + public String getBGuid() { + return bGuid; + } + + /** + * @return Returns the aHuamnId. + */ + public String getAHumanId() { + return aHumanId; + } + + /** + * @return Returns the bHumanId. + */ + public String getBHumanId() { + return bHumanId; + } + + public String getDescriptorName() { + return descriptorName; + } + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkRelationLinkDeletedEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkRelationLinkDeletedEvent.java new file mode 100644 index 00000000000..c123578ce23 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkRelationLinkDeletedEvent.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Robert A. Fisher + */ +public class NetworkRelationLinkDeletedEvent extends SkynetRelationLinkEventBase { + private static final long serialVersionUID = -1451567913757261791L; + + public NetworkRelationLinkDeletedEvent(int relTypeId, int gammaId, int branchId, int transactionId, int relId, int artAId, int artBId, int author) { + super(relTypeId, gammaId, branchId, transactionId, relId, artAId, artBId, author); + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkRelationLinkModifiedEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkRelationLinkModifiedEvent.java new file mode 100644 index 00000000000..ef28fa3870a --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/NetworkRelationLinkModifiedEvent.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Robert A. Fisher + */ +public class NetworkRelationLinkModifiedEvent extends SkynetRelationLinkEventBase { + private static final long serialVersionUID = 548299278567054333L; + + private String rationale; + int aOrder; + int bOrder; + + /** + * @param branchId + * @param transactionId + * @param relId + * @param artAId + * @param artBId + * @param author + * @param relTypeId + */ + public NetworkRelationLinkModifiedEvent(int gammaId, int branchId, int transactionId, int relId, int artAId, int artBId, String rationale, int aOrder, int bOrder, int author, int relTypeId) { + super(relTypeId, gammaId, branchId, transactionId, relId, artAId, artBId, author); + + this.rationale = rationale; + this.aOrder = aOrder; + this.bOrder = bOrder; + } + + /** + * @return Returns the aOrder. + */ + public int getAOrder() { + return aOrder; + } + + /** + * @return Returns the bOrder. + */ + public int getBOrder() { + return bOrder; + } + + /** + * @return Returns the rationale. + */ + public String getRationale() { + return rationale; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof NetworkRelationLinkModifiedEvent) { + return (getRelId() == (((NetworkRelationLinkModifiedEvent) obj).getRelId())); + } + return super.equals(obj); + } + + @Override + public int hashCode() { + return getRelId(); + } + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetArtifactEventBase.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetArtifactEventBase.java new file mode 100644 index 00000000000..aba6b9b1283 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetArtifactEventBase.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.skynet.event; + +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetArtifactEvent; + +/** + * @author Robert A. Fisher + */ +public class SkynetArtifactEventBase extends SkynetEventBase implements ISkynetArtifactEvent { + private static final long serialVersionUID = 7923550763258313718L; + + private final int artId; + private final int artTypeId; + private final String factoryName; + + /** + * @param branchId + * @param transactionId + * @param artId + * @param artTypeId + * @param author TODO + */ + public SkynetArtifactEventBase(int branchId, int transactionId, int artId, int artTypeId, String factoryName, int author) { + super(branchId, transactionId, author); + + this.artId = artId; + this.artTypeId = artTypeId; + this.factoryName = factoryName; + } + + /** + * @return Returns the artId. + */ + public int getArtId() { + return artId; + } + + /** + * @return Returns the artTypeId. + */ + public int getArtTypeId() { + return artTypeId; + } + + public String getFactoryName() { + return factoryName; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetAttributeChange.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetAttributeChange.java new file mode 100644 index 00000000000..f605d6bbfd4 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetAttributeChange.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * @author Jeff C. Phillips + */ +public class SkynetAttributeChange implements SkynetChange { + private static final long serialVersionUID = 7269483275150734396L; + private final String name; + private final int attributeId; + private final int gammaId; + private final Object[] value; + + /** + * @param name + * @param value + */ + public SkynetAttributeChange(String name, Object[] value, int attributeId, int gammaId) { + super(); + this.name = name; + this.value = value; + this.attributeId = attributeId; + this.gammaId = gammaId; + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + /** + * @return Returns the value. + */ + public Object[] getData() { + return value; + } + + public int getAttributeId() { + return attributeId; + } + + /** + * @return Returns the gammaId. + */ + public int getGammaId() { + return gammaId; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetChange.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetChange.java new file mode 100644 index 00000000000..9491277abbe --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetChange.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.skynet.event; + +import java.io.Serializable; + +/** + * @author Jeff C. Phillips + */ +public interface SkynetChange extends Serializable { + +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetDisconnectClientsEvent.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetDisconnectClientsEvent.java new file mode 100644 index 00000000000..0ff31ec5824 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetDisconnectClientsEvent.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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.skynet.event; + +/** + * This message will be issued by the skynet event service to all clients in order to disconnect them from the network. + * This message should only be issued by administrators. + * + * @author Roberto E. Escobar + */ +public class SkynetDisconnectClientsEvent extends NetworkBroadcastEvent { + + private static final long serialVersionUID = -3159755675253937318L; + private String[] userIds; + + public SkynetDisconnectClientsEvent(String[] userIds, int branchId, int transactionId, String reason, int author) { + super(branchId, transactionId, reason, author); + this.userIds = userIds; + } + + public String[] getUserIds() { + return userIds; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetEventBase.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetEventBase.java new file mode 100644 index 00000000000..e5a58111fa1 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetEventBase.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.skynet.event; + +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent; + +/** + * @author Robert A. Fisher + */ +public class SkynetEventBase implements ISkynetEvent { + private static final long serialVersionUID = -5381855085551886510L; + + private final int branchId; + private final int transactionId; + private final int author; + + /** + * @param branchId + * @param transactionId + * @param author TODO + */ + public SkynetEventBase(int branchId, int transactionId, int author) { + this.branchId = branchId; + this.transactionId = transactionId; + this.author = author; + } + + /** + * @return Returns the branchId. + */ + public int getBranchId() { + return branchId; + } + + /** + * @return Returns the transactionId. + */ + public int getTransactionId() { + return transactionId; + } + + public int compareTo(Object o) { + + if (o instanceof NetworkArtifactDeletedEvent) { + return 1; + } else if (o instanceof SkynetArtifactEventBase) { + return 1; + } else { + return -1; + } + } + + /* (non-Javadoc) + * @see org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent#getAuthor() + */ + public int getAuthor() { + return author; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetRelationLinkEventBase.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetRelationLinkEventBase.java new file mode 100644 index 00000000000..a5e511412df --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/event/SkynetRelationLinkEventBase.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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.skynet.event; + +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetRelationLinkEvent; + +/** + * @author Robert A. Fisher + */ +public class SkynetRelationLinkEventBase extends SkynetEventBase implements ISkynetRelationLinkEvent { + private static final long serialVersionUID = 154870900652138769L; + + private final Integer relId; + private final int relTypeId; + private final int artAId; + private final int artBId; + private int gammaId; + + /** + * @param branchId + * @param transactionId + * @param relId + * @param artAId + * @param artBId + * @param author TODO + */ + public SkynetRelationLinkEventBase(int relTypeId, int gammaId, int branchId, int transactionId, Integer relId, int artAId, int artBId, int author) { + super(branchId, transactionId, author); + this.relId = relId; + this.artAId = artAId; + this.artBId = artBId; + this.gammaId = gammaId; + this.relTypeId = relTypeId; + } + + /** + * @return Returns the artAId. + */ + public int getArtAId() { + return artAId; + } + + /** + * @return Returns the artBId. + */ + public int getArtBId() { + return artBId; + } + + /** + * @return Returns the relId. + */ + public Integer getRelId() { + return relId; + } + + public Integer getGammaId() { + return gammaId; + } + + /** + * @return the relTypeId + */ + public int getRelTypeId() { + return relTypeId; + } +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/filter/IEventFilter.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/filter/IEventFilter.java new file mode 100644 index 00000000000..015de98fca4 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/filter/IEventFilter.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.skynet.filter; + +import java.io.Serializable; +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent; + +/** + * @author Robert A. Fisher + */ +public interface IEventFilter extends Serializable { + + /** + * Determine if the event meets the requirement of this filter. + * + * @param event The event to inspect. + * @return boolean + */ + public boolean accepts(ISkynetEvent event); +} diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/service/SkynetEventService.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/service/SkynetEventService.java new file mode 100644 index 00000000000..1e2e88a7859 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/service/SkynetEventService.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * 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.skynet.service; + +import java.rmi.RemoteException; +import java.util.Collection; +import java.util.Dictionary; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.logging.Level; +import java.util.logging.Logger; +import net.jini.core.entry.Entry; +import net.jini.lookup.entry.Comment; +import net.jini.lookup.entry.Name; +import net.jini.lookup.entry.ServiceInfo; +import org.eclipse.osee.framework.jdk.core.type.HashCollection; +import org.eclipse.osee.framework.jini.JiniClassServer; +import org.eclipse.osee.framework.jini.service.core.JiniService; +import org.eclipse.osee.framework.jini.service.core.SimpleFormattedEntry; +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetEvent; +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetEventListener; +import org.eclipse.osee.framework.messaging.event.skynet.ISkynetEventService; +import org.eclipse.osee.framework.messaging.event.skynet.SkynetEventPlugin; +import org.eclipse.osee.framework.messaging.event.skynet.filter.IEventFilter; +import org.eclipse.osee.framework.plugin.core.config.ConfigUtil; +import org.eclipse.osee.framework.plugin.core.server.BundleResourceFinder; +import org.eclipse.osee.framework.ui.plugin.OseeUiActivator; + +/** + * Skynet Event Service handles event distribution to provide network assisted cache consistency for Skynet. + * + * @author Robert A. Fisher + */ +public class SkynetEventService extends JiniService implements ISkynetEventService { + private static final Logger logger = ConfigUtil.getConfigFactory().getLogger(SkynetEventService.class); + + private final HashCollection<IEventFilter, ISkynetEventListener> filteredListeners; + private final ReadWriteLock filteredListenersLock; + private final Collection<ISkynetEventListener> nonfilteredListeners; + private final ReadWriteLock nonfilteredListenersLock; + private static JiniClassServer jiniClassServer; + + protected SkynetEventService(String dbConfig) { + this.filteredListeners = new HashCollection<IEventFilter, ISkynetEventListener>(); + this.nonfilteredListeners = new LinkedList<ISkynetEventListener>(); + this.filteredListenersLock = new ReentrantReadWriteLock(); + this.nonfilteredListenersLock = new ReentrantReadWriteLock(); + try { + registerWithJini(dbConfig); + } catch (Exception ex) { + logger.log(Level.SEVERE, ex.toString(), ex); + } + } + + @SuppressWarnings("unchecked") + private void registerWithJini(String dbConfig) throws Exception { + jiniClassServer = JiniClassServer.getInstance(); + jiniClassServer.addResourceFinder(new BundleResourceFinder(new String[] { + "org.eclipse.osee.framework.messaging.event.skynet", "org.eclipse.osee.framework.jdk.core"})); + + Dictionary dictionary = null; + String name = "Skynet Event Service"; + String manufacturer = "Eclipse.org"; + String vendor = "Eclipse.org"; + String version = "0.0"; + String model = "SES"; + String serialNumber = "0.0"; + String description = "Skynet Event Service - Skynet Cache Network Manager"; + + OseeUiActivator plugin = SkynetEventPlugin.getInstance(); + if (plugin != null) { + dictionary = plugin.getBundle().getHeaders(); + } + + this.registerService(new Entry[] {new SimpleFormattedEntry("db", dbConfig), + new ServiceInfo(name, manufacturer, vendor, version, model, serialNumber), new Name(name), + new Comment(description)}, dictionary); + + System.out.println("....................Skynet Event Service(" + dbConfig + ") is Alive...................."); + this.stayAlive(); + } + + public void register(ISkynetEventListener listener, IEventFilter... filters) throws RemoteException { + + if (listener == null) { + System.out.println("the listener is null"); + return; + } + + if (filters.length == 0) { + nonfilteredListenersLock.writeLock().lock(); + try { + nonfilteredListeners.add(listener); + } finally { + nonfilteredListenersLock.writeLock().unlock(); + } + } else { + filteredListenersLock.writeLock().lock(); + try { + for (IEventFilter filter : filters) { + filteredListeners.put(filter, listener); + } + } finally { + filteredListenersLock.writeLock().unlock(); + } + } + } + + public void deregister(ISkynetEventListener listener, IEventFilter... filters) throws RemoteException { + if (filters.length == 0) { + nonfilteredListenersLock.writeLock().lock(); + try { + nonfilteredListeners.remove(listener); + } finally { + nonfilteredListenersLock.writeLock().unlock(); + } + } else { + filteredListenersLock.writeLock().lock(); + try { + for (IEventFilter filter : filters) { + filteredListeners.removeValue(filter, listener); + } + } finally { + filteredListenersLock.writeLock().unlock(); + } + } + } + + // TODO thread pool this guy + public void kick(final ISkynetEvent[] events, final ISkynetEventListener... except) throws RemoteException { + Thread thread = new Thread("kicker") { + + @Override + public void run() { + HashCollection<ISkynetEventListener, ISkynetEvent> eventSets = + new HashCollection<ISkynetEventListener, ISkynetEvent>(false, HashSet.class); + HashSet<ISkynetEventListener> exceptList = + new HashSet<ISkynetEventListener>((int) (except.length / .75f) + 1, .75f); + for (ISkynetEventListener listener : except) + exceptList.add(listener); + + nonfilteredListenersLock.readLock().lock(); + try { + // The non-filtered listeners will receive all events by definition + for (ISkynetEventListener listener : nonfilteredListeners) + for (ISkynetEvent event : events) + if (!exceptList.contains(listener)) eventSets.put(listener, event); + } finally { + nonfilteredListenersLock.readLock().unlock(); + } + + // Build sets according to the filters that the event matches + + filteredListenersLock.readLock().lock(); + try { + // Iterate all of the filters that have mappings to listeners + for (IEventFilter filter : filteredListeners.keySet()) + // Check each event against a particular filter + for (ISkynetEvent event : events) + if (filter.accepts(event)) + // When a filter accepts an event, the event to everyone listening for it + for (ISkynetEventListener listener : filteredListeners.getValues(filter)) + if (!exceptList.contains(listener)) eventSets.put(listener, event); + } finally { + filteredListenersLock.readLock().unlock(); + } + + // Kick all of the listeners with their set of events + for (ISkynetEventListener listener : eventSets.keySet()) + try { + + if (listener != null) listener.onEvent(eventSets.getValues(listener).toArray(ISkynetEvent.EMPTY_ARRAY)); + + } catch (Exception ex) { + + // TODO Remove from filteredListeners + + nonfilteredListeners.remove(listener); + logger.log(Level.SEVERE, ex.toString(), ex); + } + } + + }; + + thread.setPriority(Thread.MIN_PRIORITY); + thread.start(); + } + + public static void main(String[] args) { + if (args.length != 2) throw new IllegalArgumentException( + "Must supply the db name for the service, such as \"dbinstance:schema\""); + + new SkynetEventService(args[1]); + } + + public void kill() throws RemoteException { + this.deregisterService(); + this.commitSuicide(); + } + + public boolean isAlive() throws RemoteException { + return true; + } +}
\ No newline at end of file diff --git a/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/service/SkynetEventServicePlatformRunnable.java b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/service/SkynetEventServicePlatformRunnable.java new file mode 100644 index 00000000000..cf763c99412 --- /dev/null +++ b/org.eclipse.osee.framework.messaging.event.skynet/src/org/eclipse/osee/framework/messaging/event/skynet/service/SkynetEventServicePlatformRunnable.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * 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.skynet.service; + +import java.rmi.RemoteException; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.eclipse.core.runtime.Platform; +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.osee.framework.jdk.core.util.CmdLineArgs; +import org.eclipse.osee.framework.jdk.core.util.OseeProperties; +import org.eclipse.osee.framework.plugin.core.config.ConfigUtil; +import org.eclipse.osee.framework.plugin.core.config.HeadlessEclipseConfigurationFactory; + +/** + * @author Robert A. Fisher + */ +public class SkynetEventServicePlatformRunnable implements IApplication { + + private static final Logger logger = + ConfigUtil.getConfigFactory().getLogger(SkynetEventServicePlatformRunnable.class); + private SkynetEventService skynetEventService; + + public SkynetEventServicePlatformRunnable() { + super(); + skynetEventService = null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) throws Exception { + System.setProperty(OseeProperties.OSEE_CONFIG_FACTORY, HeadlessEclipseConfigurationFactory.class.getName()); + + CmdLineArgs commandArgs = new CmdLineArgs(Platform.getApplicationArgs()); + + String database = commandArgs.get("-database"); + skynetEventService = new SkynetEventService(database); + return EXIT_OK; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + try { + skynetEventService.kill(); + } catch (RemoteException ex) { + logger.log(Level.SEVERE, ex.toString(), ex); + } + } +} |