Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2009-02-20 08:52:48 +0000
committermkuppe2009-02-20 08:52:48 +0000
commit78e5371cf244388791e9c84564969ff3f6b933d1 (patch)
treec59f48cbbc2c9c03790a5e9f22e0995a2805a786 /providers
parent455543a8fb08c3aa5441934598a8430a7c251785 (diff)
downloadorg.eclipse.ecf-78e5371cf244388791e9c84564969ff3f6b933d1.tar.gz
org.eclipse.ecf-78e5371cf244388791e9c84564969ff3f6b933d1.tar.xz
org.eclipse.ecf-78e5371cf244388791e9c84564969ff3f6b933d1.zip
Code cleanups
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Activator.java14
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/JSLPDiscoveryJob.java34
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/LocatorDecoratorImpl.java36
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Messages.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternAdvertiser.java16
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/NullPatternLocator.java12
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java50
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java18
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java18
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java22
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java19
11 files changed, 122 insertions, 119 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 9c296d6fc..88242586b 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
@@ -55,7 +55,7 @@ public class Activator implements BundleActivator {
public LocatorDecorator getLocator() {
locatorSt.open();
- Locator aLocator = (Locator) locatorSt.getService();
+ final Locator aLocator = (Locator) locatorSt.getService();
if (aLocator == null) {
return new NullPatternLocator();
}
@@ -64,7 +64,7 @@ public class Activator implements BundleActivator {
public Advertiser getAdvertiser() {
advertiserSt.open();
- Advertiser advertiser = (Advertiser) advertiserSt.getService();
+ final Advertiser advertiser = (Advertiser) advertiserSt.getService();
if (advertiser == null) {
return new NullPatternAdvertiser();
}
@@ -86,7 +86,7 @@ public class Activator implements BundleActivator {
advertiserSt = new ServiceTracker(context, Advertiser.class.getName(), null);
// register ourself as an OSGi service
- Properties props = new Properties();
+ final Properties props = new Properties();
props.put(IDiscoveryService.CONTAINER_ID, IDFactory.getDefault().createStringID("org.eclipse.ecf.provider.jslp.container.JSLPDiscoveryContainer")); //$NON-NLS-1$
props.put(IDiscoveryService.CONTAINER_NAME, JSLPDiscoveryContainer.NAME);
props.put(Constants.SERVICE_RANKING, new Integer(500));
@@ -97,12 +97,12 @@ public class Activator implements BundleActivator {
/* (non-Javadoc)
* @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
*/
- public Object getService(Bundle bundle, ServiceRegistration registration) {
+ public Object getService(final Bundle bundle, final ServiceRegistration registration) {
if (jdc == null) {
try {
jdc = new JSLPDiscoveryContainer();
jdc.connect(null, null);
- } catch (ContainerConnectException e) {
+ } catch (final ContainerConnectException e) {
Trace.catching(Activator.PLUGIN_ID, Activator.PLUGIN_ID + "/debug/methods/tracing", this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
jdc = null;
}
@@ -113,7 +113,7 @@ public class Activator implements BundleActivator {
/* (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) {
+ public void ungetService(final Bundle bundle, final ServiceRegistration registration, final Object service) {
//TODO-mkuppe we later might want to dispose jSLP when the last!!! consumer ungets the service
//Though don't forget about the (ECF) Container which might still be in use
}
@@ -125,7 +125,7 @@ public class Activator implements BundleActivator {
*
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
- public void stop(BundleContext context) throws Exception {
+ public void stop(final BundleContext context) throws Exception {
//TODO-mkuppe here we should do something like a deregisterAll(), but see ungetService(...);
plugin = null;
bundleContext = null;
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 d2441201c..3e276c3f9 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
@@ -23,10 +23,10 @@ import org.osgi.framework.Bundle;
public final class JSLPDiscoveryJob extends Job {
- private JSLPDiscoveryContainer discoveryContainer;
- private Map services;
+ private final JSLPDiscoveryContainer discoveryContainer;
+ private final Map services;
- public JSLPDiscoveryJob(JSLPDiscoveryContainer container) {
+ public JSLPDiscoveryJob(final JSLPDiscoveryContainer container) {
super(Messages.JSLPDiscoveryJob_TITLE);
discoveryContainer = container;
services = Collections.synchronizedMap(new HashMap());
@@ -37,20 +37,20 @@ public final class JSLPDiscoveryJob extends Job {
*
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
- protected IStatus run(IProgressMonitor monitor) {
+ protected IStatus run(final IProgressMonitor monitor) {
Assert.isNotNull(monitor);
try {
- 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();
- ServiceURL url = (ServiceURL) entry.getKey();
+ final Map availableServices = Activator.getDefault().getLocator().getServiceURLs();
+ final Map removedServices = new HashMap(services);
+ for (final Iterator itr = availableServices.entrySet().iterator(); itr.hasNext() && !monitor.isCanceled();) {
+ final Map.Entry entry = (Map.Entry) itr.next();
+ final ServiceURL url = (ServiceURL) entry.getKey();
// do we know the service already?
if (removedServices.containsKey(url)) {
removedServices.remove(url);
} else { // we don't know the service, so we need to create the
- ServicePropertiesAdapter spa = new ServicePropertiesAdapter((List) entry.getValue());
- IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(url, spa.getServiceName()), spa.getPriority(), spa.getWeight(), spa);
+ final ServicePropertiesAdapter spa = new ServicePropertiesAdapter((List) entry.getValue());
+ final IServiceInfo serviceInfo = new JSLPServiceInfo(new ServiceURLAdapter(url, spa.getServiceName()), spa.getPriority(), spa.getWeight(), spa);
services.put(url, serviceInfo);
discoveryContainer.fireServiceTypeDiscovered(serviceInfo.getServiceID().getServiceTypeID());
discoveryContainer.fireServiceDiscovered(serviceInfo);
@@ -58,14 +58,16 @@ public final class JSLPDiscoveryJob extends Job {
monitor.worked(1);
}
// at this point removedServices only contains stale services
- for (Iterator itr = removedServices.keySet().iterator(); itr.hasNext() && !monitor.isCanceled();) {
- Object key = itr.next();
- discoveryContainer.fireServiceUndiscovered((IServiceInfo) removedServices.get(key));
+ for (final Iterator itr = removedServices.entrySet().iterator(); itr.hasNext() && !monitor.isCanceled();) {
+ final Map.Entry entry = (Map.Entry) itr.next();
+ final Object key = entry.getKey();
+ final IServiceInfo value = (IServiceInfo) entry.getValue();
+ discoveryContainer.fireServiceUndiscovered(value);
services.remove(key);
monitor.worked(1);
}
- } catch (ServiceLocationException e) {
+ } catch (final ServiceLocationException e) {
// TODO-mkuppe if the advertiser is gone, we run into this exception
// but we have to let the listeners know about the gone services
// too
@@ -84,7 +86,7 @@ public final class JSLPDiscoveryJob extends Job {
*/
public boolean shouldRun() {
if (Activator.getDefault() != null) {// system went down, no bundle
- int state = Activator.getDefault().getBundle().getState();
+ final int state = Activator.getDefault().getBundle().getState();
return (state == Bundle.ACTIVE || state == Bundle.STARTING);
}
return false;
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
index de571c407..2516779bc 100644
--- 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
@@ -19,9 +19,9 @@ import org.eclipse.core.runtime.Assert;
*/
public class LocatorDecoratorImpl implements LocatorDecorator {
- private Locator locator;
+ private final Locator locator;
- public LocatorDecoratorImpl(Locator aLocator) {
+ public LocatorDecoratorImpl(final Locator aLocator) {
Assert.isNotNull(aLocator);
locator = aLocator;
}
@@ -29,28 +29,28 @@ public class LocatorDecoratorImpl implements LocatorDecorator {
/* (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 {
+ public ServiceLocationEnumeration findAttributes(final ServiceType type, final List scopes, final 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 {
+ public ServiceLocationEnumeration findAttributes(final ServiceURL url, final List scopes, final 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 {
+ public ServiceLocationEnumeration findServices(final ServiceType type, final List scopes, final 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 {
+ public ServiceLocationEnumeration findServiceTypes(final String namingAuthority, final List scopes) throws ServiceLocationException {
return locator.findServiceTypes(namingAuthority, scopes);
}
@@ -64,18 +64,18 @@ public class LocatorDecoratorImpl implements LocatorDecorator {
/* (non-Javadoc)
* @see ch.ethz.iks.slp.Locator#setLocale(java.util.Locale)
*/
- public void setLocale(Locale locale) {
+ public void setLocale(final 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);
+ public Map getServiceURLs(final ServiceType aServiceType, final List scopes) throws ServiceLocationException {
+ final Map result = new HashMap();
+ final ServiceLocationEnumeration services = findServices(aServiceType, scopes, null);
while (services.hasMoreElements()) {
- ServiceURL url = (ServiceURL) services.next();
+ final ServiceURL url = (ServiceURL) services.next();
result.put(url, Collections.list(findAttributes(url, scopes, null)));
}
return result;
@@ -85,14 +85,14 @@ public class LocatorDecoratorImpl implements LocatorDecorator {
* @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);
+ final Enumeration stEnum = findServiceTypes(null, null);
+ final Set aSet = new HashSet(Collections.list(stEnum));
+ final Map result = new HashMap();
+ for (final Iterator itr = aSet.iterator(); itr.hasNext();) {
+ final String type = (String) itr.next();
+ final ServiceLocationEnumeration services = findServices(new ServiceType(type), null, null);
while (services.hasMoreElements()) {
- ServiceURL url = (ServiceURL) services.next();
+ final ServiceURL url = (ServiceURL) services.next();
result.put(url, Collections.list(findAttributes(url, null, null)));
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Messages.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Messages.java
index 5cc6869af..00eca9982 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/Messages.java
@@ -12,7 +12,7 @@ package org.eclipse.ecf.internal.provider.jslp;
import org.eclipse.osgi.util.NLS;
-public class Messages extends NLS {
+public final class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.provider.jslp.messages"; //$NON-NLS-1$
public static String ContainerInstantiator_0;
public static String JSLPDiscoveryContainer_0;
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
index bef10df7b..4bf0dc1f4 100644
--- 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
@@ -22,28 +22,28 @@ 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) {
+ public void addAttributes(final ServiceURL url, final 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) {
+ public void deleteAttributes(final ServiceURL url, final 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) {
+ public void deregister(final 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) {
+ public void deregister(final ServiceURL url, final List scopes) {
Trace.trace(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "deregister(ServiceURL, List)", Advertiser.class + " not present"); //$NON-NLS-1$//$NON-NLS-2$
}
@@ -62,7 +62,7 @@ public class NullPatternAdvertiser implements Advertiser {
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) {
+ } catch (final UnknownHostException e) {
Trace.catching(Activator.PLUGIN_ID, JSLPDebugOptions.METHODS_TRACING, getClass(), "getMyIP()", e); //$NON-NLS-1$
}
return null;
@@ -71,21 +71,21 @@ public class NullPatternAdvertiser implements Advertiser {
/* (non-Javadoc)
* @see ch.ethz.iks.slp.Advertiser#register(ch.ethz.iks.slp.ServiceURL, java.util.Dictionary)
*/
- public void register(ServiceURL url, Dictionary attributes) {
+ public void register(final ServiceURL url, final 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) {
+ public void register(final ServiceURL url, final List scopes, final 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) {
+ public void setLocale(final 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
index 8b70308e6..0bd55ef19 100644
--- 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
@@ -32,14 +32,14 @@ public class NullPatternLocator implements LocatorDecorator {
/* (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) {
+ public ServiceLocationEnumeration findAttributes(final ServiceURL url, final List scopes, final 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) {
+ public ServiceLocationEnumeration findAttributes(final ServiceType type, final List scopes, final 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;
}
@@ -47,7 +47,7 @@ public class NullPatternLocator implements LocatorDecorator {
/* (non-Javadoc)
* @see ch.ethz.iks.slp.Locator#findServiceTypes(java.lang.String, java.util.List)
*/
- public ServiceLocationEnumeration findServiceTypes(String namingAuthority, List scopes) {
+ public ServiceLocationEnumeration findServiceTypes(final String namingAuthority, final 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;
}
@@ -55,7 +55,7 @@ public class NullPatternLocator implements LocatorDecorator {
/* (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 {
+ public ServiceLocationEnumeration findServices(final ServiceType type, final List scopes, final 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;
}
@@ -71,14 +71,14 @@ public class NullPatternLocator implements LocatorDecorator {
/* (non-Javadoc)
* @see ch.ethz.iks.slp.Locator#setLocale(java.util.Locale)
*/
- public void setLocale(Locale locale) {
+ public void setLocale(final 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) {
+ public Map getServiceURLs(final ServiceType serviceType, final 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();
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java
index f735fb9a6..e6da8a9be 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServicePropertiesAdapter.java
@@ -38,24 +38,24 @@ public class ServicePropertiesAdapter {
private static final String WEIGHT = "x-" + ECLIPSE_ENTERPRISE_NUMBER + "-WEIGHT"; //$NON-NLS-1$ //$NON-NLS-2$
private static final String SLP_BYTE_PREFIX = "\\FF"; //$NON-NLS-1$
- private IServiceProperties serviceProperties;
+ private final IServiceProperties serviceProperties;
private String serviceName;
private int priority = ServiceInfo.DEFAULT_PRIORITY;
private int weight = ServiceInfo.DEFAULT_WEIGHT;
- public ServicePropertiesAdapter(List aList) {
+ public ServicePropertiesAdapter(final List aList) {
Assert.isNotNull(aList);
serviceProperties = new ServiceProperties();
- for (Iterator itr = aList.iterator(); itr.hasNext();) {
- String[] str = StringUtils.split((String) itr.next(), "="); //$NON-NLS-1$
+ for (final Iterator itr = aList.iterator(); itr.hasNext();) {
+ final String[] str = StringUtils.split((String) itr.next(), "="); //$NON-NLS-1$
if (str.length != 2) {
Trace.trace(Activator.PLUGIN_ID, "/debug/methods/tracing", this.getClass(), "ServicePropertiesAdapter(List)", "Skipped broken service attribute " + str); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
continue;
}
// remove the brackets "( )" from the string value which are added by jSLP for the LDAP style string representation
- String key = str[0].substring(1);
- String value = str[1].substring(0, str[1].length() - 1);
+ final String key = str[0].substring(1);
+ final String value = str[1].substring(0, str[1].length() - 1);
if (key.equalsIgnoreCase(SERVICE_ID_NAME)) {
serviceName = value;
} else if (key.equalsIgnoreCase(PRIORITY)) {
@@ -63,47 +63,47 @@ public class ServicePropertiesAdapter {
} else if (key.equalsIgnoreCase(WEIGHT)) {
weight = Integer.parseInt(value);
} else if (value.startsWith(SLP_BYTE_PREFIX)) {
- String[] strs = StringUtils.split(value.substring(4), "\\"); //$NON-NLS-1$
- byte[] b = new byte[strs.length];
+ final String[] strs = StringUtils.split(value.substring(4), "\\"); //$NON-NLS-1$
+ final byte[] b = new byte[strs.length];
for (int i = 0; i < strs.length; i++) {
- byte parseInt = (byte) Integer.parseInt(strs[i], 16);
+ final byte parseInt = (byte) Integer.parseInt(strs[i], 16);
b[i] = parseInt;
}
serviceProperties.setPropertyBytes(key, Base64.decodeFromCharArray(b));
} else if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { //$NON-NLS-1$ //$NON-NLS-2$
- serviceProperties.setProperty(key, new Boolean(value));
+ serviceProperties.setProperty(key, Boolean.valueOf(value));
} else if (isInteger(value)) {
- serviceProperties.setProperty(key, new Integer(value));
+ serviceProperties.setProperty(key, Integer.valueOf(value));
} else {
serviceProperties.setProperty(key, value);
}
}
}
- public ServicePropertiesAdapter(IServiceInfo sInfo) {
+ public ServicePropertiesAdapter(final IServiceInfo sInfo) {
Assert.isNotNull(sInfo);
- IServiceID sID = sInfo.getServiceID();
+ final IServiceID sID = sInfo.getServiceID();
Assert.isNotNull(sID);
- IServiceProperties sp = sInfo.getServiceProperties();
+ final IServiceProperties sp = sInfo.getServiceProperties();
Assert.isNotNull(sp);
serviceProperties = new ServiceProperties(sp);
if (sInfo.getPriority() >= 0) {
- serviceProperties.setPropertyString(PRIORITY, new Integer(sInfo.getPriority()).toString());
+ serviceProperties.setPropertyString(PRIORITY, Integer.toString(sInfo.getPriority()));
}
if (sInfo.getWeight() >= 0) {
- serviceProperties.setPropertyString(WEIGHT, new Integer(sInfo.getWeight()).toString());
+ serviceProperties.setPropertyString(WEIGHT, Integer.toString(sInfo.getWeight()));
}
if (sID.getServiceName() != null) {
serviceProperties.setPropertyString(SERVICE_ID_NAME, sID.getServiceName());
}
}
- private boolean isInteger(String value) {
+ private boolean isInteger(final String value) {
try {
Integer.parseInt(value);
return true;
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return false;
}
}
@@ -113,17 +113,17 @@ public class ServicePropertiesAdapter {
}
public Dictionary toProperties() {
- Dictionary dict = new Properties();
- Enumeration propertyNames = serviceProperties.getPropertyNames();
+ final Dictionary dict = new Properties();
+ final Enumeration propertyNames = serviceProperties.getPropertyNames();
while (propertyNames.hasMoreElements()) {
- String key = (String) propertyNames.nextElement();
- byte[] propertyBytes = serviceProperties.getPropertyBytes(key);
+ final String key = (String) propertyNames.nextElement();
+ final byte[] propertyBytes = serviceProperties.getPropertyBytes(key);
if (propertyBytes != null) {
- byte[] encode = Base64.encodeToCharArray(propertyBytes);
- StringBuffer buf = new StringBuffer();
+ final byte[] encode = Base64.encodeToCharArray(propertyBytes);
+ final StringBuffer buf = new StringBuffer();
buf.append(SLP_BYTE_PREFIX);
for (int i = 0; i < encode.length; i++) {
- buf.append("\\"); //$NON-NLS-1$
+ buf.append('\\');
buf.append(Integer.toHexString(encode[i]));
}
dict.put(key, buf.toString());
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java
index 4412a2b6d..a773393c8 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/internal/provider/jslp/ServiceURLAdapter.java
@@ -26,39 +26,39 @@ public class ServiceURLAdapter {
private URI uri;
private IServiceID serviceID;
- public ServiceURLAdapter(ServiceURL aServiceURL, String aServiceName) {
+ public ServiceURLAdapter(final ServiceURL aServiceURL, final String aServiceName) {
this(aServiceURL, aServiceName, new String[0]);
}
- public ServiceURLAdapter(ServiceURL aServiceURL, String aServiceName, String[] scopes) {
+ public ServiceURLAdapter(final ServiceURL aServiceURL, final String aServiceName, final String[] scopes) {
Assert.isNotNull(aServiceURL);
Assert.isNotNull(scopes);
setIServiceID(aServiceURL, aServiceName, scopes);
setURI(aServiceURL);
}
- private void setURI(ServiceURL aServiceURL) {
- StringBuffer buf = new StringBuffer();
+ private void setURI(final ServiceURL aServiceURL) {
+ final StringBuffer buf = new StringBuffer();
String protocol = aServiceURL.getProtocol();
if (protocol == null) {
protocol = "unknown"; //$NON-NLS-1$
}
buf.append(protocol);
buf.append("://"); //$NON-NLS-1$
- String userInfo = aServiceURL.getUserInfo();
+ final String userInfo = aServiceURL.getUserInfo();
if (!"".equals(userInfo)) { //$NON-NLS-1$
buf.append(userInfo);
- buf.append("@"); //$NON-NLS-1$
+ buf.append('@');
}
buf.append(aServiceURL.getHost());
- buf.append(":"); //$NON-NLS-1$
+ buf.append(':');
buf.append(aServiceURL.getPort());
buf.append(aServiceURL.getURLPath());
uri = URI.create(buf.toString());
}
- private void setIServiceID(ServiceURL aServiceURL, String aServiceName, String[] scopes) {
- Namespace namespace = IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME);
+ private void setIServiceID(final ServiceURL aServiceURL, final String aServiceName, final String[] scopes) {
+ final Namespace namespace = IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME);
serviceID = (IServiceID) namespace.createInstance(new Object[] {aServiceURL, aServiceName, scopes});
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java
index f0c43564e..4f4c65dc8 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/container/JSLPServiceInfo.java
@@ -25,7 +25,7 @@ public class JSLPServiceInfo extends ServiceInfo implements IServiceInfo {
private static final long serialVersionUID = 6828789192986625259L;
- public JSLPServiceInfo(URI anURI, IServiceID serviceID, int priority, int weight, IServiceProperties props) {
+ public JSLPServiceInfo(final URI anURI, final IServiceID serviceID, final int priority, final int weight, final IServiceProperties props) {
super(anURI, serviceID, priority, weight, props);
}
@@ -33,24 +33,24 @@ public class JSLPServiceInfo extends ServiceInfo implements IServiceInfo {
* @param serviceID
* @deprecated
*/
- public JSLPServiceInfo(IServiceID serviceID) {
+ public JSLPServiceInfo(final IServiceID serviceID) {
super(null, serviceID, DEFAULT_PRIORITY, DEFAULT_WEIGHT, new ServiceProperties());
}
- public JSLPServiceInfo(IServiceInfo aSI) throws IDCreateException {
+ public JSLPServiceInfo(final IServiceInfo aSI) throws IDCreateException {
this(aSI.getLocation(), ServiceIDFactory.getDefault().createServiceID(IDFactory.getDefault().getNamespaceByName(JSLPNamespace.NAME), aSI.getServiceID().getServiceTypeID(), aSI.getServiceID().getServiceName()), aSI.getPriority(), aSI.getWeight(), aSI.getServiceProperties());
}
- public JSLPServiceInfo(ServiceURLAdapter anAdapter, int priority, int weight, ServicePropertiesAdapter aServicePropertiesAdapter) {
+ public JSLPServiceInfo(final ServiceURLAdapter anAdapter, final int priority, final int weight, final ServicePropertiesAdapter aServicePropertiesAdapter) {
this(anAdapter.getURI(), anAdapter.getIServiceID(), priority, weight, aServicePropertiesAdapter.toServiceProperties());
}
public ServiceURL getServiceURL() throws ServiceLocationException {
- IServiceTypeID stid = getServiceID().getServiceTypeID();
- URI location = getLocation();
- String scheme = location.getScheme();
- String authority = location.getAuthority();
- String path = location.getPath() == null ? "" : location.getPath(); //$NON-NLS-1$
+ final IServiceTypeID stid = getServiceID().getServiceTypeID();
+ final URI location = getLocation();
+ final String scheme = location.getScheme();
+ final String authority = location.getAuthority();
+ final String path = location.getPath() == null ? "" : location.getPath(); //$NON-NLS-1$
return new ServiceURL(stid.getInternal() + "://" + scheme + "://" + authority + path, ServiceURL.LIFETIME_PERMANENT); //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java
index bdd141327..044bbb68e 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPNamespace.java
@@ -37,9 +37,9 @@ public class JSLPNamespace extends Namespace {
// create by jSLP ServiceURL
} else if (parameters[0] instanceof ServiceURL) {
- ServiceURL anURL = (ServiceURL) parameters[0];
- IServiceTypeID stid = new JSLPServiceTypeID(this, anURL, (String[]) parameters[2]);
- String serviceName = (String) (parameters[1] != null ? parameters[1] : anURL.getHost());
+ final ServiceURL anURL = (ServiceURL) parameters[0];
+ final IServiceTypeID stid = new JSLPServiceTypeID(this, anURL, (String[]) parameters[2]);
+ final String serviceName = (String) (parameters[1] != null ? parameters[1] : anURL.getHost());
return new JSLPServiceID(this, stid, serviceName);
// conversion call where conversion isn't necessary
@@ -48,15 +48,15 @@ public class JSLPNamespace extends Namespace {
// convert from IServiceID to IServiceTypeID, String
} else if (parameters[0] instanceof IServiceID && parameters.length == 1) {
- IServiceID anId = (IServiceID) parameters[0];
- Object[] newParams = new Object[2];
+ final IServiceID anId = (IServiceID) parameters[0];
+ final Object[] newParams = new Object[2];
newParams[0] = anId.getServiceTypeID();
newParams[1] = anId.getName();
return createInstance(newParams);
// create by ECF discovery generic IServiceTypeID (but not JSLPServiceID!!!)
} else if (parameters[0] instanceof IServiceTypeID) {
- IServiceTypeID stid = (IServiceTypeID) parameters[0];
+ final IServiceTypeID stid = (IServiceTypeID) parameters[0];
parameters[0] = stid.getName();
return createInstance(parameters);
@@ -72,15 +72,15 @@ public class JSLPNamespace extends Namespace {
// create by ECF discovery generic String representation
} else if (parameters[0] instanceof String && ((String) parameters[0]).startsWith("_")) { //$NON-NLS-1$
- String type = (String) parameters[0];
- String name = (String) parameters[1];
- IServiceTypeID stid = new JSLPServiceTypeID(this, new ServiceTypeID(this, type));
+ final String type = (String) parameters[0];
+ final String name = (String) parameters[1];
+ final IServiceTypeID stid = new JSLPServiceTypeID(this, new ServiceTypeID(this, type));
return new JSLPServiceID(this, stid, name);
// create by "jslp:..."
} else if (parameters[0] instanceof String && ((String) parameters[0]).startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) {
- String str = (String) parameters[0];
- int index = str.indexOf(Namespace.SCHEME_SEPARATOR);
+ final String str = (String) parameters[0];
+ final int index = str.indexOf(Namespace.SCHEME_SEPARATOR);
parameters[0] = str.substring(index + 1);
return createInstance(parameters);
diff --git a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java
index 8a8ef2804..ba8eea314 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jslp/src/org/eclipse/ecf/provider/jslp/identity/JSLPServiceTypeID.java
@@ -41,7 +41,7 @@ public class JSLPServiceTypeID extends ServiceTypeID {
final String na = st.getNamingAuthority();
String str = st.toString();
- if (na.equals("")) { //$NON-NLS-1$
+ if ("".equals(na)) { //$NON-NLS-1$
namingAuthority = DEFAULT_NA;
} else {
namingAuthority = na;
@@ -67,7 +67,7 @@ public class JSLPServiceTypeID extends ServiceTypeID {
}
// set the protocol if provided
- String protocol = anURL.getProtocol();
+ final String protocol = anURL.getProtocol();
if (protocol != null) {
protocols = new String[] {protocol};
createType();
@@ -77,28 +77,29 @@ public class JSLPServiceTypeID extends ServiceTypeID {
JSLPServiceTypeID(final Namespace namespace, final IServiceTypeID type) {
super(namespace, type);
- StringBuffer buf = new StringBuffer("service:"); //$NON-NLS-1$
+ final StringBuffer buf = new StringBuffer("service:"); //$NON-NLS-1$
for (int i = 0; i < services.length; i++) {
buf.append(services[i]);
// #228876
if (!namingAuthority.equalsIgnoreCase(JSLP_DEFAULT_NA) && i == 1) {
- buf.append("."); //$NON-NLS-1$
+ buf.append('.');
buf.append(namingAuthority);
}
- buf.append(":"); //$NON-NLS-1$
+ buf.append(':');
}
// remove dangling colon
- String string = buf.toString();
+ final String string = buf.toString();
st = new ServiceType(string.substring(0, string.length() - 1));
}
JSLPServiceTypeID(final Namespace namespace, final ServiceType aServiceType) {
this(namespace, aServiceType.toString());
+
+ // remove the SLP "service" prefix
final String[] newServices = new String[services.length - 1];
- for (int i = 0; i < services.length - 1; i++) {
- newServices[i] = services[i + 1];
- }
+ System.arraycopy(services, 1, newServices, 0, newServices.length);
services = newServices;
+
createType();
}

Back to the top