Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Alexander Kuppe2010-06-26 11:22:44 +0000
committerMarkus Alexander Kuppe2010-06-26 11:22:44 +0000
commit8678326d1d50199e29106c8b4f505bd04d734088 (patch)
tree7cb0c3440b99970d805c3c7be0fccc98952499dd
parentbe2fb03bc697110e1ee105d463ad972f4f2076ce (diff)
downloadorg.eclipse.ecf-8678326d1d50199e29106c8b4f505bd04d734088.tar.gz
org.eclipse.ecf-8678326d1d50199e29106c8b4f505bd04d734088.tar.xz
org.eclipse.ecf-8678326d1d50199e29106c8b4f505bd04d734088.zip
NEW - bug 317798: [Discovery][DNS-SD] Create/register IDiscoveryAdvertiser container/service
https://bugs.eclipse.org/bugs/show_bug.cgi?id=317798
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java247
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryAdvertiser.java56
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryContainerAdapter.java162
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryLocator.java91
4 files changed, 325 insertions, 231 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java
index e66bb5ad5..502e0a883 100644
--- a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/Activator.java
@@ -30,10 +30,10 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ConfigurationException;
import org.osgi.service.cm.ManagedServiceFactory;
-public class Activator implements BundleActivator, ManagedServiceFactory {
+public class Activator implements BundleActivator {
- private Map serviceRegistrations = new HashMap();
- private BundleContext context;
+ private final Map serviceRegistrations = new HashMap();
+ private volatile BundleContext context;
private static final String NAME = "ecf.discovery.dnssd";
/*
@@ -43,40 +43,27 @@ public class Activator implements BundleActivator, ManagedServiceFactory {
public void start(BundleContext context) throws Exception {
this.context = context;
- // register a managed factory for this service
- final Properties cmProps = new Properties();
- cmProps.put(Constants.SERVICE_PID, NAME);
- context.registerService(ManagedServiceFactory.class.getName(), this, cmProps);
+ // register a managed factory for the locator service
+ final Properties locCmProps = new Properties();
+ locCmProps.put(Constants.SERVICE_PID, NAME + ".locator");
+ context.registerService(ManagedServiceFactory.class.getName(), new DnsSdManagedServiceFactory(DnsSdDiscoveryLocator.class), locCmProps);
- // register the service
- final Properties props = new Properties();
- props.put("org.eclipse.ecf.discovery.containerName", NAME);
- props.put(Constants.SERVICE_RANKING, new Integer(750));
- String[] clazzes = new String[]{IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName()};
- serviceRegistrations.put(null, context.registerService(clazzes, new ServiceFactory() {
- private volatile DnsSdDiscoveryLocator locator;
+ // register the locator service
+ final Properties locProps = new Properties();
+ locProps.put("org.eclipse.ecf.discovery.containerName", NAME + ".locator");
+ locProps.put(Constants.SERVICE_RANKING, new Integer(750));
+ serviceRegistrations.put(null, context.registerService(IDiscoveryLocator.class.getName(), new DnsSdServiceFactory(DnsSdDiscoveryLocator.class), locProps));
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
- */
- public Object getService(final Bundle bundle, final ServiceRegistration registration) {
- if (locator == null) {
- try {
- locator = new DnsSdDiscoveryLocator();
- locator.connect(null, null);
- } catch (final ContainerConnectException e) {
- locator = null;
- }
- }
- return locator;
- }
-
- /* (non-Javadoc)
- * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
- */
- public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
- }
- }, props));
+ // register a managed factory for the advertiser service
+ final Properties advCmProps = new Properties();
+ advCmProps.put(Constants.SERVICE_PID, NAME + ".advertiser");
+ context.registerService(ManagedServiceFactory.class.getName(), new DnsSdManagedServiceFactory(DnsSdDiscoveryAdvertiser.class), advCmProps);
+
+ // register the advertiser service
+ final Properties advProps = new Properties();
+ advProps.put("org.eclipse.ecf.discovery.containerName", NAME + ".advertiser");
+ advProps.put(Constants.SERVICE_RANKING, new Integer(750));
+ serviceRegistrations.put(null, context.registerService(IDiscoveryAdvertiser.class.getName(), new DnsSdServiceFactory(DnsSdDiscoveryAdvertiser.class), advProps));
}
/*
@@ -87,77 +74,149 @@ public class Activator implements BundleActivator, ManagedServiceFactory {
if (serviceRegistrations != null) {
for (Iterator itr = serviceRegistrations.values().iterator(); itr.hasNext();) {
ServiceRegistration serviceRegistration = (ServiceRegistration) itr.next();
- ServiceReference reference = serviceRegistration.getReference();
- IDiscoveryLocator aLocator = (IDiscoveryLocator) context.getService(reference);
-
- serviceRegistration.unregister();
- IContainer container = (IContainer) aLocator.getAdapter(IContainer.class);
- container.dispose();
- container.disconnect();
+ disposeServiceRegistration(serviceRegistration);
}
-
- serviceRegistrations = null;
}
this.context = null;
}
-
- /* (non-Javadoc)
- * @see org.osgi.service.cm.ManagedServiceFactory#getName()
+
+ /**
+ * @param serviceRegistration disconnects the underlying IContainer and unregisters the service
*/
- public String getName() {
- return this.getClass().getName();
+ private void disposeServiceRegistration(ServiceRegistration serviceRegistration) {
+ ServiceReference reference = serviceRegistration.getReference();
+ IContainer aContainer = (DnsSdDiscoveryContainerAdapter) context.getService(reference);
+
+ serviceRegistration.unregister();
+ IContainer container = (IContainer) aContainer.getAdapter(IContainer.class);
+ container.dispose();
+ container.disconnect();
}
-
- /* (non-Javadoc)
- * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
+
+ /**
+ * A ManagedServiceFactory capable to handle DnsSdDiscoveryContainerAdapters
*/
- public void updated(String pid, Dictionary properties)
- throws ConfigurationException {
- if(properties != null) {
- Properties props = new Properties();
- props.put(Constants.SERVICE_PID, pid);
-
- DnsSdDiscoveryLocator locator = new DnsSdDiscoveryLocator();
- DnsSdServiceTypeID targetID = new DnsSdServiceTypeID();
- try {
- final String[] searchPaths = (String[]) properties.get(IDnsSdDiscoveryConstants.CA_SEARCH_PATH);
- if(searchPaths != null) {
- targetID.setSearchPath(searchPaths);
- }
+ private class DnsSdManagedServiceFactory implements ManagedServiceFactory {
+ private final Class containerClass;
- final String resolver = (String) properties.get(IDnsSdDiscoveryConstants.CA_RESOLVER);
- if(resolver != null) {
- locator.setResolver(resolver);
- }
-
- final String tsigKey = (String) properties.get(IDnsSdDiscoveryConstants.CA_TSIG_KEY);
- if(tsigKey != null) {
- final String tsigKeyName = (String) properties.get(IDnsSdDiscoveryConstants.CA_TSIG_KEY_NAME);
- locator.setTsigKey(tsigKeyName, tsigKey);
+ public DnsSdManagedServiceFactory(Class aContainerClass) {
+ containerClass = aContainerClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.cm.ManagedServiceFactory#getName()
+ */
+ public String getName() {
+ return this.getClass().getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
+ */
+ public void updated(String pid, Dictionary properties)
+ throws ConfigurationException {
+ if(properties != null) {
+ DnsSdDiscoveryContainerAdapter adapter = null;
+ DnsSdServiceTypeID targetID = null;
+ try {
+ // get existing or create new discoverycontainer
+ final ServiceRegistration serviceRegistration = (ServiceRegistration) serviceRegistrations.get(pid);
+ if(serviceRegistration != null) {
+ adapter = (DnsSdDiscoveryContainerAdapter) context.getService(serviceRegistration.getReference());
+ targetID = (DnsSdServiceTypeID) adapter.getConnectedID();
+ } else {
+ adapter = (DnsSdDiscoveryContainerAdapter) containerClass.newInstance();
+ targetID = new DnsSdServiceTypeID();
+ }
+
+ // apply configuration
+ final String[] searchPaths = (String[]) properties.get(IDnsSdDiscoveryConstants.CA_SEARCH_PATH);
+ if(searchPaths != null) {
+ targetID.setSearchPath(searchPaths);
+ }
+
+ final String resolver = (String) properties.get(IDnsSdDiscoveryConstants.CA_RESOLVER);
+ if(resolver != null) {
+ adapter.setResolver(resolver);
+ }
+
+ final String tsigKey = (String) properties.get(IDnsSdDiscoveryConstants.CA_TSIG_KEY);
+ if(tsigKey != null) {
+ final String tsigKeyName = (String) properties.get(IDnsSdDiscoveryConstants.CA_TSIG_KEY_NAME);
+ adapter.setTsigKey(tsigKeyName, tsigKey);
+ }
+
+ // finally connect container and keep ser reg for later updates/deletes
+ if(serviceRegistration == null) {
+ final Properties props = new Properties();
+ props.put(Constants.SERVICE_PID, pid);
+ adapter.connect(targetID, null);
+ serviceRegistrations.put(pid, context.registerService(IDiscoveryLocator.class.getName(), adapter, props));
+ }
+ } catch (ContainerConnectException e) {
+ throw new ConfigurationException("IDnsSdDiscoveryConstants properties", e.getLocalizedMessage(), e);
+ } catch (ClassCastException cce) {
+ throw new ConfigurationException("IDnsSdDiscoveryConstants properties", cce.getLocalizedMessage(), cce);
+ } catch (InstantiationException e) {
+ // may never happen
+ throw new ConfigurationException("InstantiationException", e.getLocalizedMessage(), e);
+ } catch (IllegalAccessException e) {
+ // may never happen
+ throw new ConfigurationException("IllegalAccessException", e.getLocalizedMessage(), e);
}
-
- locator.connect(targetID, null);
- serviceRegistrations.put(pid, context.registerService(IDiscoveryLocator.class.getName(), locator, props));
- } catch (ContainerConnectException e) {
- throw new ConfigurationException("IDnsSdDiscoveryConstants properties", e.getLocalizedMessage(), e);
- } catch (ClassCastException cce) {
- throw new ConfigurationException("IDnsSdDiscoveryConstants properties", cce.getLocalizedMessage(), cce);
}
}
- }
- /* (non-Javadoc)
- * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)
+ /* (non-Javadoc)
+ * @see org.osgi.service.cm.ManagedServiceFactory#deleted(java.lang.String)
+ */
+ public void deleted(String pid) {
+ ServiceRegistration serviceRegistration = (ServiceRegistration) serviceRegistrations.get(pid);
+ disposeServiceRegistration(serviceRegistration);
+ }
+ }
+
+ /**
+ * A ServiceFactory capable to handle DnsSdDiscoveryContainerAdapters
*/
- public void deleted(String pid) {
- ServiceRegistration serviceRegistration = (ServiceRegistration) serviceRegistrations.get(pid);
- ServiceReference reference = serviceRegistration.getReference();
- IDiscoveryLocator aLocator = (IDiscoveryLocator) context.getService(reference);
-
- serviceRegistration.unregister();
- IContainer container = (IContainer) aLocator.getAdapter(IContainer.class);
- container.dispose();
- container.disconnect();
- return;
+ public class DnsSdServiceFactory implements ServiceFactory {
+ private volatile DnsSdDiscoveryContainerAdapter container;
+ private final Class containerClass;
+
+ public DnsSdServiceFactory(Class aDiscoveryContainerClass) {
+ containerClass = aDiscoveryContainerClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
+ */
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ if (container == null) {
+ try {
+ container = (DnsSdDiscoveryContainerAdapter) containerClass.newInstance();
+ container.connect(null, null);
+ } catch (final ContainerConnectException e) {
+ // may never happen
+ e.printStackTrace();
+ container = null;
+ } catch (InstantiationException e) {
+ // may never happen
+ e.printStackTrace();
+ container = null;
+ } catch (IllegalAccessException e) {
+ // may never happen
+ e.printStackTrace();
+ container = null;
+ }
+ }
+ return container;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
+ */
+ public void ungetService(Bundle bundle,
+ ServiceRegistration registration, Object service) {
+ }
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryAdvertiser.java b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryAdvertiser.java
index 717de13df..110cd6a8d 100644
--- a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryAdvertiser.java
+++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryAdvertiser.java
@@ -19,11 +19,11 @@ import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.events.ContainerConnectedEvent;
import org.eclipse.ecf.core.events.ContainerConnectingEvent;
import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.discovery.DiscoveryContainerConfig;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.IServiceProperties;
-import org.eclipse.ecf.discovery.identity.IServiceID;
-import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.xbill.DNS.DClass;
import org.xbill.DNS.Message;
import org.xbill.DNS.Name;
@@ -33,8 +33,14 @@ import org.xbill.DNS.SimpleResolver;
import org.xbill.DNS.Type;
import org.xbill.DNS.Update;
-public class DnsSdDiscoveryAdvertiser extends DnsSdDiscoveryLocator {
+public class DnsSdDiscoveryAdvertiser extends DnsSdDiscoveryContainerAdapter {
+ public DnsSdDiscoveryAdvertiser() {
+ super(DnsSdNamespace.NAME, new DiscoveryContainerConfig(IDFactory
+ .getDefault().createStringID(
+ DnsSdDiscoveryAdvertiser.class.getName())));
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#registerService(org.eclipse.ecf.discovery.IServiceInfo)
*/
@@ -142,48 +148,4 @@ public class DnsSdDiscoveryAdvertiser extends DnsSdDiscoveryLocator {
connectContext));
fireContainerEvent(new ContainerConnectedEvent(this.getID(), targetID));
}
-
- /* not a locator! */
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
- */
- public IServiceInfo getServiceInfo(IServiceID aServiceId) {
- Assert.isNotNull(aServiceId);
- // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
- // doesn't support this yet
- throw new UnsupportedOperationException(
- "This is not an IDiscoveryLocator");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServiceTypes()
- */
- public IServiceTypeID[] getServiceTypes() {
- // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
- // doesn't support this yet
- throw new UnsupportedOperationException(
- "This is not an IDiscoveryLocator");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServices()
- */
- public IServiceInfo[] getServices() {
- // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
- // doesn't support this yet
- throw new UnsupportedOperationException(
- "This is not an IDiscoveryLocator");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
- */
- public IServiceInfo[] getServices(IServiceTypeID aServiceTypeId) {
- Assert.isNotNull(aServiceTypeId);
- // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
- // doesn't support this yet
- throw new UnsupportedOperationException(
- "This is not an IDiscoveryLocator");
- }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryContainerAdapter.java b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryContainerAdapter.java
new file mode 100644
index 000000000..bee1530d0
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryContainerAdapter.java
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Markus Alexander Kuppe.
+ * 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:
+ * Markus Alexander Kuppe (ecf-dev_eclipse.org <at> lemmster <dot> de) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.provider.dnssd;
+
+import java.net.UnknownHostException;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.events.ContainerDisconnectedEvent;
+import org.eclipse.ecf.core.events.ContainerDisconnectingEvent;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter;
+import org.eclipse.ecf.discovery.DiscoveryContainerConfig;
+import org.eclipse.ecf.discovery.IServiceInfo;
+import org.eclipse.ecf.discovery.identity.IServiceID;
+import org.eclipse.ecf.discovery.identity.IServiceTypeID;
+import org.xbill.DNS.Resolver;
+import org.xbill.DNS.SimpleResolver;
+import org.xbill.DNS.TSIG;
+
+public abstract class DnsSdDiscoveryContainerAdapter extends
+ AbstractDiscoveryContainerAdapter {
+
+ protected Resolver resolver;
+ protected DnsSdServiceTypeID targetID;
+
+ public DnsSdDiscoveryContainerAdapter(String aNamespaceName,
+ DiscoveryContainerConfig aConfig) {
+ super(aNamespaceName, aConfig);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
+ */
+ public IServiceInfo getServiceInfo(IServiceID aServiceId) {
+ Assert.isNotNull(aServiceId);
+ // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
+ // doesn't support this yet
+ throw new UnsupportedOperationException(
+ "This is not an IDiscoveryLocator");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServiceTypes()
+ */
+ public IServiceTypeID[] getServiceTypes() {
+ // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
+ // doesn't support this yet
+ throw new UnsupportedOperationException(
+ "This is not an IDiscoveryLocator");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServices()
+ */
+ public IServiceInfo[] getServices() {
+ // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
+ // doesn't support this yet
+ throw new UnsupportedOperationException(
+ "This is not an IDiscoveryLocator");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.provider.dnssd.DnsSdDiscoveryLocator#getServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
+ */
+ public IServiceInfo[] getServices(IServiceTypeID aServiceTypeId) {
+ Assert.isNotNull(aServiceTypeId);
+ // nop, we are just an Advertiser but AbstractDiscoveryContainerAdapter
+ // doesn't support this yet
+ throw new UnsupportedOperationException(
+ "This is not an IDiscoveryLocator");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryAdvertiser#registerService(org.eclipse.ecf.discovery.IServiceInfo)
+ */
+ public void registerService(IServiceInfo serviceInfo) {
+ Assert.isNotNull(serviceInfo);
+ // nop, we are just a Locator but AbstractDiscoveryContainerAdapter
+ // doesn't support this yet
+ throw new UnsupportedOperationException(
+ "This is not an IDiscoveryAdvertiser");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IDiscoveryAdvertiser#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
+ */
+ public void unregisterService(IServiceInfo serviceInfo) {
+ Assert.isNotNull(serviceInfo);
+ // nop, we are just a Locator but AbstractDiscoveryContainerAdapter
+ // doesn't support this yet
+ throw new UnsupportedOperationException(
+ "This is not an IDiscoveryAdvertiser");
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, org.eclipse.ecf.core.security.IConnectContext)
+ */
+ public abstract void connect(ID targetID, IConnectContext connectContext)
+ throws ContainerConnectException;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.IContainer#getConnectedID()
+ */
+ public ID getConnectedID() {
+ return targetID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.core.IContainer#disconnect()
+ */
+ public void disconnect() {
+ fireContainerEvent(new ContainerDisconnectingEvent(this.getID(),
+ getConnectedID()));
+ targetID = null;
+ fireContainerEvent(new ContainerDisconnectedEvent(this.getID(),
+ getConnectedID()));
+ }
+
+ /**
+ * @param searchPaths The default search path used for discovery
+ */
+ public void setSearchPath(String[] searchPaths) {
+ targetID.setSearchPath(searchPaths);
+ }
+
+ /**
+ * @return The default search path used by this discovery provider
+ */
+ public String[] getSearchPath() {
+ return targetID.getSearchPath();
+ }
+
+ /**
+ * @param aResolver The resolver to use
+ * @throws DnsSdDiscoveryException if hostname cannot be resolved
+ */
+ public void setResolver(String aResolver) {
+ try {
+ resolver = new SimpleResolver(aResolver);
+ } catch (UnknownHostException e) {
+ throw new DnsSdDiscoveryException(e);
+ }
+ }
+
+ /**
+ * @param tsigKeyName A key name/user name for dns dynamic update
+ * @param tsigKey A string representation of the shared key
+ */
+ public void setTsigKey(String tsigKeyName, String tsigKey) {
+ resolver.setTSIGKey(new TSIG(tsigKeyName, tsigKey));
+ }
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryLocator.java b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryLocator.java
index b098fda79..901a9949f 100644
--- a/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryLocator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.dnssd/src/org/eclipse/ecf/provider/dnssd/DnsSdDiscoveryLocator.java
@@ -24,12 +24,9 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.events.ContainerConnectedEvent;
import org.eclipse.ecf.core.events.ContainerConnectingEvent;
-import org.eclipse.ecf.core.events.ContainerDisconnectedEvent;
-import org.eclipse.ecf.core.events.ContainerDisconnectingEvent;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDFactory;
import org.eclipse.ecf.core.security.IConnectContext;
-import org.eclipse.ecf.discovery.AbstractDiscoveryContainerAdapter;
import org.eclipse.ecf.discovery.DiscoveryContainerConfig;
import org.eclipse.ecf.discovery.IServiceInfo;
import org.eclipse.ecf.discovery.ServiceInfo;
@@ -40,20 +37,16 @@ import org.xbill.DNS.Lookup;
import org.xbill.DNS.Name;
import org.xbill.DNS.PTRRecord;
import org.xbill.DNS.Record;
-import org.xbill.DNS.Resolver;
import org.xbill.DNS.ResolverConfig;
import org.xbill.DNS.SRVRecord;
import org.xbill.DNS.SimpleResolver;
-import org.xbill.DNS.TSIG;
import org.xbill.DNS.TXTRecord;
import org.xbill.DNS.Type;
-public class DnsSdDiscoveryLocator extends AbstractDiscoveryContainerAdapter {
+public class DnsSdDiscoveryLocator extends DnsSdDiscoveryContainerAdapter {
private static final String DNS_SD_PATH = "path";
private static final String DNS_SD_PTCL = "dns-sd.ptcl";
- protected DnsSdServiceTypeID targetID;
- protected Resolver resolver;
public DnsSdDiscoveryLocator() {
super(DnsSdNamespace.NAME, new DiscoveryContainerConfig(IDFactory
@@ -216,36 +209,6 @@ public class DnsSdDiscoveryLocator extends AbstractDiscoveryContainerAdapter {
* (non-Javadoc)
*
* @see
- * org.eclipse.ecf.discovery.IDiscoveryAdvertiser#registerService(org.eclipse
- * .ecf.discovery.IServiceInfo)
- */
- public void registerService(IServiceInfo serviceInfo) {
- Assert.isNotNull(serviceInfo);
- // nop, we are just a Locator but AbstractDiscoveryContainerAdapter
- // doesn't support this yet
- throw new UnsupportedOperationException(
- "This is not an IDiscoveryAdvertiser");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ecf.discovery.IDiscoveryAdvertiser#unregisterService(org.
- * eclipse.ecf.discovery.IServiceInfo)
- */
- public void unregisterService(IServiceInfo serviceInfo) {
- Assert.isNotNull(serviceInfo);
- // nop, we are just a Locator but AbstractDiscoveryContainerAdapter
- // doesn't support this yet
- throw new UnsupportedOperationException(
- "This is not an IDiscoveryAdvertiser");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
* org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
* org.eclipse.ecf.core.security.IConnectContext)
*/
@@ -306,56 +269,4 @@ public class DnsSdDiscoveryLocator extends AbstractDiscoveryContainerAdapter {
return (String[]) res.toArray(new String[res.size()]);
}
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ecf.core.IContainer#disconnect()
- */
- public void disconnect() {
- fireContainerEvent(new ContainerDisconnectingEvent(this.getID(),
- getConnectedID()));
- targetID = null;
- fireContainerEvent(new ContainerDisconnectedEvent(this.getID(),
- getConnectedID()));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ecf.core.IContainer#getConnectedID()
- */
- public ID getConnectedID() {
- return targetID;
- }
-
- /**
- * @param searchPaths The default search path used for discovery
- */
- public void setSearchPath(String[] searchPaths) {
- targetID.setSearchPath(searchPaths);
- }
-
- /**
- * @return The default search path used by this discovery provider
- */
- public String[] getSearchPath() {
- return targetID.getSearchPath();
- }
-
- /**
- * @param aResolver The resolver to use
- * @throws DnsSdDiscoveryException if hostname cannot be resolved
- */
- public void setResolver(String aResolver) {
- try {
- resolver = new SimpleResolver(aResolver);
- } catch (UnknownHostException e) {
- throw new DnsSdDiscoveryException(e);
- }
- }
-
- public void setTsigKey(String tsigKeyName, String tsigKey) {
- resolver.setTSIGKey(new TSIG(tsigKeyName, tsigKey));
- }
}

Back to the top