Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.classpath7
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.project34
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.pde.core.prefs4
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Client.product56
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Manager.product56
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/META-INF/MANIFEST.MF22
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/about.html28
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/build.properties11
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/bundle.properties10
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/plugin.xml29
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/AbstractEventAdminApplication.java148
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/Activator.java29
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminClientApplication.java64
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminManagerApplication.java66
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestEventHandler.java23
-rw-r--r--examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestSender.java59
17 files changed, 653 insertions, 0 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.classpath b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.classpath
new file mode 100644
index 000000000..6f3b481ac
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.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/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.project b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.project
new file mode 100644
index 000000000..d521eb7e5
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.examples.eventadmin.app</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/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..519a6e7e2
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Wed Jun 10 10:27:34 PDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.pde.core.prefs b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.pde.core.prefs
new file mode 100644
index 000000000..8223ddf93
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Wed Jun 10 10:33:18 PDT 2009
+eclipse.preferences.version=1
+pluginProject.extensions=true
+resolve.requirebundle=false
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Client.product b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Client.product
new file mode 100644
index 000000000..271feee2c
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Client.product
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="EventAdmin Client" uid="org.eclipse.ecf.examples.eventadmin.app.client" application="org.eclipse.ecf.examples.eventadmin.app.EventAdminClient" version="1.0.0" useFeatures="false" includeLaunchers="true">
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <launcher>
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+ <vm>
+ </vm>
+
+ <plugins>
+ <plugin id="org.eclipse.core.contenttype"/>
+ <plugin id="org.eclipse.core.jobs"/>
+ <plugin id="org.eclipse.core.runtime"/>
+ <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
+ <plugin id="org.eclipse.ecf"/>
+ <plugin id="org.eclipse.ecf.datashare"/>
+ <plugin id="org.eclipse.ecf.discovery"/>
+ <plugin id="org.eclipse.ecf.examples.eventadmin"/>
+ <plugin id="org.eclipse.ecf.examples.eventadmin.app"/>
+ <plugin id="org.eclipse.ecf.identity"/>
+ <plugin id="org.eclipse.ecf.provider"/>
+ <plugin id="org.eclipse.ecf.provider.datashare"/>
+ <plugin id="org.eclipse.ecf.provider.jms"/>
+ <plugin id="org.eclipse.ecf.provider.jms.activemq"/>
+ <plugin id="org.eclipse.ecf.provider.remoteservice"/>
+ <plugin id="org.eclipse.ecf.remoteservice"/>
+ <plugin id="org.eclipse.ecf.sharedobject"/>
+ <plugin id="org.eclipse.ecf.ssl" fragment="true"/>
+ <plugin id="org.eclipse.equinox.app"/>
+ <plugin id="org.eclipse.equinox.common"/>
+ <plugin id="org.eclipse.equinox.concurrent"/>
+ <plugin id="org.eclipse.equinox.preferences"/>
+ <plugin id="org.eclipse.equinox.registry"/>
+ <plugin id="org.eclipse.osgi"/>
+ <plugin id="org.eclipse.osgi.services"/>
+ </plugins>
+
+ <configurations>
+ <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
+ <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
+ </configurations>
+
+</product>
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Manager.product b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Manager.product
new file mode 100644
index 000000000..95d5c1ede
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/EventAdmin Manager.product
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="EventAdmin Manager" uid="org.eclipse.ecf.examples.eventadmin.app.manager" application="org.eclipse.ecf.examples.eventadmin.app.EventAdminManager" version="1.0.0" useFeatures="false" includeLaunchers="true">
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <launcher>
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+ <vm>
+ </vm>
+
+ <plugins>
+ <plugin id="org.eclipse.core.contenttype"/>
+ <plugin id="org.eclipse.core.jobs"/>
+ <plugin id="org.eclipse.core.runtime"/>
+ <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
+ <plugin id="org.eclipse.ecf"/>
+ <plugin id="org.eclipse.ecf.datashare"/>
+ <plugin id="org.eclipse.ecf.discovery"/>
+ <plugin id="org.eclipse.ecf.examples.eventadmin"/>
+ <plugin id="org.eclipse.ecf.examples.eventadmin.app"/>
+ <plugin id="org.eclipse.ecf.identity"/>
+ <plugin id="org.eclipse.ecf.provider"/>
+ <plugin id="org.eclipse.ecf.provider.datashare"/>
+ <plugin id="org.eclipse.ecf.provider.jms"/>
+ <plugin id="org.eclipse.ecf.provider.jms.activemq"/>
+ <plugin id="org.eclipse.ecf.provider.remoteservice"/>
+ <plugin id="org.eclipse.ecf.remoteservice"/>
+ <plugin id="org.eclipse.ecf.sharedobject"/>
+ <plugin id="org.eclipse.ecf.ssl" fragment="true"/>
+ <plugin id="org.eclipse.equinox.app"/>
+ <plugin id="org.eclipse.equinox.common"/>
+ <plugin id="org.eclipse.equinox.concurrent"/>
+ <plugin id="org.eclipse.equinox.preferences"/>
+ <plugin id="org.eclipse.equinox.registry"/>
+ <plugin id="org.eclipse.osgi"/>
+ <plugin id="org.eclipse.osgi.services"/>
+ </plugins>
+
+ <configurations>
+ <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
+ <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
+ </configurations>
+
+</product>
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/META-INF/MANIFEST.MF b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..bdc093094
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/META-INF/MANIFEST.MF
@@ -0,0 +1,22 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.eclipse.ecf.examples.eventadmin.app;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.ecf.examples.internal.eventadmin.app.Activator
+Bundle-Vendor: %bundleProvider
+Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1,
+ J2SE-1.4
+Import-Package: org.eclipse.ecf.core;version="3.0.0",
+ org.eclipse.ecf.core.identity,
+ org.eclipse.ecf.core.sharedobject,
+ org.eclipse.ecf.core.util,
+ org.eclipse.equinox.app;version="1.0.0",
+ 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
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: bundle
+Require-Bundle: org.eclipse.ecf.examples.eventadmin;bundle-version="1.0.0",
+ org.eclipse.equinox.common;bundle-version="3.5.0"
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/about.html b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/about.html
new file mode 100644
index 000000000..4c79781a5
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/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/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/build.properties b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/build.properties
new file mode 100644
index 000000000..a837611ef
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/build.properties
@@ -0,0 +1,11 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ bundle.properties,\
+ plugin.xml
+src.includes = about.html,\
+ META-INF/,\
+ src/,\
+ bundle.properties
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/bundle.properties b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/bundle.properties
new file mode 100644
index 000000000..41ccdcaa4
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/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 Host
+bundleProvider=Eclipse.org - ECF \ No newline at end of file
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/plugin.xml b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/plugin.xml
new file mode 100644
index 000000000..59c9bdcdd
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/plugin.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ id="EventAdminManager"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ cardinality="singleton-global"
+ thread="main"
+ visible="true">
+ <run
+ class="org.eclipse.ecf.examples.internal.eventadmin.app.EventAdminManagerApplication">
+ </run>
+ </application>
+ </extension>
+ <extension
+ id="EventAdminClient"
+ point="org.eclipse.core.runtime.applications">
+ <application
+ cardinality="singleton-global"
+ thread="main"
+ visible="true">
+ <run
+ class="org.eclipse.ecf.examples.internal.eventadmin.app.EventAdminClientApplication">
+ </run>
+ </application>
+ </extension>
+
+</plugin>
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/AbstractEventAdminApplication.java b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/AbstractEventAdminApplication.java
new file mode 100644
index 000000000..3b758622f
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/AbstractEventAdminApplication.java
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * 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.examples.internal.eventadmin.app;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerFactory;
+import org.eclipse.ecf.core.IContainerManager;
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.core.sharedobject.ISharedObjectContainer;
+import org.eclipse.ecf.core.sharedobject.SharedObjectAddException;
+import org.eclipse.ecf.examples.eventadmin.EventAdminImpl;
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventConstants;
+import org.osgi.util.tracker.ServiceTracker;
+
+public abstract class AbstractEventAdminApplication implements IApplication {
+
+ protected BundleContext bundleContext;
+ // The following must be set in processArgs
+ protected String containerType;
+ protected String containerId;
+ protected String targetId;
+ protected String topic;
+
+ protected ServiceTracker containerManagerTracker;
+ private final Object appLock = new Object();
+ private boolean done = false;
+ protected EventAdminImpl eventAdminImpl;
+ protected ServiceRegistration eventAdminRegistration;
+ protected IContainer container;
+
+ public Object start(IApplicationContext context) throws Exception {
+ // Get BundleContext
+ bundleContext = Activator.getContext();
+ // Process Arguments
+ processArgs(context.getArguments());
+ // Create event admin impl
+ eventAdminImpl = new EventAdminImpl(bundleContext);
+ // Create, configure, and connect container
+ createConfigureAndConnectContainer();
+ // registerEventAdmin
+ registerEventAdmin();
+ return new Integer(0);
+ }
+
+ protected abstract void processArgs(Map args);
+
+ protected void registerEventAdmin() {
+ // Create properties for event admin
+ Properties eventAdminProps = new Properties();
+ eventAdminProps.put(EventConstants.EVENT_TOPIC, topic);
+ // register event admin service
+ eventAdminRegistration = bundleContext.registerService(EventAdmin.class
+ .getName(), eventAdminImpl, eventAdminProps);
+ }
+
+ protected void waitForDone() {
+ // then just wait here
+ synchronized (appLock) {
+ while (!done) {
+ try {
+ appLock.wait();
+ } catch (InterruptedException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ public void stop() {
+ if (eventAdminRegistration != null) {
+ eventAdminRegistration.unregister();
+ eventAdminRegistration = null;
+ }
+ if (container != null) {
+ container.dispose();
+ getContainerManager().removeAllContainers();
+ container = null;
+ }
+ if (containerManagerTracker != null) {
+ containerManagerTracker.close();
+ containerManagerTracker = null;
+ }
+ synchronized (appLock) {
+ done = true;
+ appLock.notifyAll();
+ }
+ bundleContext = null;
+ }
+
+ protected void connectContainer(IContainer container, String target)
+ throws ContainerConnectException {
+ if (target != null)
+ container.connect(IDFactory.getDefault().createID(
+ container.getConnectNamespace(), target), null);
+ }
+
+ protected void createConfigureAndConnectContainer()
+ throws ContainerCreateException, SharedObjectAddException,
+ ContainerConnectException {
+ container = createContainer(containerType, containerId);
+ addEventAdmin(container, eventAdminImpl, topic);
+ connectContainer(container, targetId);
+ }
+
+ protected IContainerManager getContainerManager() {
+ if (containerManagerTracker == null) {
+ containerManagerTracker = new ServiceTracker(bundleContext,
+ IContainerManager.class.getName(), null);
+ containerManagerTracker.open();
+ }
+ return (IContainerManager) containerManagerTracker.getService();
+ }
+
+ protected IContainer createContainer(String containerType,
+ String containerId) throws ContainerCreateException {
+ IContainerFactory containerFactory = getContainerManager()
+ .getContainerFactory();
+ return (containerId == null) ? containerFactory
+ .createContainer(containerType) : containerFactory
+ .createContainer(containerType, new Object[] { containerId });
+ }
+
+ protected void addEventAdmin(IContainer container,
+ EventAdminImpl eventAdmin, String topic)
+ throws SharedObjectAddException {
+ ISharedObjectContainer soContainer = (ISharedObjectContainer) container
+ .getAdapter(ISharedObjectContainer.class);
+ soContainer.getSharedObjectManager().addSharedObject(
+ IDFactory.getDefault().createStringID(topic), eventAdmin, null);
+ }
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/Activator.java b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/Activator.java
new file mode 100644
index 000000000..61bcaed7a
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/Activator.java
@@ -0,0 +1,29 @@
+package org.eclipse.ecf.examples.internal.eventadmin.app;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext ctxt) throws Exception {
+ context = ctxt;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ context = null;
+ }
+
+ public static BundleContext getContext() {
+ return context;
+ }
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminClientApplication.java b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminClientApplication.java
new file mode 100644
index 000000000..3b8fcf90c
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminClientApplication.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+* 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.examples.internal.eventadmin.app;
+
+import java.util.Map;
+
+import org.eclipse.equinox.app.IApplicationContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.EventHandler;
+
+public class EventAdminClientApplication extends AbstractEventAdminApplication {
+
+ private static final String DEFAULT_CONTAINER_TYPE = "ecf.jms.activemq.tcp.client";
+ private static final String DEFAULT_TOPIC = EventAdminManagerApplication.DEFAULT_TOPIC;
+ private static final String DEFAULT_CONTAINER_TARGET = EventAdminManagerApplication.DEFAULT_CONTAINER_ID;
+
+ private TestSender testSender;
+ private ServiceRegistration testEventHandlerRegistration;
+
+ public Object start(IApplicationContext context) throws Exception {
+ // Do setup in abstract super class
+ super.start(context);
+
+ // XXX for testing, setup an event handler
+ testEventHandlerRegistration = bundleContext.registerService(
+ EventHandler.class.getName(), new TestEventHandler(), null);
+
+ // XXX for testing, setup a test sender
+ testSender = new TestSender(eventAdminImpl, topic, container.getID().getName());
+ new Thread(testSender).start();
+
+ // Now just wait until we're stopped
+ waitForDone();
+
+ return new Integer(0);
+ }
+
+ public void stop() {
+ if (testSender != null) {
+ testSender.stop();
+ testSender = null;
+ }
+ if (testEventHandlerRegistration != null) {
+ testEventHandlerRegistration.unregister();
+ testEventHandlerRegistration = null;
+ }
+ super.stop();
+ }
+
+ protected void processArgs(Map args) {
+ containerType = DEFAULT_CONTAINER_TYPE;
+ containerId = null;
+ targetId = DEFAULT_CONTAINER_TARGET;
+ topic = DEFAULT_TOPIC;
+ }
+
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminManagerApplication.java b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminManagerApplication.java
new file mode 100644
index 000000000..de54c3aea
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/EventAdminManagerApplication.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.examples.internal.eventadmin.app;
+
+import java.util.Map;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.event.EventHandler;
+
+public class EventAdminManagerApplication extends AbstractEventAdminApplication
+ implements IApplication {
+
+ private static final String DEFAULT_CONTAINER_TYPE = "ecf.jms.activemq.tcp.manager";
+ public static final String DEFAULT_CONTAINER_ID = "tcp://localhost:61616/exampleTopic";
+ public static final String DEFAULT_TOPIC = "defaultTopic";
+
+ private TestSender testSender;
+ private ServiceRegistration testEventHandlerRegistration;
+
+ public Object start(IApplicationContext context) throws Exception {
+ // Do setup in abstract super class
+ super.start(context);
+
+ // XXX for testing, setup an event handler
+ testEventHandlerRegistration = bundleContext.registerService(
+ EventHandler.class.getName(), new TestEventHandler(), null);
+
+ // XXX for testing, setup a test sender
+ testSender = new TestSender(eventAdminImpl, topic, container.getID().getName());
+ new Thread(testSender).start();
+
+ // Now just wait until we're stopped
+ waitForDone();
+
+ return new Integer(0);
+ }
+
+ public void stop() {
+ if (testSender != null) {
+ testSender.stop();
+ testSender = null;
+ }
+ if (testEventHandlerRegistration != null) {
+ testEventHandlerRegistration.unregister();
+ testEventHandlerRegistration = null;
+ }
+ super.stop();
+ }
+
+ protected void processArgs(Map args) {
+ containerType = DEFAULT_CONTAINER_TYPE;
+ containerId = DEFAULT_CONTAINER_ID;
+ targetId = null;
+ topic = DEFAULT_TOPIC;
+ }
+
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestEventHandler.java b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestEventHandler.java
new file mode 100644
index 000000000..1ca19a95a
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestEventHandler.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.examples.internal.eventadmin.app;
+
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventHandler;
+
+public class TestEventHandler implements EventHandler {
+
+ public void handleEvent(Event event) {
+ System.out.println("handleEvent\n\ttopic=" + event.getTopic()
+ + "\n\tmessage=" + event.getProperty("message") + "\n\tsender="
+ + event.getProperty("sender"));
+ }
+
+}
diff --git a/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestSender.java b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestSender.java
new file mode 100644
index 000000000..14cc62d38
--- /dev/null
+++ b/examples/bundles/org.eclipse.ecf.examples.eventadmin.app/src/org/eclipse/ecf/examples/internal/eventadmin/app/TestSender.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.examples.internal.eventadmin.app;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.osgi.service.event.Event;
+import org.osgi.service.event.EventAdmin;
+
+public class TestSender implements Runnable {
+
+ private static final long DEFAULT_WAITTIME = 2000;
+
+ private long waittime = DEFAULT_WAITTIME;
+
+ private EventAdmin eventAdmin;
+ private String topic;
+ private String sender;
+ private boolean done = false;
+ private long messageCounter = 0L;
+
+ public TestSender(EventAdmin eventAdmin, String topic, String sender) {
+ this.eventAdmin = eventAdmin;
+ this.topic = topic;
+ this.sender = sender;
+ }
+
+ public void run() {
+ synchronized (this) {
+ while (!done) {
+ try {
+ wait(waittime);
+ Map msgProps = new Properties();
+ msgProps.put("message", "message #"
+ + messageCounter++);
+ msgProps.put("sender", sender);
+ eventAdmin.postEvent(new Event(topic, msgProps));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void stop() {
+ synchronized (this) {
+ done = true;
+ notifyAll();
+ }
+ }
+}

Back to the top