Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-03-29 21:58:53 +0000
committerslewis2014-03-29 21:58:53 +0000
commitc2c021a2c39100409ec8322172f87657487750e0 (patch)
tree7bbe8523104e2ee3c0a9c8bfb10d4cd5caea591f /providers
parent13dabf26528a07883a2205b9dc67de66d9dec7ec (diff)
downloadorg.eclipse.ecf-c2c021a2c39100409ec8322172f87657487750e0.tar.gz
org.eclipse.ecf-c2c021a2c39100409ec8322172f87657487750e0.tar.xz
org.eclipse.ecf-c2c021a2c39100409ec8322172f87657487750e0.zip
Update discovery api and jmdns discovery provider to be usable without
extension registry per bug 421569 Change-Id: I02dc9a9659606b1803255369371e8e98bd78249f
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/META-INF/MANIFEST.MF2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java26
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/ContainerInstantiator.java16
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java11
4 files changed, 42 insertions, 13 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.jmdns/META-INF/MANIFEST.MF
index c08179f25..9e1d8fd86 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/META-INF/MANIFEST.MF
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ecf.provider.jmdns;singleton:=true
-Bundle-Version: 4.2.0.qualifier
+Bundle-Version: 4.3.0.qualifier
Bundle-Activator: org.eclipse.ecf.internal.provider.jmdns.JMDNSPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
index 620ccbd69..0a1b56a84 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
@@ -12,14 +12,17 @@ package org.eclipse.ecf.internal.provider.jmdns;
import java.util.Properties;
import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.ecf.core.ContainerConnectException;
-import org.eclipse.ecf.core.IContainer;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.ecf.core.*;
import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.core.util.*;
import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.service.IDiscoveryService;
+import org.eclipse.ecf.provider.jmdns.container.ContainerInstantiator;
import org.eclipse.ecf.provider.jmdns.container.JMDNSDiscoveryContainer;
+import org.eclipse.ecf.provider.jmdns.identity.JMDNSNamespace;
import org.osgi.framework.*;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;
@@ -45,7 +48,7 @@ public class JMDNSPlugin implements BundleActivator {
plugin = this;
}
- private ServiceTracker adapterManagerTracker = null;
+ private AdapterManagerTracker adapterManagerTracker = null;
private ServiceRegistration serviceRegistration;
@@ -56,15 +59,10 @@ public class JMDNSPlugin implements BundleActivator {
public IAdapterManager getAdapterManager() {
// First, try to get the adapter manager via
if (adapterManagerTracker == null) {
- adapterManagerTracker = new ServiceTracker(this.context, IAdapterManager.class.getName(), null);
+ adapterManagerTracker = new AdapterManagerTracker(this.context);
adapterManagerTracker.open();
}
- IAdapterManager adapterManager = (IAdapterManager) adapterManagerTracker.getService();
- // Then, if the service isn't there, try to get from Platform class via
- // PlatformHelper class
- if (adapterManager == null)
- adapterManager = PlatformHelper.getPlatformAdapterManager();
- return adapterManager;
+ return adapterManagerTracker.getAdapterManager();
}
/**
@@ -78,6 +76,14 @@ public class JMDNSPlugin implements BundleActivator {
props.put(Constants.SERVICE_RANKING, new Integer(750));
String[] clazzes = new String[] {IDiscoveryService.class.getName(), IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName()};
serviceRegistration = context.registerService(clazzes, serviceFactory, props);
+ SafeRunner.run(new ExtensionRegistryRunnable(ctxt) {
+ protected void runWithoutRegistry() throws Exception {
+ ctxt.registerService(Namespace.class, new JMDNSNamespace("JMDNS Discovery Namespace"), null);
+ ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ContainerInstantiator.JMDNS_CONTAINER_NAME, new ContainerInstantiator(), "JMDNS Discovery Container", true, false), null);
+ ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ContainerInstantiator.JMDNS_LOCATOR_NAME, new ContainerInstantiator(), "JMDNS Discovery Locator"), null);
+ ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ContainerInstantiator.JMDNS_ADVERTISER_NAME, new ContainerInstantiator(), "JMDNS Discovery Advertiser"), null);
+ }
+ });
}
private final DiscoveryServiceFactory serviceFactory = new DiscoveryServiceFactory();
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/ContainerInstantiator.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/ContainerInstantiator.java
index 6fc8b3ce3..1fb03aa82 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/ContainerInstantiator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/ContainerInstantiator.java
@@ -17,13 +17,25 @@ import org.eclipse.ecf.discovery.IDiscoveryContainerAdapter;
public class ContainerInstantiator implements IContainerInstantiator {
+ /**
+ * @since 4.3
+ */
+ public static final String JMDNS_CONTAINER_NAME = "ecf.container.jmdns";
+ /**
+ * @since 4.3
+ */
+ public static final String JMDNS_LOCATOR_NAME = "ecf.container.jmdns.locator";
+ /**
+ * @since 4.3
+ */
+ public static final String JMDNS_ADVERTISER_NAME = "ecf.container.jmdns.advertiser";
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.provider.IContainerInstantiator#createInstance(org.eclipse.ecf.core.ContainerTypeDescription, java.lang.Object[])
*/
public IContainer createInstance(final ContainerTypeDescription description, final Object[] args) throws ContainerCreateException {
try {
- final AbstractContainer container = new JMDNSDiscoveryContainer();
- return container;
+ return new JMDNSDiscoveryContainer();
} catch (final IDCreateException e) {
final ContainerCreateException excep = new ContainerCreateException("Jmdns container create failed", e); //$NON-NLS-1$
excep.setStackTrace(e.getStackTrace());
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
index 5c2691495..ac6a046fa 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
@@ -23,6 +23,17 @@ public class JMDNSNamespace extends Namespace {
public static final String NAME = "ecf.namespace.jmdns"; //$NON-NLS-1$
+ public JMDNSNamespace() {
+ super();
+ }
+
+ /**
+ * @since 4.3
+ */
+ public JMDNSNamespace(String description) {
+ super(NAME, description);
+ }
+
private String getInitFromExternalForm(final Object[] args) {
if (args == null || args.length < 1 || args[0] == null)
return null;

Back to the top