Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis@composent.com2010-12-05 22:03:03 +0000
committerslewis@composent.com2010-12-05 22:03:03 +0000
commit4204c15b88ea309bbe3cbc07f08ebfa476b88af8 (patch)
tree633149a05f5d4f4248047e6d4077f31e3f879f75 /incubation
parentddffd2ae2b280d70ecb07acdb8fe82b49db39fc1 (diff)
downloadorg.eclipse.ecf-4204c15b88ea309bbe3cbc07f08ebfa476b88af8.tar.gz
org.eclipse.ecf-4204c15b88ea309bbe3cbc07f08ebfa476b88af8.tar.xz
org.eclipse.ecf-4204c15b88ea309bbe3cbc07f08ebfa476b88af8.zip
rsa simplifications
Diffstat (limited to 'incubation')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java4
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Discovery.java38
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java17
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java68
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java5
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java39
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java20
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java73
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java34
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java46
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java43
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java11
12 files changed, 201 insertions, 197 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java
index 307edff4d..696dc5155 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/DebugOptions.java
@@ -30,4 +30,8 @@ public interface DebugOptions {
public static final String CONTAINERSELECTOR = DEBUG + "/containerselector"; //$NON-NLS-1$
+ public static final String DISCOVERY = DEBUG + "/discovery"; //$NON-NLS-1$
+
+ public static final String ENDPOINTDESCRIPTIONREADER = "/endpointdescriptionreader";
+
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Discovery.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Discovery.java
index 54dc00c48..b918c3c9c 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Discovery.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Discovery.java
@@ -19,8 +19,6 @@ import java.util.Map;
import java.util.Properties;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.discovery.IDiscoveryAdvertiser;
import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceInfo;
@@ -48,8 +46,6 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
public class Discovery {
- private static final boolean DEBUG = false;
-
private BundleContext context;
private IExecutor executor;
@@ -122,7 +118,7 @@ public class Discovery {
eventQueue.queueListeners(listeners.entrySet(), new EventDispatcher() {
public void dispatchEvent(Object eventListener,
Object listenerObject, int eventAction, Object eventObject) {
-
+ final String logMethodName = "dispatchEvent";
final EndpointListenerEvent event = (EndpointListenerEvent) eventObject;
final EndpointListener endpointListener = event
.getEndpointListener();
@@ -142,7 +138,7 @@ public class Discovery {
+ endpointListener + " description="
+ endpointDescription + " matchingFilter="
+ matchingFilter;
- logError(message, e);
+ logError(logMethodName, message, e);
} catch (LinkageError e) {
String message = "LinkageError in EndpointListener listener="
+ endpointListener
@@ -150,7 +146,7 @@ public class Discovery {
+ endpointDescription
+ " matchingFilter="
+ matchingFilter;
- logError(message, e);
+ logError(logMethodName, message, e);
} catch (AssertionError e) {
String message = "AssertionError in EndpointListener listener="
+ endpointListener
@@ -158,7 +154,7 @@ public class Discovery {
+ endpointDescription
+ " matchingFilter="
+ matchingFilter;
- logError(message, e);
+ logError(logMethodName, message, e);
}
}
});
@@ -199,12 +195,9 @@ public class Discovery {
bundleTracker.open();
}
- private void logError(String message, Throwable e) {
- Activator a = Activator.getDefault();
- if (a != null)
- a.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR,
- message, e)); //$NON-NLS-1$
-
+ private void logError(String methodName, String message, Throwable e) {
+ LogUtility.logError(methodName, DebugOptions.DISCOVERY,
+ this.getClass(), message, e);
}
public void close() {
@@ -376,22 +369,15 @@ public class Discovery {
}
} else {
- if (DEBUG)
- logInfo("No matching EndpointListeners found for "
- + (discovered ? "discovered" : "undiscovered")
- + " endpointDescription=" + endpointDescription);
+ LogUtility.logWarning("queueEndpointDescription",
+ DebugOptions.DISCOVERY, this.getClass(),
+ "No matching EndpointListeners found for "
+ + (discovered ? "discovered" : "undiscovered")
+ + " endpointDescription=" + endpointDescription);
}
}
- private void logInfo(String info) {
- log(new Status(IStatus.INFO, Activator.PLUGIN_ID, IStatus.INFO, info,
- null));
- }
-
- private void log(IStatus status) {
- }
-
private void processInitialLocatorServices(final IDiscoveryLocator locator,
final LocatorServiceListener locatorListener) {
IProgressRunnable runnable = new IProgressRunnable() {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
index 5ae3410f8..c7025cdaf 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
@@ -17,6 +17,8 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
@@ -114,21 +116,14 @@ public class EndpointDescriptionBundleTrackerCustomizer implements
try {
return builder.readEndpointDescriptions(fileURL.openStream());
} catch (Exception e) {
- // log
- logError("Exception creating endpoint descriptions from fileURL="
- + fileURL, e);
+ LogUtility.logError("handleEndpointDescriptionFile", DebugOptions.DISCOVERY,
+ this.getClass(), new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+ IStatus.ERROR, ("Exception creating endpoint descriptions from fileURL="
+ + fileURL), e));
return null;
}
}
- private void logError(String message, Throwable t) {
- // XXX todo
- System.err.println(message);
- if (t != null) {
- t.printStackTrace(System.err);
- }
- }
-
public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
index e0d0c7213..3817c002a 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
@@ -12,20 +12,18 @@ package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.AbstractMetadataFactory;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionParseException;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
import org.osgi.framework.Constants;
-public class EndpointDescriptionReader extends AbstractMetadataFactory {
+public class EndpointDescriptionReader {
public org.osgi.service.remoteserviceadmin.EndpointDescription[] readEndpointDescriptions(
InputStream input) throws IOException {
@@ -44,8 +42,9 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
try {
// OSGI required properties
// objectClass/String+
- List<String> objectClasses = PropertiesUtil.getStringPlusProperty(
- parsedProperties, Constants.OBJECTCLASS);
+ List<String> objectClasses = PropertiesUtil
+ .getStringPlusProperty(parsedProperties,
+ Constants.OBJECTCLASS);
// Must have at least one objectClass
if (objectClasses == null || objectClasses.size() == 0)
throw new EndpointDescriptionParseException(
@@ -56,10 +55,11 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
.toArray(new String[objectClasses.size()]));
// endpoint.id
- String endpointId = getStringWithDefault(
- parsedProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
- null);
+ String endpointId = PropertiesUtil
+ .getStringWithDefault(
+ parsedProperties,
+ org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID,
+ null);
// Must have endpoint id, so throw if it's not found
if (endpointId == null)
throw new EndpointDescriptionParseException(
@@ -71,10 +71,11 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
// endpoint.service.id. Default is set to Long(0), which means
// not an OSGi endpoint description
- Long endpointServiceId = getLongWithDefault(
- parsedProperties,
- org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
- new Long(0));
+ Long endpointServiceId = PropertiesUtil
+ .getLongWithDefault(
+ parsedProperties,
+ org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
+ new Long(0));
parsedProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID,
endpointServiceId);
@@ -107,7 +108,7 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
}
results.add(result);
} catch (Exception e) {
- logError("Exception parsing endpoint description properties", e);
+ LogUtility.logError("readEndpointDescriptions", DebugOptions.ENDPOINTDESCRIPTIONREADER, this.getClass(), "Exception parsing endpoint description properties", e);
}
}
return (org.osgi.service.remoteserviceadmin.EndpointDescription[]) results
@@ -119,8 +120,9 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
throws EndpointDescriptionParseException {
// we get the remote service id...default 0 means that it's not an ECF
// remote service
- Long remoteServiceId = getLongWithDefault(parsedProperties,
- RemoteConstants.ENDPOINT_REMOTESERVICE_ID, null);
+ Long remoteServiceId = PropertiesUtil.getLongWithDefault(
+ parsedProperties, RemoteConstants.ENDPOINT_REMOTESERVICE_ID,
+ null);
if (remoteServiceId == null)
throw new EndpointDescriptionParseException(
RemoteConstants.ENDPOINT_REMOTESERVICE_ID
@@ -141,7 +143,7 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
String rsFilter = (String) parsedProperties
.get(RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
- Map properties = getNonECFProperties(parsedProperties);
+ Map properties = PropertiesUtil.getNonECFProperties(parsedProperties);
return new EndpointDescription(properties, endpointContainerID
.getNamespace().getName(), remoteServiceId.longValue(),
@@ -190,44 +192,16 @@ public class EndpointDescriptionReader extends AbstractMetadataFactory {
.toArray(new ID[resultList.size()]) : null;
}
- private Map<String, Object> getNonECFProperties(
- Map<String, Object> parsedProperties) {
- Map<String, Object> result = new HashMap<String, Object>();
- for (String key : parsedProperties.keySet())
- if (!PropertiesUtil.isECFProperty(key))
- result.put(key, parsedProperties.get(key));
- return result;
- }
-
- private void logError(String message, Throwable exception) {
- System.err.println(message);
- if (exception != null) {
- exception.printStackTrace(System.err);
- }
- }
-
- private String verifyStringProperty(Map properties, String propName) {
- Object r = properties.get(propName);
- try {
- return (String) r;
- } catch (ClassCastException e) {
- IllegalArgumentException iae = new IllegalArgumentException(
- "property value is not a String: " + propName);
- iae.initCause(e);
- throw iae;
- }
- }
-
private ID getContainerID(Map<String, Object> properties)
throws IDCreateException {
// We try to get the ID from the OSGi id
- String osgiId = verifyStringProperty(properties,
+ String osgiId = PropertiesUtil.verifyStringProperty(properties,
org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
if (osgiId == null)
throw new IDCreateException(
org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID
+ " must not be null");
- String containerIDNamespace = verifyStringProperty(properties,
+ String containerIDNamespace = PropertiesUtil.verifyStringProperty(properties,
RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
return IDUtil.createID(properties, containerIDNamespace);
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java
index dea9250ea..4074b0aa0 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/IDUtil.java
@@ -101,8 +101,9 @@ public class IDUtil {
return createID(endpointDescription.getContainerIDNamespace(),
endpointDescription.getId());
}
-
- public static ID createID(Namespace namespace, Object[] args) throws IDCreateException {
+
+ public static ID createID(Namespace namespace, Object[] args)
+ throws IDCreateException {
return getIDFactory().createID(namespace, args);
}
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
index ccd124910..d48cae706 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LocatorServiceListener.java
@@ -14,8 +14,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.ecf.discovery.IDiscoveryLocator;
import org.eclipse.ecf.discovery.IServiceEvent;
import org.eclipse.ecf.discovery.IServiceInfo;
@@ -74,7 +72,7 @@ class LocatorServiceListener implements IServiceListener {
discoveredEndpointDescription.getEndpointDescription(),
discovered);
} else {
- logWarning("handleOSGiServiceEvent discoveredEndpointDescription is null for service info="
+ logWarning("handleOSGiServiceEvent","discoveredEndpointDescription is null for service info="
+ serviceInfo + ",discovered=" + discovered);
}
}
@@ -100,31 +98,31 @@ class LocatorServiceListener implements IServiceListener {
}
}
- private void logWarning(String message) {
- // XXX todo
- System.out.println(message);
+ private void logWarning(String methodName, String message) {
+ LogUtility.logWarning(methodName, DebugOptions.DISCOVERY, this.getClass(), message);
}
- private void logError(String message) {
- logError(message, null);
+ private void logError(String methodName, String message) {
+ logError(methodName, message, null);
}
- private void logError(String message, Throwable t) {
- Activator a = Activator.getDefault();
- if (a != null) {
- a.log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, t));
- }
+ private void logError(String methodName, String message, Throwable t) {
+ LogUtility.logError(methodName, DebugOptions.DISCOVERY,
+ this.getClass(), message, t);
}
private DiscoveredEndpointDescription getDiscoveredEndpointDescription(
IServiceID serviceId, IServiceInfo serviceInfo, boolean discovered) {
// Get IEndpointDescriptionFactory
+ final String methodName = "getDiscoveredEndpointDescription";
IDiscoveredEndpointDescriptionFactory factory = discovery
.getDiscoveredEndpointDescriptionFactory();
if (factory == null) {
- logError("No IEndpointDescriptionFactory found, could not create EndpointDescription for "
- + (discovered ? "discovered" : "undiscovered")
- + " serviceInfo=" + serviceInfo);
+ logError(
+ methodName,
+ "No IEndpointDescriptionFactory found, could not create EndpointDescription for "
+ + (discovered ? "discovered" : "undiscovered")
+ + " serviceInfo=" + serviceInfo);
return null;
}
try {
@@ -135,12 +133,15 @@ class LocatorServiceListener implements IServiceListener {
locator, serviceInfo) : factory
.getUndiscoveredEndpointDescription(locator, serviceId);
} catch (Exception e) {
- logError("Exception calling IEndpointDescriptionFactory."
- + ((discovered) ? "createDiscoveredEndpointDescription"
- : "getUndiscoveredEndpointDescription"), e);
+ logError(
+ methodName,
+ "Exception calling IEndpointDescriptionFactory."
+ + ((discovered) ? "createDiscoveredEndpointDescription"
+ : "getUndiscoveredEndpointDescription"), e);
return null;
} catch (NoClassDefFoundError e) {
logError(
+ methodName,
"NoClassDefFoundError calling IEndpointDescriptionFactory."
+ ((discovered) ? "createDiscoveredEndpointDescription"
: "getUndiscoveredEndpointDescription"), e);
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java
index ae7267307..3f9682f2f 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/LogUtility.java
@@ -48,6 +48,21 @@ public class LogUtility {
: message), t));
}
+ public static void logWarning(String methodName, String debugOption,
+ Class clazz, String message, Throwable t) {
+ if (t != null)
+ traceException(methodName, debugOption, clazz, message, t);
+ else
+ trace(methodName, debugOption, clazz, message);
+ Activator.getDefault().log(
+ new Status(IStatus.WARNING, Activator.PLUGIN_ID,
+ IStatus.WARNING, clazz.getName() + ":" //$NON-NLS-1$
+ + ((methodName == null) ? "<unknown>" //$NON-NLS-1$
+ : methodName) + ":" //$NON-NLS-1$
+ + ((message == null) ? "<empty>" //$NON-NLS-1$
+ : message), t));
+ }
+
public static void logError(String methodName, String debugOption,
Class clazz, IStatus status) {
Throwable t = status.getException();
@@ -59,6 +74,11 @@ public class LogUtility {
Activator.getDefault().log(status);
}
+ public static void logWarning(String methodName, String debugOption,
+ Class clazz, IStatus status) {
+ logError(methodName, debugOption, clazz, status);
+ }
+
public static void trace(String methodName, String debugOptions,
Class clazz, String message) {
Trace.trace(Activator.PLUGIN_ID, debugOptions, clazz, methodName,
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
index 7eda5edc7..b887bdaea 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/PropertiesUtil.java
@@ -13,9 +13,13 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
@@ -119,5 +123,74 @@ public class PropertiesUtil {
return isOSGiProperty(key) || isECFProperty(key);
}
+ public static Map createMapFromDictionary(Dictionary input) {
+ if (input == null)
+ return null;
+ Map result = new HashMap();
+ for (Enumeration e = input.keys(); e.hasMoreElements();) {
+ Object key = e.nextElement();
+ Object val = input.get(key);
+ result.put(key, val);
+ }
+ return result;
+ }
+
+ public static Dictionary createDictionaryFromMap(Map propMap) {
+ if (propMap == null)
+ return null;
+ Dictionary result = new Properties();
+ for (Iterator i = propMap.keySet().iterator(); i.hasNext();) {
+ Object key = i.next();
+ Object val = propMap.get(key);
+ result.put(key, val);
+ }
+ return result;
+ }
+
+ public static Long getLongWithDefault(Map props, String key, Long def) {
+ if (props == null)
+ return def;
+ Object o = props.get(key);
+ if (o instanceof Long)
+ return (Long) o;
+ if (o instanceof String)
+ return Long.valueOf((String) o);
+ return def;
+ }
+
+ public static String[] getStringArrayWithDefault(
+ Map<String, Object> properties, String key, String[] def) {
+ if (properties == null)
+ return def;
+ Object o = properties.get(key);
+ if (o instanceof String) {
+ return new String[] { (String) o };
+ } else if (o instanceof String[]) {
+ return (String[]) o;
+ } else if (o instanceof List) {
+ List l = (List) o;
+ return (String[]) l.toArray(new String[l.size()]);
+ }
+ return def;
+ }
+
+ public static String getStringWithDefault(Map props, String key, String def) {
+ if (props == null)
+ return def;
+ Object o = props.get(key);
+ if (o == null || (!(o instanceof String)))
+ return def;
+ return (String) o;
+ }
+
+ public static Map<String, Object> getNonECFProperties(
+ Map<String, Object> parsedProperties) {
+ Map<String, Object> result = new HashMap<String, Object>();
+ for (String key : parsedProperties.keySet())
+ if (!isECFProperty(key))
+ result.put(key, parsedProperties.get(key));
+ return result;
+ }
+
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
index db57e5ff1..9f11498ba 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractConsumerContainerSelector.java
@@ -11,12 +11,9 @@ package org.eclipse.ecf.osgi.services.remoteserviceadmin;
import java.util.Arrays;
import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerTypeDescription;
@@ -24,6 +21,7 @@ import org.eclipse.ecf.core.IContainer;
import org.eclipse.ecf.core.IContainerFactory;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.security.IConnectContext;
+import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
import org.eclipse.ecf.remoteservice.RemoteServiceContainer;
@@ -157,7 +155,8 @@ public class AbstractConsumerContainerSelector extends
Dictionary importedConfigProperties = desc
.getPropertiesForImportedConfigs(
localImportedConfigs,
- createDictionaryFromMap(remoteExportedProperties));
+ PropertiesUtil
+ .createDictionaryFromMap(remoteExportedProperties));
// Then select a specific local imported config (typically the
// first on in the array)
String selectedConfig = selectLocalImportedConfig(
@@ -166,7 +165,8 @@ public class AbstractConsumerContainerSelector extends
if (selectedConfig != null) {
IRemoteServiceContainer rsContainer = createContainer(
selectedConfig,
- createMapFromDictionary(importedConfigProperties));
+ PropertiesUtil
+ .createMapFromDictionary(importedConfigProperties));
if (rsContainer != null) {
trace("createAndConfigureProxyContainers", //$NON-NLS-1$
"created new proxy container with config type=" //$NON-NLS-1$
@@ -180,30 +180,6 @@ public class AbstractConsumerContainerSelector extends
return null;
}
- private Map createMapFromDictionary(Dictionary input) {
- if (input == null)
- return null;
- Map result = new HashMap();
- for (Enumeration e = input.keys(); e.hasMoreElements();) {
- Object key = e.nextElement();
- Object val = input.get(key);
- result.put(key, val);
- }
- return result;
- }
-
- private Dictionary createDictionaryFromMap(Map propMap) {
- if (propMap == null)
- return null;
- Dictionary result = new Properties();
- for (Iterator i = propMap.keySet().iterator(); i.hasNext();) {
- Object key = i.next();
- Object val = propMap.get(key);
- result.put(key, val);
- }
- return result;
- }
-
protected IRemoteServiceContainer createContainer(
String containerTypeDescriptionName, Map properties) {
try {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
index 29d09dd1d..ad8881e6b 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractHostContainerSelector.java
@@ -205,9 +205,17 @@ public abstract class AbstractHostContainerSelector extends
if (descriptions == null)
return results;
// If there are no required configs specified, then create any defaults
- if (requiredConfigs == null || requiredConfigs.length == 0)
- createDefaultRSContainers(serviceReference, descriptions, results);
- else {
+ if (requiredConfigs == null || requiredConfigs.length == 0) {
+ ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
+ if (ctds != null) {
+ for (int i = 0; i < ctds.length; i++) {
+ IRemoteServiceContainer rsContainer = createRSContainer(
+ serviceReference, ctds[i]);
+ if (rsContainer != null)
+ results.add(rsContainer);
+ }
+ }
+ } else {
// See if we have a match
for (int i = 0; i < descriptions.length; i++) {
IRemoteServiceContainer rsContainer = createMatchingContainer(
@@ -224,24 +232,19 @@ public abstract class AbstractHostContainerSelector extends
if (results.size() == 0 && requiredConfigs != null
&& requiredConfigs.length > 0) {
List requiredConfigsList = Arrays.asList(requiredConfigs);
- if (!requiredConfigsList.contains(NODEFAULT))
- createDefaultRSContainers(serviceReference, descriptions,
- results);
- }
- return results;
- }
-
- private void createDefaultRSContainers(ServiceReference serviceReference,
- ContainerTypeDescription[] descriptions, List results) {
- ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
- if (ctds != null) {
- for (int i = 0; i < ctds.length; i++) {
- IRemoteServiceContainer rsContainer = createRSContainer(
- serviceReference, ctds[i]);
- if (rsContainer != null)
- results.add(rsContainer);
+ if (!requiredConfigsList.contains(NODEFAULT)) {
+ ContainerTypeDescription[] ctds = getContainerTypeDescriptionsForDefaultConfigTypes(descriptions);
+ if (ctds != null) {
+ for (int i = 0; i < ctds.length; i++) {
+ IRemoteServiceContainer rsContainer = createRSContainer(
+ serviceReference, ctds[i]);
+ if (rsContainer != null)
+ results.add(rsContainer);
+ }
+ }
}
}
+ return results;
}
protected ContainerTypeDescription[] getContainerTypeDescriptionsForDefaultConfigTypes(
@@ -315,7 +318,10 @@ public abstract class AbstractHostContainerSelector extends
protected void connectHostContainer(ServiceReference serviceReference,
IContainer container, Object target)
throws ContainerConnectException, IDCreateException {
- ID targetID = (target instanceof String)?IDUtil.createID(container.getConnectNamespace(), (String) target):IDUtil.createID(container.getConnectNamespace(), new Object[] { target});
+ ID targetID = (target instanceof String) ? IDUtil.createID(
+ container.getConnectNamespace(), (String) target) : IDUtil
+ .createID(container.getConnectNamespace(),
+ new Object[] { target });
Object context = serviceReference
.getProperty(RemoteConstants.SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT);
IConnectContext connectContext = null;
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
index ccbe5a99f..44f814985 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java
@@ -22,47 +22,14 @@ import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.discovery.IServiceProperties;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.Activator;
+import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.DebugOptions;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.IDUtil;
+import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.LogUtility;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
public abstract class AbstractMetadataFactory {
protected static final String COLLECTION_SEPARATOR = ",";
- protected String[] getStringArrayWithDefault(
- Map<String, Object> properties, String key, String[] def) {
- if (properties == null)
- return def;
- Object o = properties.get(key);
- if (o instanceof String) {
- return new String[] { (String) o };
- } else if (o instanceof String[]) {
- return (String[]) o;
- } else if (o instanceof List) {
- List l = (List) o;
- return (String[]) l.toArray(new String[l.size()]);
- }
- return def;
- }
-
- protected String getStringWithDefault(Map props, String key, String def) {
- if (props == null)
- return def;
- Object o = props.get(key);
- if (o == null || (!(o instanceof String)))
- return def;
- return (String) o;
- }
-
- protected Long getLongWithDefault(Map props, String key, Long def) {
- if (props == null)
- return def;
- Object o = props.get(key);
- if (o instanceof Long)
- return (Long) o;
- if (o instanceof String)
- return Long.valueOf((String) o);
- return def;
- }
protected void encodeString(IServiceProperties props, String name,
String value) {
@@ -372,12 +339,12 @@ public abstract class AbstractMetadataFactory {
}
}
- protected void logInfo(String methodName, String message, Throwable t) {
- // XXX todo
+ protected void logWarning(String methodName, String message, Throwable t) {
+ LogUtility.logWarning(methodName, DebugOptions.DISCOVERY, this.getClass(), message, t);
}
protected void logError(String methodName, String message, Throwable t) {
- // XXX todo
+ LogUtility.logError(methodName, DebugOptions.DISCOVERY, this.getClass(), message, t);
}
public void close() {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java
index 7f5b42546..8ef1a53ba 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java
@@ -24,6 +24,7 @@ import org.eclipse.ecf.discovery.ServiceInfo;
import org.eclipse.ecf.discovery.ServiceProperties;
import org.eclipse.ecf.discovery.identity.IServiceTypeID;
import org.eclipse.ecf.discovery.identity.ServiceIDFactory;
+import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
public class ServiceInfoFactory extends AbstractMetadataFactory implements
IServiceInfoFactory {
@@ -153,7 +154,7 @@ public class ServiceInfoFactory extends AbstractMetadataFactory implements
try {
host = InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
- logInfo("createURI", //$NON-NLS-1$
+ logWarning("createURI", //$NON-NLS-1$
"failed to get local host adress, falling back to \'localhost\'.", e); //$NON-NLS-1$
host = "localhost"; //$NON-NLS-1$
}
@@ -167,7 +168,7 @@ public class ServiceInfoFactory extends AbstractMetadataFactory implements
String defaultServiceName = createDefaultServiceName(
endpointDescription, advertiser, serviceTypeID);
// Look for service name that was explicitly set
- String serviceName = getStringWithDefault(
+ String serviceName = PropertiesUtil.getStringWithDefault(
endpointDescription.getProperties(),
RemoteConstants.DISCOVERY_SERVICE_NAME, defaultServiceName);
return serviceName;
@@ -184,12 +185,12 @@ public class ServiceInfoFactory extends AbstractMetadataFactory implements
EndpointDescription endpointDescription,
IDiscoveryAdvertiser advertiser) {
Map props = endpointDescription.getProperties();
- String[] scopes = getStringArrayWithDefault(props,
+ String[] scopes = PropertiesUtil.getStringArrayWithDefault(props,
RemoteConstants.DISCOVERY_SCOPE, IServiceTypeID.DEFAULT_SCOPE);
- String[] protocols = getStringArrayWithDefault(props,
+ String[] protocols = PropertiesUtil.getStringArrayWithDefault(props,
RemoteConstants.DISCOVERY_PROTOCOLS,
IServiceTypeID.DEFAULT_SCOPE);
- String namingAuthority = getStringWithDefault(props,
+ String namingAuthority = PropertiesUtil.getStringWithDefault(props,
RemoteConstants.DISCOVERY_NAMING_AUTHORITY,
IServiceTypeID.DEFAULT_NA);
return ServiceIDFactory.getDefault().createServiceTypeID(

Back to the top