Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2009-02-20 08:52:50 +0000
committermkuppe2009-02-20 08:52:50 +0000
commit823b8577c66ab314df4f1d5a165fc4116d1ff83f (patch)
treea854e51e04ee98d53c3cb407f834152076e06353 /providers
parent78e5371cf244388791e9c84564969ff3f6b933d1 (diff)
downloadorg.eclipse.ecf-823b8577c66ab314df4f1d5a165fc4116d1ff83f.tar.gz
org.eclipse.ecf-823b8577c66ab314df4f1d5a165fc4116d1ff83f.tar.xz
org.eclipse.ecf-823b8577c66ab314df4f1d5a165fc4116d1ff83f.zip
Code cleanups
Diffstat (limited to 'providers')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java32
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/SimpleFIFOQueue.java18
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java98
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java12
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceID.java2
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceTypeID.java2
7 files changed, 85 insertions, 81 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
index 1ef139a91..dea4fabfe 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/JMDNSPlugin.java
@@ -71,28 +71,28 @@ public class JMDNSPlugin implements BundleActivator {
/**
* This method is called upon plug-in activation
*/
- public void start(BundleContext ctxt) throws Exception {
+ public void start(final BundleContext ctxt) throws Exception {
this.context = ctxt;
LOCALHOST = InetAddress.getLocalHost();
- Properties props = new Properties();
+ final Properties props = new Properties();
props.put(IDiscoveryService.CONTAINER_ID, IDFactory.getDefault().createStringID("org.eclipse.ecf.provider.jmdns.container.JMDNSDiscoveryContainer")); //$NON-NLS-1$
props.put(IDiscoveryService.CONTAINER_NAME, NAME);
- props.put(Constants.SERVICE_RANKING, new Integer(750));
+ props.put(Constants.SERVICE_RANKING, Integer.toString(750));
context.registerService(IDiscoveryService.class.getName(), new ServiceFactory() {
private volatile JMDNSDiscoveryContainer jdc;
/* (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 JMDNSDiscoveryContainer(LOCALHOST);
jdc.connect(null, null);
- } catch (IDCreateException e) {
+ } catch (final IDCreateException e) {
Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSPlugin.PLUGIN_ID + "/debug/methods/catching", this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (ContainerConnectException e) {
+ } catch (final ContainerConnectException e) {
Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSPlugin.PLUGIN_ID + "/debug/methods/catching", this.getClass(), "getService(Bundle, ServiceRegistration)", e); //$NON-NLS-1$ //$NON-NLS-2$
jdc = null;
}
@@ -103,7 +103,7 @@ public class JMDNSPlugin 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
}
@@ -112,15 +112,16 @@ public class JMDNSPlugin implements BundleActivator {
}
protected Bundle getBundle() {
- if (context == null)
+ if (context == null) {
return null;
+ }
return context.getBundle();
}
/**
* This method is called when the plug-in is stopped
*/
- public void stop(BundleContext ctxt) throws Exception {
+ public void stop(final BundleContext ctxt) throws Exception {
if (serviceRegistration != null) {
serviceRegistration.unregister();
serviceRegistration = null;
@@ -149,10 +150,11 @@ public class JMDNSPlugin implements BundleActivator {
* @param string
* @param t
*/
- public void logException(String string, Throwable t) {
+ public void logException(final String string, final Throwable t) {
getLogService();
- if (logService != null)
+ if (logService != null) {
logService.log(LogService.LOG_ERROR, string, t);
+ }
}
protected LogService getLogService() {
@@ -161,18 +163,20 @@ public class JMDNSPlugin implements BundleActivator {
logServiceTracker.open();
}
logService = (LogService) logServiceTracker.getService();
- if (logService == null)
+ if (logService == null) {
logService = new SystemLogService(PLUGIN_ID);
+ }
return logService;
}
/**
* @param errorString
*/
- public void logError(String errorString) {
+ public void logError(final String errorString) {
getLogService();
- if (logService != null)
+ if (logService != null) {
logService.log(LogService.LOG_ERROR, errorString);
+ }
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java
index fd92121a0..8ffe206d0 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/Messages.java
@@ -16,7 +16,7 @@ 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.jmdns.messages"; //$NON-NLS-1$
public static String ContainerInstantiator_EXCEPTION_CONTAINER_CREATE;
public static String ContainerInstantiator_EXCEPTION_GETTING_INETADDRESS;
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/SimpleFIFOQueue.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/SimpleFIFOQueue.java
index 1b6a11e81..a6da99a48 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/SimpleFIFOQueue.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/internal/provider/jmdns/SimpleFIFOQueue.java
@@ -15,16 +15,16 @@ import java.util.LinkedList;
import java.util.List;
public class SimpleFIFOQueue {
- List list;
+ private final List list;
- boolean stopped;
+ private boolean stopped;
public SimpleFIFOQueue() {
list = new LinkedList();
stopped = false;
}
- public synchronized boolean enqueue(Object obj) {
+ public synchronized boolean enqueue(final Object obj) {
if (isStopped() || obj == null) {
return false;
}
@@ -38,7 +38,7 @@ public class SimpleFIFOQueue {
}
public synchronized Object dequeue() {
- Object val = peekQueue();
+ final Object val = peekQueue();
if (val != null) {
removeHead();
}
@@ -51,14 +51,14 @@ public class SimpleFIFOQueue {
return null;
try {
wait();
- } catch (Exception e) {
+ } catch (final Exception e) {
return null;
}
}
return list.get(0);
}
- public synchronized Object peekQueue(long waitMS) {
+ public synchronized Object peekQueue(final long waitMS) {
if (waitMS == 0)
return peekQueue();
if (stopped) {
@@ -66,7 +66,7 @@ public class SimpleFIFOQueue {
}
try {
wait(waitMS);
- } catch (Exception e) {
+ } catch (final Exception e) {
return null;
}
if (isEmpty())
@@ -97,7 +97,7 @@ public class SimpleFIFOQueue {
}
public synchronized Object[] flush() {
- Object[] out = list.toArray();
+ final Object[] out = list.toArray();
list.clear();
close();
return out;
@@ -109,7 +109,7 @@ public class SimpleFIFOQueue {
}
public String toString() {
- StringBuffer sb = new StringBuffer("SimpleFIFOQueue["); //$NON-NLS-1$
+ final StringBuffer sb = new StringBuffer("SimpleFIFOQueue["); //$NON-NLS-1$
sb.append(list).append("]"); //$NON-NLS-1$
return sb.toString();
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java
index 90411f0ac..a45f5e409 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/container/JMDNSDiscoveryContainer.java
@@ -52,7 +52,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
SimpleFIFOQueue queue = null;
Thread notificationThread = null;
- public JMDNSDiscoveryContainer(InetAddress addr) {
+ public JMDNSDiscoveryContainer(final InetAddress addr) {
super(JMDNSNamespace.NAME, new DiscoveryContainerConfig(IDFactory.getDefault().createStringID(JMDNSDiscoveryContainer.class.getName() + ";" + addr.toString() + ";" + instanceCount++))); //$NON-NLS-1$ //$NON-NLS-2$
Assert.isNotNull(addr);
intf = addr;
@@ -81,7 +81,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
/* (non-Javadoc)
* @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, org.eclipse.ecf.core.security.IConnectContext)
*/
- public void connect(ID targetID1, IConnectContext joinContext) throws ContainerConnectException {
+ public void connect(final ID targetID1, final IConnectContext joinContext) throws ContainerConnectException {
synchronized (lock) {
if (disposed)
throw new ContainerConnectException(Messages.JMDNSDiscoveryContainer_EXCEPTION_CONTAINER_DISPOSED);
@@ -111,12 +111,12 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
for (;;) {
if (Thread.currentThread().isInterrupted())
break;
- Runnable runnable = (Runnable) queue.dequeue();
+ final Runnable runnable = (Runnable) queue.dequeue();
if (Thread.currentThread().isInterrupted() || runnable == null)
break;
try {
runnable.run();
- } catch (Throwable t) {
+ } catch (final Throwable t) {
handleRuntimeException(t);
}
}
@@ -125,7 +125,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
notificationThread.start();
}
- protected void handleRuntimeException(Throwable t) {
+ protected void handleRuntimeException(final Throwable t) {
// Nothing to do except log
JMDNSPlugin.getDefault().logException("handleRuntimeException", t); //$NON-NLS-1$
}
@@ -138,7 +138,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
if (getConnectedID() == null || disposed) {
return;
}
- ID connectedID = getConnectedID();
+ final ID connectedID = getConnectedID();
fireContainerEvent(new ContainerDisconnectingEvent(this.getID(), connectedID));
queue.close();
notificationThread = null;
@@ -155,13 +155,13 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
/* (non-Javadoc)
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)
*/
- public IServiceInfo getServiceInfo(IServiceID service) {
+ public IServiceInfo getServiceInfo(final IServiceID service) {
Assert.isNotNull(service);
synchronized (lock) {
try {
- ServiceInfo serviceInfo = jmdns.getServiceInfo(service.getServiceTypeID().getInternal(), service.getServiceName());
+ final ServiceInfo serviceInfo = jmdns.getServiceInfo(service.getServiceTypeID().getInternal(), service.getServiceName());
return (serviceInfo == null) ? null : createIServiceInfoFromServiceInfo(serviceInfo);
- } catch (Exception e) {
+ } catch (final Exception e) {
Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getServiceInfo", e); //$NON-NLS-1$
return null;
}
@@ -173,10 +173,10 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
*/
public IServiceInfo[] getServices() {
synchronized (lock) {
- IServiceTypeID[] serviceTypeArray = getServiceTypes();
- List results = new ArrayList();
+ final IServiceTypeID[] serviceTypeArray = getServiceTypes();
+ final List results = new ArrayList();
for (int i = 0; i < serviceTypeArray.length; i++) {
- IServiceTypeID stid = serviceTypeArray[i];
+ final IServiceTypeID stid = serviceTypeArray[i];
if (stid != null)
results.addAll(Arrays.asList(getServices(stid)));
}
@@ -187,23 +187,23 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
/* (non-Javadoc)
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)
*/
- public IServiceInfo[] getServices(IServiceTypeID type) {
+ public IServiceInfo[] getServices(final IServiceTypeID type) {
Assert.isNotNull(type);
- List serviceInfos = new ArrayList();
+ final List serviceInfos = new ArrayList();
synchronized (lock) {
// We don't know the naming authority yet (it's part of the service properties)
- for (Iterator itr = serviceTypes.iterator(); itr.hasNext();) {
- IServiceTypeID serviceType = (IServiceTypeID) itr.next();
+ for (final Iterator itr = serviceTypes.iterator(); itr.hasNext();) {
+ final IServiceTypeID serviceType = (IServiceTypeID) itr.next();
if (Arrays.equals(serviceType.getServices(), type.getServices()) && Arrays.equals(serviceType.getProtocols(), type.getProtocols()) && Arrays.equals(serviceType.getScopes(), type.getScopes())) {
- ServiceInfo[] infos = jmdns.list(type.getInternal());
+ final ServiceInfo[] infos = jmdns.list(type.getInternal());
for (int i = 0; i < infos.length; i++) {
try {
if (infos[i] != null) {
- IServiceInfo si = createIServiceInfoFromServiceInfo(infos[i]);
+ final IServiceInfo si = createIServiceInfoFromServiceInfo(infos[i]);
if (si != null)
serviceInfos.add(si);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Trace.catching(JMDNSPlugin.PLUGIN_ID, JMDNSDebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "getServices", e); //$NON-NLS-1$
}
}
@@ -225,7 +225,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
/* (non-Javadoc)
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)
*/
- public void registerService(IServiceInfo serviceInfo) throws ECFException {
+ public void registerService(final IServiceInfo serviceInfo) throws ECFException {
Assert.isNotNull(serviceInfo);
final ServiceInfo svcInfo = createServiceInfoFromIServiceInfo(serviceInfo);
checkServiceInfo(svcInfo);
@@ -239,7 +239,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
/* (non-Javadoc)
* @see org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)
*/
- public void unregisterService(IServiceInfo serviceInfo) {
+ public void unregisterService(final IServiceInfo serviceInfo) {
Assert.isNotNull(serviceInfo);
final ServiceInfo si = createServiceInfoFromIServiceInfo(serviceInfo);
jmdns.unregisterService(si);
@@ -247,11 +247,11 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
/**************************** JMDNS listeners ***********************************/
- private void runInThread(Runnable runnable) {
+ private void runInThread(final Runnable runnable) {
queue.enqueue(runnable);
}
- private void logError(String errorString) {
+ private void logError(final String errorString) {
JMDNSPlugin.getDefault().logError(errorString);
}
@@ -306,18 +306,18 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
Trace.trace(JMDNSPlugin.PLUGIN_ID, "serviceAdded(" + arg0.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
runInThread(new Runnable() {
public void run() {
- String serviceType = arg0.getType();
- String serviceName = arg0.getName();
+ final String serviceType = arg0.getType();
+ final String serviceName = arg0.getName();
IServiceInfo aServiceInfo = null;
synchronized (lock) {
if (getConnectedID() == null || disposed) {
return;
}
// explicitly get the service to determine the naming authority (part of the service properties)
- ServiceInfo info = jmdns.getServiceInfo(serviceType, serviceName);
+ final ServiceInfo info = jmdns.getServiceInfo(serviceType, serviceName);
try {
aServiceInfo = createIServiceInfoFromServiceInfo(info);
- } catch (Exception e) {
+ } catch (final Exception e) {
return;
}
}
@@ -326,7 +326,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
});
}
- Collection getAllListeners(IServiceTypeID serviceTypeID) {
+ Collection getAllListeners(final IServiceTypeID serviceTypeID) {
return super.getListeners(serviceTypeID);
}
@@ -349,7 +349,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
});
}
- void fireUndiscovered(IServiceInfo serviceInfo) {
+ void fireUndiscovered(final IServiceInfo serviceInfo) {
fireServiceUndiscovered(new ServiceContainerEvent(serviceInfo, getID()));
}
@@ -360,26 +360,26 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
Trace.trace(JMDNSPlugin.PLUGIN_ID, "serviceResolved(" + arg0.getName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
}
- void fireDiscovered(IServiceInfo serviceInfo) {
+ void fireDiscovered(final IServiceInfo serviceInfo) {
fireServiceDiscovered(new ServiceContainerEvent(serviceInfo, getID()));
}
/*******************************************/
- private void checkServiceInfo(ServiceInfo serviceInfo) throws ECFException {
+ private void checkServiceInfo(final ServiceInfo serviceInfo) throws ECFException {
final String serviceName = serviceInfo.getName();
if (serviceName == null)
throw new ECFException(Messages.JMDNSDiscoveryContainer_SERVICE_NAME_NOT_NULL);
}
- private IServiceTypeID createServiceTypeID(String type) {
- IServiceID serviceID = createServiceID(type, null);
+ private IServiceTypeID createServiceTypeID(final String type) {
+ final IServiceID serviceID = createServiceID(type, null);
if (serviceID == null)
return null;
return serviceID.getServiceTypeID();
}
IServiceInfo createIServiceInfoFromServiceEvent(final ServiceEvent event) throws Exception {
- ServiceInfo si = event.getInfo();
+ final ServiceInfo si = event.getInfo();
if (si != null)
return createIServiceInfoFromServiceInfo(si);
// else service info from JMDNS is null...and we need to create IServiceInfo ourselves
@@ -391,8 +391,8 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
IServiceInfo createIServiceInfoFromServiceInfo(final ServiceInfo serviceInfo) throws Exception {
Assert.isNotNull(serviceInfo);
- String st = serviceInfo.getType();
- String n = serviceInfo.getName();
+ final String st = serviceInfo.getType();
+ final String n = serviceInfo.getName();
if (st == null || n == null)
throw new InvalidObjectException(Messages.JMDNSDiscoveryContainer_EXCEPTION_SERVICEINFO_INVALID);
final InetAddress addr = serviceInfo.getAddress();
@@ -414,11 +414,11 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
} else {
final byte[] bytes = serviceInfo.getPropertyBytes(key);
try {
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
- Object object = in.readObject();
+ final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+ final Object object = in.readObject();
in.close();
props.put(key, object);
- } catch (StreamCorruptedException ioe) {
+ } catch (final StreamCorruptedException ioe) {
props.put(key, serviceInfo.getPropertyString(key));
}
}
@@ -431,7 +431,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
return new org.eclipse.ecf.discovery.ServiceInfo(uri, sID, priority, weight, new ServiceProperties(props));
}
- ServiceID createServiceID(String type, String name) {
+ ServiceID createServiceID(final String type, final String name) {
ServiceID id = null;
try {
id = (ServiceID) ServiceIDFactory.getDefault().createServiceID(getServicesNamespace(), type, name);
@@ -442,7 +442,7 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
return id;
}
- private ServiceInfo createServiceInfoFromIServiceInfo(IServiceInfo serviceInfo) {
+ private ServiceInfo createServiceInfoFromIServiceInfo(final IServiceInfo serviceInfo) {
if (serviceInfo == null)
return null;
final IServiceID sID = serviceInfo.getServiceID();
@@ -455,15 +455,15 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
if (val instanceof String) {
props.put(key, val);
} else if (val instanceof Serializable) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
- ObjectOutputStream out = new ObjectOutputStream(bos);
+ final ObjectOutputStream out = new ObjectOutputStream(bos);
out.writeObject(val);
out.close();
- } catch (IOException e1) {
+ } catch (final IOException e1) {
e1.printStackTrace();
}
- byte[] buf = bos.toByteArray();
+ final byte[] buf = bos.toByteArray();
props.put(key, buf);
// } else if (svcProps.getPropertyBytes(key) != null) {
// byte[] bytes = svcProps.getPropertyBytes(key);
@@ -474,16 +474,16 @@ public class JMDNSDiscoveryContainer extends AbstractDiscoveryContainerAdapter i
}
}
// Add URI scheme to props
- URI location = serviceInfo.getLocation();
+ final URI location = serviceInfo.getLocation();
if (location != null) {
props.put(SCHEME_PROPERTY, location.getScheme());
- String path = location.getPath();
+ final String path = location.getPath();
if (path != null)
props.put(URI_PATH_PROPERTY, path);
}
props.put(NAMING_AUTHORITY_PROPERTY, serviceInfo.getServiceID().getServiceTypeID().getNamingAuthority());
- int priority = (serviceInfo.getPriority() == -1) ? 0 : serviceInfo.getPriority();
- int weight = (serviceInfo.getWeight() == -1) ? 0 : serviceInfo.getWeight();
+ final int priority = (serviceInfo.getPriority() == -1) ? 0 : serviceInfo.getPriority();
+ final int weight = (serviceInfo.getWeight() == -1) ? 0 : serviceInfo.getWeight();
final String serviceName = sID.getServiceName() == null ? location.getHost() : sID.getServiceName();
final ServiceInfo si = ServiceInfo.create(sID.getServiceTypeID().getInternal(), serviceName, (location.getPort() == -1) ? 65535 : location.getPort(), weight, priority, props);
return si;
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
index 6daf911fa..3dd653f2a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSNamespace.java
@@ -30,13 +30,13 @@ public class JMDNSNamespace extends Namespace {
super();
}
- private String getInitFromExternalForm(Object[] args) {
+ private String getInitFromExternalForm(final Object[] args) {
if (args == null || args.length < 1 || args[0] == null)
return null;
if (args[0] instanceof String) {
- String arg = (String) args[0];
+ final String arg = (String) args[0];
if (arg.startsWith(getScheme() + Namespace.SCHEME_SEPARATOR)) {
- int index = arg.indexOf(Namespace.SCHEME_SEPARATOR);
+ final int index = arg.indexOf(Namespace.SCHEME_SEPARATOR);
if (index >= arg.length())
return null;
return arg.substring(index + 1);
@@ -48,10 +48,10 @@ public class JMDNSNamespace extends Namespace {
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.Namespace#createInstance(java.lang.Object[])
*/
- public ID createInstance(Object[] parameters) {
+ public ID createInstance(final Object[] parameters) {
String type = null;
try {
- String init = getInitFromExternalForm(parameters);
+ final String init = getInitFromExternalForm(parameters);
if (init != null)
type = init;
else {
@@ -65,7 +65,7 @@ public class JMDNSNamespace extends Namespace {
} else
throw new IDCreateException(Messages.JMDNSNamespace_EXCEPTION_TYPE_PARAM_NOT_STRING);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new IDCreateException(NLS.bind("{0} createInstance()", getName()), e); //$NON-NLS-1$
}
final JMDNSServiceTypeID stid = new JMDNSServiceTypeID(this, type);
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceID.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceID.java
index e7ad2664c..313e37bf4 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceID.java
@@ -18,7 +18,7 @@ public class JMDNSServiceID extends ServiceID {
private static final long serialVersionUID = 8389531866888790264L;
- public JMDNSServiceID(Namespace namespace, IServiceTypeID type, String name) {
+ public JMDNSServiceID(final Namespace namespace, final IServiceTypeID type, final String name) {
super(namespace, type, name);
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceTypeID.java b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceTypeID.java
index 7159ad40e..fc2a3f953 100644
--- a/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceTypeID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.jmdns/src/org/eclipse/ecf/provider/jmdns/identity/JMDNSServiceTypeID.java
@@ -21,7 +21,7 @@ public class JMDNSServiceTypeID extends ServiceTypeID {
private static final long serialVersionUID = 7549266915001431139L;
- protected JMDNSServiceTypeID(Namespace namespace, String type) {
+ protected JMDNSServiceTypeID(final Namespace namespace, final String type) {
super(namespace, type);
}

Back to the top