Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-08-29 16:39:01 -0400
committerslewis2009-08-29 16:39:01 -0400
commit1851ce0cc75aa6a0dea1dac76ac40e39c4253c38 (patch)
tree4e8f0f9b18e2d5c8122df3553bbb681301f9af8a
parentbbefc1568f2da27c2d9b55e1f49326d165403a87 (diff)
downloadorg.eclipse.ecf-1851ce0cc75aa6a0dea1dac76ac40e39c4253c38.tar.gz
org.eclipse.ecf-1851ce0cc75aa6a0dea1dac76ac40e39c4253c38.tar.xz
org.eclipse.ecf-1851ce0cc75aa6a0dea1dac76ac40e39c4253c38.zip
Initial checkin of distributed EventAdmin implementation.
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.classpath7
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.project34
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.jdt.core.prefs74
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.api.tools.prefs91
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/META-INF/MANIFEST.MF17
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/about.html28
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/build.properties9
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/bundle.properties10
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/internal/remoteservice/eventadmin/DistributedEventAdminMessage.java49
-rw-r--r--server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/remoteservice/eventadmin/DistributedEventAdmin.java238
11 files changed, 561 insertions, 0 deletions
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.classpath b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.classpath
new file mode 100644
index 000000000..6f3b481ac
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.1%Foundation-1.1"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.project b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.project
new file mode 100644
index 000000000..af0dbc0ea
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.remoteservice.eventadmin</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>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.jdt.core.prefs b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..905debea9
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,74 @@
+#Fri Aug 07 15:35:21 PDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+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.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.api.tools.prefs b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.api.tools.prefs
new file mode 100644
index 000000000..7ed800c3e
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.api.tools.prefs
@@ -0,0 +1,91 @@
+#Fri Aug 07 15:34:58 PDT 2009
+ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error
+ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error
+CLASS_ELEMENT_TYPE_ADDED_METHOD=Error
+CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error
+CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error
+CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error
+CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error
+ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error
+ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error
+ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+FIELD_ELEMENT_TYPE_ADDED_VALUE=Error
+FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error
+FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error
+FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error
+FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error
+ILLEGAL_EXTEND=Warning
+ILLEGAL_IMPLEMENT=Warning
+ILLEGAL_INSTANTIATE=Warning
+ILLEGAL_OVERRIDE=Warning
+ILLEGAL_REFERENCE=Warning
+INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+INVALID_JAVADOC_TAG=Ignore
+INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Ignore
+LEAK_EXTEND=Warning
+LEAK_FIELD_DECL=Warning
+LEAK_IMPLEMENT=Warning
+LEAK_METHOD_PARAM=Warning
+LEAK_METHOD_RETURN_TYPE=Warning
+METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
+METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
+UNUSED_PROBLEM_FILTERS=Warning
+eclipse.preferences.version=1
+incompatible_api_component_version=Error
+incompatible_api_component_version_include_major_without_breaking_change=Disabled
+incompatible_api_component_version_include_minor_without_api_change=Disabled
+invalid_since_tag_version=Error
+malformed_since_tag=Error
+missing_since_tag=Error
+report_api_breakage_when_major_version_incremented=Disabled
+report_resolution_errors_api_component=Warning
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.core.prefs b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..08321d98a
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Fri Aug 07 15:31:09 PDT 2009
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/META-INF/MANIFEST.MF b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..3824e38f9
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ECF Distributed EventAdmin Service
+Bundle-SymbolicName: org.eclipse.ecf.remoteservice.eventadmin
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: Eclipse.org-ECF
+Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1
+Bundle-Localization: bundle
+Import-Package: org.eclipse.ecf.core.identity;version="3.0.0",
+ org.eclipse.ecf.core.sharedobject,
+ org.eclipse.equinox.concurrent.future;version="1.0.0",
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.event;version="1.2.0",
+ org.osgi.util.tracker;version="1.4.2"
+Require-Bundle: org.eclipse.equinox.common;bundle-version="3.5.0"
+Export-Package: org.eclipse.ecf.internal.remoteservice.eventadmin;x-internal:=true,
+ org.eclipse.ecf.remoteservice.eventadmin
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/about.html b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/about.html
new file mode 100644
index 000000000..4c79781a5
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 25, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/build.properties b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/build.properties
new file mode 100644
index 000000000..f72f2b8b5
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/build.properties
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ bundle.properties,\
+ about.html
+src.includes = bundle.properties,\
+ META-INF/,\
+ about.html
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/bundle.properties b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/bundle.properties
new file mode 100644
index 000000000..de1d72435
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/bundle.properties
@@ -0,0 +1,10 @@
+#################################################################################
+# Copyright (c) 2009 EclipseSource and others. 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
+#
+# Contributors:
+# EclipseSource - initial API and implementation
+#################################################################################
+bundleName=ECF RemoteServices EventAdmin Example
+bundleProvider=Eclipse.org - ECF \ No newline at end of file
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/internal/remoteservice/eventadmin/DistributedEventAdminMessage.java b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/internal/remoteservice/eventadmin/DistributedEventAdminMessage.java
new file mode 100644
index 000000000..ff13c3b28
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/internal/remoteservice/eventadmin/DistributedEventAdminMessage.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. 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:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.ecf.internal.remoteservice.eventadmin;
+
+import java.io.NotSerializableException;
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.osgi.service.event.Event;
+
+public class DistributedEventAdminMessage implements Serializable {
+
+ private static final long serialVersionUID = 2743430591605178391L;
+ private String topic;
+ private Map properties;
+
+ private transient Event localEvent;
+
+ public DistributedEventAdminMessage(Event event) throws NotSerializableException {
+ this.topic = event.getTopic();
+ this.properties = createPropertiesFromEvent(event);
+ }
+
+ private Map createPropertiesFromEvent(Event event) throws NotSerializableException {
+ String[] propertyNames = event.getPropertyNames();
+ Hashtable ht = (propertyNames == null)?new Hashtable(1):new Hashtable(propertyNames.length);
+ for(int i=0; i < propertyNames.length; i++) {
+ Object val = event.getProperty(propertyNames[i]);
+ if (!(val instanceof Serializable)) throw new NotSerializableException("Cannot serialize property value of name="+propertyNames[i]+", value="+val);
+ ht.put(propertyNames[i], val);
+ }
+ return ht;
+ }
+
+ public synchronized Event getEvent() {
+ if (localEvent == null) {
+ localEvent = new Event(topic,properties);
+ }
+ return localEvent;
+ }
+}
diff --git a/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/remoteservice/eventadmin/DistributedEventAdmin.java b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/remoteservice/eventadmin/DistributedEventAdmin.java
new file mode 100644
index 000000000..714f7481e
--- /dev/null
+++ b/server-side/bundles/org.eclipse.ecf.remoteservice.eventadmin/src/org/eclipse/ecf/remoteservice/eventadmin/DistributedEventAdmin.java
@@ -0,0 +1,238 @@
+/*******************************************************************************
+ * Copyright (c) 2009 EclipseSource and others. 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:
+ * EclipseSource - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.remoteservice.eventadmin;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.sharedobject.BaseSharedObject;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
+import org.eclipse.ecf.core.sharedobject.SharedObjectAddException;
+import org.eclipse.ecf.core.sharedobject.SharedObjectMsg;
+import org.eclipse.ecf.internal.remoteservice.eventadmin.DistributedEventAdminMessage;
+import org.eclipse.equinox.concurrent.future.IExecutor;
+import org.eclipse.equinox.concurrent.future.IProgressRunnable;
+import org.eclipse.equinox.concurrent.future.ThreadsExecutor;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventConstants;
+import org.osgi.service.event.EventHandler;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class DistributedEventAdmin extends BaseSharedObject implements EventAdmin {
+
+ private BundleContext context;
+
+ private ServiceTracker eventHandlerServiceTracker;
+ private final Object eventHandlerSTLock = new Object();
+
+ private IExecutor executor;
+
+ private String topic;
+ private ID topicID;
+
+ public DistributedEventAdmin(BundleContext context, String topic, IExecutor executor) {
+ this.context = context;
+ Assert.isNotNull(this.context);
+ this.topic = topic;
+ Assert.isNotNull(this.topic);
+ this.topicID = IDFactory.getDefault().createStringID(getTopic());
+ this.executor = (executor == null)?new ThreadsExecutor():executor;
+ }
+
+ public DistributedEventAdmin(BundleContext context, String topic) {
+ this(context,topic,null);
+ }
+
+ public String getTopic() {
+ return topic;
+ }
+
+ public ID getTopicID() {
+ return topicID;
+ }
+
+ public void addToContainer(ISharedObjectContainer soContainer) throws SharedObjectAddException {
+ soContainer.getSharedObjectManager().addSharedObject(topicID, this, null);
+ }
+
+ public void removeFromContainer(ISharedObjectContainer soContainer) {
+ soContainer.getSharedObjectManager().removeSharedObject(getTopicID());
+ }
+
+ public ServiceRegistration register(Properties props) {
+ if (props == null) props = new Properties();
+ props.put(EventConstants.EVENT_TOPIC, getTopic());
+ return this.context.registerService(EventAdmin.class.getName(), this, props);
+ }
+
+ public ServiceRegistration register() {
+ return register(null);
+ }
+
+ public void dispose() {
+ if (eventHandlerServiceTracker != null) {
+ eventHandlerServiceTracker.close();
+ eventHandlerServiceTracker = null;
+ }
+ topic = null;
+ topicID = null;
+ executor = null;
+ }
+
+ public void postEvent(final Event event) {
+ try {
+ sendSharedObjectMsgTo(null, SharedObjectMsg.createMsg(
+ "handlePostEvent", new DistributedEventAdminMessage(event)));
+ localPostEvent(event);
+ } catch (IOException e) {
+ logError("postEvent exception event=" + event + " not sent.", e);
+ }
+ }
+
+ public void sendEvent(Event event) {
+ try {
+ sendSharedObjectMsgTo(null, SharedObjectMsg.createMsg(
+ "handleSendEvent", new DistributedEventAdminMessage(event)));
+ localSendEvent(event);
+ } catch (IOException e) {
+ logError("sendEvent exception event=" + event + " not sent.", e);
+ }
+ }
+
+ private ServiceReference[] getEventHandlerServiceReferences(Event event) {
+ synchronized (eventHandlerSTLock) {
+ if (eventHandlerServiceTracker == null) {
+ eventHandlerServiceTracker = new ServiceTracker(context,
+ EventHandler.class.getName(), null);
+ eventHandlerServiceTracker.open();
+ }
+ ServiceReference[] refs = eventHandlerServiceTracker
+ .getServiceReferences();
+ List results = new ArrayList();
+ if (refs == null)
+ return null;
+ for (int i = 0; i < refs.length; i++) {
+ String eventFilter = (String) refs[i]
+ .getProperty(EventConstants.EVENT_FILTER);
+ Filter filter = null;
+ if (eventFilter != null) {
+ try {
+ filter = context.createFilter(eventFilter);
+ if (event.matches(filter))
+ results.add(refs[i]);
+ } catch (InvalidSyntaxException e) {
+ logError("getEventHandlers eventFilter=" + eventFilter,
+ e);
+ continue;
+ }
+ } else
+ results.add(refs[i]);
+ }
+ return (ServiceReference[]) results
+ .toArray(new ServiceReference[] {});
+ }
+ }
+
+ protected boolean handleSharedObjectMsg(SharedObjectMsg msg) {
+ try {
+ msg.invoke(this);
+ return true;
+ } catch (final Exception e) {
+ logError("handleSharedObjectMsg invoke error on msg=" + msg, e);
+ }
+ return false;
+ }
+
+ private void localSendEvent(Event event) {
+ ServiceReference[] eventHandlerRefs = getEventHandlerServiceReferences(event);
+ if (eventHandlerRefs == null) {
+ logWarning("sendEvent event=" + event
+ + ". No service references found to post to.");
+ return;
+ }
+ // Now synchronously call every eventhandler
+ for (int i = 0; i < eventHandlerRefs.length; i++)
+ callSync(eventHandlerRefs[i], (EventHandler) context
+ .getService(eventHandlerRefs[i]), event);
+
+ }
+
+ private void localPostEvent(Event event) {
+ ServiceReference[] refs = getEventHandlerServiceReferences(event);
+ if (refs == null) {
+ logWarning("localPostEvent event=" + event
+ + ". No service references found to post to.");
+ return;
+ }
+ for (int i = 0; i < refs.length; i++)
+ fireAsync(refs[i], (EventHandler) context.getService(refs[i]),
+ event);
+ }
+
+ void handlePostEvent(DistributedEventAdminMessage event) {
+ localPostEvent(event.getEvent());
+ }
+
+ void handleSendEvent(DistributedEventAdminMessage event) {
+ localSendEvent(event.getEvent());
+ }
+
+ protected void logWarning(String string) {
+ System.out.println(string);
+ }
+
+ protected void callSync(final ServiceReference serviceReference,
+ final EventHandler eventHandler, final Event event) {
+ SafeRunner.run(new ISafeRunnable() {
+ public void handleException(Throwable exception) {
+ logError(
+ "Exception in EventHandler.handleEvent. eventHandler="
+ + eventHandler + ". serviceReference="
+ + serviceReference + ". event=" + event,
+ exception);
+ }
+
+ public void run() throws Exception {
+ eventHandler.handleEvent(event);
+ }
+ });
+ }
+
+ protected void fireAsync(final ServiceReference serviceReference,
+ final EventHandler eventHandler, final Event event) {
+ executor.execute(new IProgressRunnable() {
+ public Object run(IProgressMonitor arg0) throws Exception {
+ eventHandler.handleEvent(event);
+ return null;
+ }
+ }, null);
+ }
+
+ protected void logError(String string, Throwable e) {
+ System.err.println(string);
+ if (e != null)
+ e.printStackTrace(System.err);
+ }
+
+}

Back to the top