diff options
author | slewis | 2010-05-19 04:44:18 +0000 |
---|---|---|
committer | slewis | 2010-05-19 04:44:18 +0000 |
commit | 0a08d845fd749b1d76ceeb3c9066545cd17c337a (patch) | |
tree | 0f92fa0b3a86ba7fd4604c74681e568851972106 /examples | |
parent | f692232fd6202d57fd5aea1f260dde99f13dee70 (diff) | |
download | org.eclipse.ecf-0a08d845fd749b1d76ceeb3c9066545cd17c337a.tar.gz org.eclipse.ecf-0a08d845fd749b1d76ceeb3c9066545cd17c337a.tar.xz org.eclipse.ecf-0a08d845fd749b1d76ceeb3c9066545cd17c337a.zip |
Added product config for zookeeper,generic host and consumer. Also cleaned up code
Diffstat (limited to 'examples')
3 files changed, 89 insertions, 15 deletions
diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/.settings/org.eclipse.jdt.core.prefs b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/.settings/org.eclipse.jdt.core.prefs index 135cf7bac..26f041458 100644 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/.settings/org.eclipse.jdt.core.prefs +++ b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ -#Sun Apr 18 18:17:24 PDT 2010 +#Tue May 18 21:37:08 PDT 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=jsr14 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zookeeper,generic).product b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zookeeper,generic).product new file mode 100644 index 000000000..ea37fef03 --- /dev/null +++ b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/products/Hello Service Consumer (zookeeper,generic).product @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?pde version="3.5"?> + +<product name="Generic Hello Consumer" uid="org.eclipse.ecf.examples.remoteservices.zoogenerichelloconsumer" application="org.eclipse.ecf.examples.remoteservices.hello.consumer.HelloConsumer" version="1.0.0" useFeatures="false" includeLaunchers="false"> + + <configIni use="default"> + </configIni> + + <launcherArgs> + <programArgs>-console +-consoleLog +-containerType ecf.generic.client</programArgs> + <vmArgs>-Dzoodiscovery.autoStart=true; +-Dzoodiscovery.clientPort=2002 +-Dzoodiscovery.flavor=zoodiscovery.flavor.standalone=localhost:2001 +-Xms40m +-Xmx512m</vmArgs> + <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac> + </launcherArgs> + + <launcher> + <solaris/> + <win useIco="false"> + <bmp/> + </win> + </launcher> + + <vm> + </vm> + + <plugins> + <plugin id="org.apache.log4j"/> + <plugin id="org.apache.zookeeper"/> + <plugin id="org.eclipse.core.contenttype"/> + <plugin id="org.eclipse.core.jobs"/> + <plugin id="org.eclipse.core.runtime"/> + <plugin id="org.eclipse.ecf"/> + <plugin id="org.eclipse.ecf.discovery"/> + <plugin id="org.eclipse.ecf.examples.remoteservices.hello"/> + <plugin id="org.eclipse.ecf.examples.remoteservices.hello.consumer"/> + <plugin id="org.eclipse.ecf.identity"/> + <plugin id="org.eclipse.ecf.osgi.services.discovery"/> + <plugin id="org.eclipse.ecf.osgi.services.distribution"/> + <plugin id="org.eclipse.ecf.provider"/> + <plugin id="org.eclipse.ecf.provider.remoteservice"/> + <plugin id="org.eclipse.ecf.provider.zookeeper"/> + <plugin id="org.eclipse.ecf.remoteservice"/> + <plugin id="org.eclipse.ecf.sharedobject"/> + <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> + + +</product> diff --git a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/src/org/eclipse/ecf/internal/examples/remoteservices/hello/consumer/HelloConsumerApplication.java b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/src/org/eclipse/ecf/internal/examples/remoteservices/hello/consumer/HelloConsumerApplication.java index 71eb54c19..3e9b94131 100644 --- a/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/src/org/eclipse/ecf/internal/examples/remoteservices/hello/consumer/HelloConsumerApplication.java +++ b/examples/bundles/org.eclipse.ecf.examples.remoteservices.hello.consumer/src/org/eclipse/ecf/internal/examples/remoteservices/hello/consumer/HelloConsumerApplication.java @@ -32,6 +32,7 @@ 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.util.tracker.ServiceTracker; import org.osgi.util.tracker.ServiceTrackerCustomizer; @@ -49,6 +50,8 @@ public class HelloConsumerApplication implements IApplication, private boolean done = false; private ServiceTracker helloServiceTracker; + private ServiceRegistration discoveryListenerRegistration; + private ServiceRegistration distributionListenerRegistration; public Object start(IApplicationContext appContext) throws Exception { // Set bundle context (for use with service trackers) @@ -61,19 +64,8 @@ public class HelloConsumerApplication implements IApplication, // upon discovery via the IProxyContainerFinder/DefaultProxyContainerFinder. getContainerFactory().createContainer(containerType); - // Register proxy discovery listener to log the publish/unpublish of remote services. - // This LoggingProxyDiscoveryListener logs the publication of OSGi remote services...so - // that the discovery can be more easily debugged. - // Note that other IProxyDiscoveryListeners may be created and registered, and - // all will be notified of publish/unpublish events - bundleContext.registerService(IProxyDiscoveryListener.class.getName(), new LoggingProxyDiscoveryListener(), null); - - // Register proxy distribution listener to log the register/unregister of remote services. - // This LoggingProxyDistributionListener logs the register/unregister of OSGi remote services...so - // that the distribution can be more easily debugged. - // Note that other IProxyDistributionListener may be created and registered, and - // all will be notified of register/unregister events - bundleContext.registerService(IProxyDistributionListener.class.getName(), new LoggingProxyDistributionListener(), null); + // Register osgi discovery and distribution listeners + registerRemoteServiceListeners(); // Create service tracker to track IHello instances that have the 'service.imported' // property set (as defined by OSGi 4.2 remote services spec). @@ -88,6 +80,21 @@ public class HelloConsumerApplication implements IApplication, return IApplication.EXIT_OK; } + private void registerRemoteServiceListeners() { + // Register proxy discovery listener to log the publish/unpublish of remote services. + // This LoggingProxyDiscoveryListener logs the publication of OSGi remote services...so + // that the discovery can be more easily debugged. + // Note that other IProxyDiscoveryListeners may be created and registered, and + // all will be notified of publish/unpublish events + discoveryListenerRegistration = bundleContext.registerService(IProxyDiscoveryListener.class.getName(), new LoggingProxyDiscoveryListener(), null); + // Register proxy distribution listener to log the register/unregister of remote services. + // This LoggingProxyDistributionListener logs the register/unregister of OSGi remote services...so + // that the distribution can be more easily debugged. + // Note that other IProxyDistributionListener may be created and registered, and + // all will be notified of register/unregister events + distributionListenerRegistration = bundleContext.registerService(IProxyDistributionListener.class.getName(), new LoggingProxyDistributionListener(), null); + } + private void startLocalDiscoveryIfPresent() { Bundle[] bundles = bundleContext.getBundles(); for(int i=0; i < bundles.length; i++) { @@ -119,6 +126,14 @@ public class HelloConsumerApplication implements IApplication, containerFactoryServiceTracker.close(); containerFactoryServiceTracker = null; } + if (discoveryListenerRegistration != null) { + discoveryListenerRegistration.unregister(); + discoveryListenerRegistration = null; + } + if (distributionListenerRegistration != null) { + distributionListenerRegistration.unregister(); + distributionListenerRegistration = null; + } this.bundleContext = null; synchronized (appLock) { done = true; |