Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-05-30 12:10:36 +0000
committermkuppe2008-05-30 12:10:36 +0000
commit47cdead86b8a5d1b3f28b438318692f4fe039db1 (patch)
treeecad4a334e769fe918a4bffe94cd08ebe1be9fc5 /providers/bundles
parent71d9e892bca471a6a4151cf1310a9ed4de11a490 (diff)
downloadorg.eclipse.ecf-47cdead86b8a5d1b3f28b438318692f4fe039db1.tar.gz
org.eclipse.ecf-47cdead86b8a5d1b3f28b438318692f4fe039db1.tar.xz
org.eclipse.ecf-47cdead86b8a5d1b3f28b438318692f4fe039db1.zip
RESOLVED - bug 206444: [Discovery] Providers should be dynamic aware
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206444
Diffstat (limited to 'providers/bundles')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java220
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecorator.java31
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecoratorImpl.java101
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternAdvertiser.java91
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternLocator.java93
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java10
7 files changed, 369 insertions, 179 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java
index 53028146a..5a4cf1ffd 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java
@@ -10,11 +10,10 @@
******************************************************************************/
package org.eclipse.ecf.internal.provider.jslp;
-import ch.ethz.iks.slp.*;
-import java.util.*;
-import org.eclipse.ecf.core.util.Trace;
+import ch.ethz.iks.slp.Advertiser;
+import ch.ethz.iks.slp.Locator;
+import org.eclipse.core.runtime.Assert;
import org.osgi.framework.*;
-import org.osgi.util.tracker.ServiceTracker;
public class Activator implements BundleActivator {
// The shared instance
@@ -34,21 +33,8 @@ public class Activator implements BundleActivator {
// @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=108214
private BundleContext bundleContext;
- private ServiceTracker locatorST;
- private ServiceTracker advertiserST;
- private final ServiceLocationEnumeration emptyServiceLocationEnumeration = new ServiceLocationEnumeration() {
- public Object next() throws ServiceLocationException {
- throw new ServiceLocationException(ServiceLocationException.INTERNAL_SYSTEM_ERROR, "no elements"); //$NON-NLS-1$
- }
-
- public boolean hasMoreElements() {
- return false;
- }
-
- public Object nextElement() {
- throw new NoSuchElementException();
- }
- };
+ private LocatorDecorator locator = new NullPatternLocator();
+ private Advertiser advertiser = new NullPatternAdvertiser();
/**
* The constructor
@@ -61,26 +47,14 @@ public class Activator implements BundleActivator {
return bundleContext.getBundle();
}
- private Locator getLocator() {
- try {
- locatorST.open();
- Locator service = (Locator) locatorST.waitForService(10000);
- return service;
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return null;
- }
+ public LocatorDecorator getLocator() {
+ Assert.isNotNull(locator);
+ return locator;
}
- private Advertiser getAdvertiser() {
- try {
- advertiserST.open();
- Advertiser service = (Advertiser) advertiserST.waitForService(10000);
- return service;
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return null;
- }
+ public Advertiser getAdvertiser() {
+ Assert.isNotNull(advertiser);
+ return advertiser;
}
/*
@@ -91,8 +65,42 @@ public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
bundleContext = context;
- locatorST = new ServiceTracker(bundleContext, Locator.class.getName(), null);
- advertiserST = new ServiceTracker(bundleContext, Advertiser.class.getName(), null);
+ // initially get the locator and add a life cycle listener
+ final ServiceReference lRef = context.getServiceReference(Locator.class.getName());
+ if (lRef != null) {
+ locator = new LocatorDecoratorImpl((Locator) context.getService(lRef));
+ }
+ context.addServiceListener(new ServiceListener() {
+ public void serviceChanged(ServiceEvent event) {
+ switch (event.getType()) {
+ case ServiceEvent.REGISTERED :
+ Object service = bundleContext.getService(event.getServiceReference());
+ locator = new LocatorDecoratorImpl((Locator) service);
+ break;
+ case ServiceEvent.UNREGISTERING :
+ locator = new NullPatternLocator();
+ break;
+ }
+ }
+ }, "(" + Constants.OBJECTCLASS + "=" + Locator.class.getName() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+
+ // initially get the advertiser and add a life cycle listener
+ final ServiceReference aRef = context.getServiceReference(Advertiser.class.getName());
+ if (aRef != null) {
+ advertiser = (Advertiser) context.getService(aRef);
+ }
+ context.addServiceListener(new ServiceListener() {
+ public void serviceChanged(ServiceEvent event) {
+ switch (event.getType()) {
+ case ServiceEvent.REGISTERED :
+ advertiser = (Advertiser) bundleContext.getService(event.getServiceReference());
+ break;
+ case ServiceEvent.UNREGISTERING :
+ advertiser = new NullPatternAdvertiser();
+ break;
+ }
+ }
+ }, "(" + Constants.OBJECTCLASS + "=" + Advertiser.class.getName() + ")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
//TODO-mkuppe https://bugs.eclipse.org/232813
// register the jSLP discovery service (will be automatically unregistered when this bundle gets uninstalled)
@@ -110,142 +118,8 @@ public class Activator implements BundleActivator {
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
- if (locatorST != null) {
- locatorST.close();
- locatorST = null;
- }
//TODO-mkuppe here we should do something like a deregisterAll();
- if (advertiserST != null) {
- advertiserST.close();
- advertiserST = null;
- }
plugin = null;
bundleContext = null;
}
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Locator#findServiceTypes(java.lang.String, java.util.List)
- */
- public ServiceLocationEnumeration findServiceTypes(String namingAuthority, List scopes) throws ServiceLocationException {
- Locator locator = getLocator();
- if (locator != null) {
- return locator.findServiceTypes(namingAuthority, scopes);
- }
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "findServiceTypes(String, List)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- //TODO add logging
- return emptyServiceLocationEnumeration;
- }
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Locator#findServices(ch.ethz.iks.slp.ServiceType, java.util.List, java.lang.String)
- */
- private ServiceLocationEnumeration findServices(ServiceType type, List scopes, String searchFilter) throws ServiceLocationException {
- Locator locator = getLocator();
- if (locator != null) {
- return locator.findServices(type, scopes, searchFilter);
- }
- //TODO add logging
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "findServies(ServiceType, List, String)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- return emptyServiceLocationEnumeration;
- }
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Locator#findAttributes(ch.ethz.iks.slp.ServiceURL, java.util.List, java.util.List)
- */
- private ServiceLocationEnumeration findAttributes(ServiceURL anURL, List scopes, List attributes) throws ServiceLocationException {
- Locator locator = getLocator();
- if (locator != null) {
- return locator.findAttributes(anURL, scopes, attributes);
- }
- //TODO add logging
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "findAttributes(ch.ethz.iks.slp.ServiceType, java.util.List, java.util.List)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- return emptyServiceLocationEnumeration;
- }
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Advertiser#deregister(ch.ethz.iks.slp.ServiceURL)
- */
- public void deregister(ServiceURL url) throws ServiceLocationException {
- Advertiser advertiser = getAdvertiser();
- if (advertiser != null) {
- advertiser.deregister(url);
- return;
- }
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "deregister(ServiceURL)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- //TODO add logging
- }
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Advertiser#deregister(ch.ethz.iks.slp.ServiceURL, java.util.List)
- */
- public void deregister(ServiceURL url, List scopes) throws ServiceLocationException {
- Advertiser advertiser = getAdvertiser();
- if (advertiser != null) {
- advertiser.deregister(url, scopes);
- return;
- }
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "deregister(ServiceURL, List)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- //TODO add logging
- }
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Advertiser#register(ch.ethz.iks.slp.ServiceURL, java.util.Dictionary)
- */
- public void register(ServiceURL url, Dictionary attributes) throws ServiceLocationException {
- Advertiser advertiser = getAdvertiser();
- if (advertiser != null) {
- advertiser.register(url, attributes);
- return;
- }
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "register(ServiceURL, Dictionary)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- //TODO add logging
- }
-
- /* (non-Javadoc)
- * @see ch.ethz.iks.slp.Advertiser#register(ch.ethz.iks.slp.ServiceURL, java.util.List, java.util.Dictionary)
- */
- public void register(ServiceURL url, List scopes, Dictionary attributes) throws ServiceLocationException {
- Advertiser advertiser = getAdvertiser();
- if (advertiser != null) {
- advertiser.register(url, scopes, attributes);
- return;
- }
- Trace.trace(PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "register(ServiceURL, List, Dictionary)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
- //TODO add logging
- }
-
- /**
- * @return A Map whos keys are {@link ServiceURL} and Entries are {@link List} describing service attributes
- * @throws ServiceLocationException
- */
- public Map getServiceURLs() throws ServiceLocationException {
- Enumeration stEnum = findServiceTypes(null, null);
- Set aSet = new HashSet(Collections.list(stEnum));
- Map result = new HashMap();
- for (Iterator itr = aSet.iterator(); itr.hasNext();) {
- String type = (String) itr.next();
- ServiceLocationEnumeration services = findServices(new ServiceType(type), null, null);
- while (services.hasMoreElements()) {
- ServiceURL url = (ServiceURL) services.next();
- result.put(url, Collections.list(findAttributes(url, null, null)));
- }
- }
- return result;
- }
-
- /**
- * @param aServiceType
- * @param scopes
- * @return A Map whos keys are {@link ServiceURL} and Entries are {@link List} describing service attributes
- * @throws ServiceLocationException
- */
- public Map getServiceURLs(ServiceType aServiceType, List scopes) throws ServiceLocationException {
- Map result = new HashMap();
- ServiceLocationEnumeration services = findServices(aServiceType, scopes, null);
- while (services.hasMoreElements()) {
- ServiceURL url = (ServiceURL) services.next();
- result.put(url, Collections.list(findAttributes(url, scopes, null)));
- }
- return result;
- }
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java
index 6bc68ec90..f31b8025e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java
@@ -40,7 +40,7 @@ public final class JSLPDiscoveryJob extends Job {
protected IStatus run(IProgressMonitor monitor) {
Assert.isNotNull(monitor);
try {
- Map availableServices = Activator.getDefault().getServiceURLs();
+ Map availableServices = Activator.getDefault().getLocator().getServiceURLs();
Map removedServices = new HashMap(services);
for (Iterator itr = availableServices.entrySet().iterator(); itr.hasNext() && !monitor.isCanceled();) {
Map.Entry entry = (Map.Entry) itr.next();
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecorator.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecorator.java
new file mode 100644
index 000000000..9f56be4c3
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecorator.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Versant Corp.
+ * 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 Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.provider.jslp;
+
+import ch.ethz.iks.slp.*;
+import java.util.List;
+import java.util.Map;
+
+public interface LocatorDecorator extends Locator {
+ /**
+ * @param aServiceType
+ * @param scopes
+ * @return A Map whos keys are {@link ServiceURL} and Entries are {@link List} describing service attributes
+ * @throws ServiceLocationException
+ */
+ public Map getServiceURLs(ServiceType aServiceType, List scopes) throws ServiceLocationException;
+
+ /**
+ * @return A Map whos keys are {@link ServiceURL} and Entries are {@link List} describing service attributes
+ * @throws ServiceLocationException
+ */
+ public Map getServiceURLs() throws ServiceLocationException;
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecoratorImpl.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecoratorImpl.java
new file mode 100644
index 000000000..de571c407
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecoratorImpl.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Versant Corp.
+ * 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 Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.provider.jslp;
+
+import ch.ethz.iks.slp.*;
+import java.util.*;
+import org.eclipse.core.runtime.Assert;
+
+/**
+ * This decorator add additional methods which will eventually be moved to jSLP itself
+ */
+public class LocatorDecoratorImpl implements LocatorDecorator {
+
+ private Locator locator;
+
+ public LocatorDecoratorImpl(Locator aLocator) {
+ Assert.isNotNull(aLocator);
+ locator = aLocator;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findAttributes(ch.ethz.iks.slp.ServiceType, java.util.List, java.util.List)
+ */
+ public ServiceLocationEnumeration findAttributes(ServiceType type, List scopes, List attributeIds) throws ServiceLocationException {
+ return locator.findAttributes(type, scopes, attributeIds);
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findAttributes(ch.ethz.iks.slp.ServiceURL, java.util.List, java.util.List)
+ */
+ public ServiceLocationEnumeration findAttributes(ServiceURL url, List scopes, List attributeIds) throws ServiceLocationException {
+ return locator.findAttributes(url, scopes, attributeIds);
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findServices(ch.ethz.iks.slp.ServiceType, java.util.List, java.lang.String)
+ */
+ public ServiceLocationEnumeration findServices(ServiceType type, List scopes, String searchFilter) throws ServiceLocationException, IllegalArgumentException {
+ return locator.findServices(type, scopes, searchFilter);
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findServiceTypes(java.lang.String, java.util.List)
+ */
+ public ServiceLocationEnumeration findServiceTypes(String namingAuthority, List scopes) throws ServiceLocationException {
+ return locator.findServiceTypes(namingAuthority, scopes);
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#getLocale()
+ */
+ public Locale getLocale() {
+ return locator.getLocale();
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ locator.setLocale(locale);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.internal.provider.jslp.LocatorDecorator#getServiceURLs(ch.ethz.iks.slp.ServiceType, java.util.List)
+ */
+ public Map getServiceURLs(ServiceType aServiceType, List scopes) throws ServiceLocationException {
+ Map result = new HashMap();
+ ServiceLocationEnumeration services = findServices(aServiceType, scopes, null);
+ while (services.hasMoreElements()) {
+ ServiceURL url = (ServiceURL) services.next();
+ result.put(url, Collections.list(findAttributes(url, scopes, null)));
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.internal.provider.jslp.LocatorDecorator#getServiceURLs()
+ */
+ public Map getServiceURLs() throws ServiceLocationException {
+ Enumeration stEnum = findServiceTypes(null, null);
+ Set aSet = new HashSet(Collections.list(stEnum));
+ Map result = new HashMap();
+ for (Iterator itr = aSet.iterator(); itr.hasNext();) {
+ String type = (String) itr.next();
+ ServiceLocationEnumeration services = findServices(new ServiceType(type), null, null);
+ while (services.hasMoreElements()) {
+ ServiceURL url = (ServiceURL) services.next();
+ result.put(url, Collections.list(findAttributes(url, null, null)));
+ }
+ }
+ return result;
+ }
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternAdvertiser.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternAdvertiser.java
new file mode 100644
index 000000000..bef10df7b
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternAdvertiser.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Versant Corp.
+ * 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 Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.provider.jslp;
+
+import ch.ethz.iks.slp.Advertiser;
+import ch.ethz.iks.slp.ServiceURL;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+import org.eclipse.ecf.core.util.Trace;
+
+public class NullPatternAdvertiser implements Advertiser {
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#addAttributes(ch.ethz.iks.slp.ServiceURL, java.util.Dictionary)
+ */
+ public void addAttributes(ServiceURL url, Dictionary attributes) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "addAttributes(ServiceURL, Dictionary)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#deleteAttributes(ch.ethz.iks.slp.ServiceURL, java.util.Dictionary)
+ */
+ public void deleteAttributes(ServiceURL url, Dictionary attributeIds) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "deleteAttributes(ServiceURL, Dictionary)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#deregister(ch.ethz.iks.slp.ServiceURL)
+ */
+ public void deregister(ServiceURL url) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "deregister(ServiceURL)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#deregister(ch.ethz.iks.slp.ServiceURL, java.util.List)
+ */
+ public void deregister(ServiceURL url, List scopes) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "deregister(ServiceURL, List)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#getLocale()
+ */
+ public Locale getLocale() {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getLocale()", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return Locale.getDefault();
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#getMyIP()
+ */
+ public InetAddress getMyIP() {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getMyIP()", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ try {
+ return InetAddress.getLocalHost();
+ } catch (UnknownHostException e) {
+ Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getMyIP()", e); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#register(ch.ethz.iks.slp.ServiceURL, java.util.Dictionary)
+ */
+ public void register(ServiceURL url, Dictionary attributes) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "register(ServiceURL, Dictionary)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#register(ch.ethz.iks.slp.ServiceURL, java.util.List, java.util.Dictionary)
+ */
+ public void register(ServiceURL url, List scopes, Dictionary attributes) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "register(ServiceURL, List, Dictionary)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Advertiser#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "setLocale(Locale)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternLocator.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternLocator.java
new file mode 100644
index 000000000..8b70308e6
--- /dev/null
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternLocator.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Versant Corp.
+ * 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 Kuppe (mkuppe <at> versant <dot> com) - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.provider.jslp;
+
+import ch.ethz.iks.slp.*;
+import java.util.*;
+import org.eclipse.ecf.core.util.Trace;
+
+public class NullPatternLocator implements LocatorDecorator {
+ private final ServiceLocationEnumeration emptyServiceLocationEnumeration = new ServiceLocationEnumeration() {
+ public Object next() throws ServiceLocationException {
+ throw new ServiceLocationException(ServiceLocationException.INTERNAL_SYSTEM_ERROR, "no elements"); //$NON-NLS-1$
+ }
+
+ public boolean hasMoreElements() {
+ return false;
+ }
+
+ public Object nextElement() {
+ throw new NoSuchElementException();
+ }
+ };
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findAttributes(ch.ethz.iks.slp.ServiceURL, java.util.List, java.util.List)
+ */
+ public ServiceLocationEnumeration findAttributes(ServiceURL url, List scopes, List attributeIds) {
+ return emptyServiceLocationEnumeration;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findAttributes(ch.ethz.iks.slp.ServiceType, java.util.List, java.util.List)
+ */
+ public ServiceLocationEnumeration findAttributes(ServiceType type, List scopes, List attributeIds) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "findAttributes(ch.ethz.iks.slp.ServiceType, java.util.List, java.util.List)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return emptyServiceLocationEnumeration;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findServiceTypes(java.lang.String, java.util.List)
+ */
+ public ServiceLocationEnumeration findServiceTypes(String namingAuthority, List scopes) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "findServiceTypes(String, List)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return emptyServiceLocationEnumeration;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#findServices(ch.ethz.iks.slp.ServiceType, java.util.List, java.lang.String)
+ */
+ public ServiceLocationEnumeration findServices(ServiceType type, List scopes, String searchFilter) throws IllegalArgumentException {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "findServies(ServiceType, List, String)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return emptyServiceLocationEnumeration;
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#getLocale()
+ */
+ public Locale getLocale() {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getLocale()", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return Locale.getDefault();
+ }
+
+ /* (non-Javadoc)
+ * @see ch.ethz.iks.slp.Locator#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale locale) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "setLocale(Locale)", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.internal.provider.jslp.LocatorDecorator#getServiceURLs(ch.ethz.iks.slp.ServiceType, java.util.List)
+ */
+ public Map getServiceURLs(ServiceType serviceType, List scopes) {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getServiceURLs(ServiceType, List scopes", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return new HashMap();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.internal.provider.jslp.LocatorDecorator#getServiceURLs()
+ */
+ public Map getServiceURLs() {
+ Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getServiceURLs()", Locator.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
+ return new HashMap();
+ }
+}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java
index 97e5e60ac..8f6ed6403 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPDiscoveryContainer.java
@@ -144,7 +144,7 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
public IServiceTypeID[] getServiceTypes() {
List result = new ArrayList();
try {
- ServiceLocationEnumeration slenum = Activator.getDefault().findServiceTypes(null, null);
+ ServiceLocationEnumeration slenum = Activator.getDefault().getLocator().findServiceTypes(null, null);
for (; slenum.hasMoreElements();) {
ServiceType st = new ServiceType((String) slenum.nextElement());
IServiceID sid = (IServiceID) getConnectNamespace().createInstance(new Object[] {st.toString()});
@@ -163,7 +163,7 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
*/
public IServiceInfo[] getServices() {
try {
- return convertToIServiceInfo(Activator.getDefault().getServiceURLs());
+ return convertToIServiceInfo(Activator.getDefault().getLocator().getServiceURLs());
} catch (ServiceLocationException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getServices(int)", e); //$NON-NLS-1$
}
@@ -178,7 +178,7 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
try {
JSLPServiceID sid = (JSLPServiceID) IDFactory.getDefault().createID(getConnectNamespace(), new Object[] {type, null});
JSLPServiceTypeID stid = (JSLPServiceTypeID) sid.getServiceTypeID();
- return convertToIServiceInfo(Activator.getDefault().getServiceURLs(stid.getServiceType(), Arrays.asList(stid.getScopes())), type.getScopes());
+ return convertToIServiceInfo(Activator.getDefault().getLocator().getServiceURLs(stid.getServiceType(), Arrays.asList(stid.getScopes())), type.getScopes());
} catch (IDCreateException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getServices(IServiceTypeID)", e); //$NON-NLS-1$
} catch (ServiceLocationException e) {
@@ -195,7 +195,7 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
try {
JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
IServiceTypeID stid = si.getServiceID().getServiceTypeID();
- Activator.getDefault().register(si.getServiceURL(), Arrays.asList(stid.getScopes()), new ServicePropertiesAdapter(si.getServiceProperties()).toProperties());
+ Activator.getDefault().getAdvertiser().register(si.getServiceURL(), Arrays.asList(stid.getScopes()), new ServicePropertiesAdapter(si.getServiceProperties()).toProperties());
} catch (ServiceLocationException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "registerService(IServiceInfo)", e); //$NON-NLS-1$
throw new ECFException(e.getMessage(), e);
@@ -209,7 +209,7 @@ public class JSLPDiscoveryContainer extends AbstractDiscoveryContainerAdapter im
Assert.isNotNull(aServiceInfo);
JSLPServiceInfo si = new JSLPServiceInfo(aServiceInfo);
try {
- Activator.getDefault().deregister(si.getServiceURL());
+ Activator.getDefault().getAdvertiser().deregister(si.getServiceURL());
} catch (ServiceLocationException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "unregisterService(IServiceInfo)", e); //$NON-NLS-1$
}

Back to the top