Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis@composent.com2010-10-30 10:25:22 -0400
committerslewis@composent.com2010-10-30 10:25:22 -0400
commit70d9f8f7ac5efafabb406d52e2b79d4f2ecac5f6 (patch)
treeddfd2baa78f67b5d83f5858a9afea47975ffc2fe
parentc26389fd26a74ccec41013109a6869ba32761876 (diff)
downloadorg.eclipse.ecf-70d9f8f7ac5efafabb406d52e2b79d4f2ecac5f6.tar.gz
org.eclipse.ecf-70d9f8f7ac5efafabb406d52e2b79d4f2ecac5f6.tar.xz
org.eclipse.ecf-70d9f8f7ac5efafabb406d52e2b79d4f2ecac5f6.zip
rsa additions/changes
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java308
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBuilder.java150
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java792
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java44
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java2
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java10
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java29
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java24
-rw-r--r--incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java61
-rw-r--r--incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java4
10 files changed, 1214 insertions, 210 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
index 55948e534..0140002f5 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/Activator.java
@@ -19,6 +19,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.UUID;
+import javax.xml.parsers.SAXParserFactory;
+
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.ecf.core.util.LogHelper;
@@ -60,24 +62,11 @@ public class Activator implements BundleActivator {
return instance;
}
- private AbstractServiceInfoFactory serviceInfoFactory;
- private ServiceRegistration serviceInfoFactoryRegistration;
-
- private AbstractEndpointDescriptionFactory endpointDescriptionFactory;
- private ServiceRegistration endpointDescriptionFactoryRegistration;
-
private IExecutor executor;
+
private ServiceTracker locatorServiceTracker;
-
- private ServiceTracker endpointListenerServiceTracker;
- private Object endpointListenerServiceTrackerLock = new Object();
-
- private ServiceTracker logServiceTracker = null;
- private LogService logService = null;
- private Object logServiceTrackerLock = new Object();
-
private Map<IDiscoveryLocator, LocatorServiceListener> locatorListeners;
-
+
/*
* (non-Javadoc)
*
@@ -88,20 +77,13 @@ public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
Activator.instance = this;
- // For the service info factory and the endpointdescription factory
- // registration, set the service ranking property to Integer.MIN_VALUE so
- // that any other registered factories will be preferred.
- final Properties properties = new Properties();
- properties.put(Constants.SERVICE_RANKING, new Integer(
- Integer.MIN_VALUE));
- serviceInfoFactory = new DefaultServiceInfoFactory();
- serviceInfoFactoryRegistration = context.registerService(IServiceInfoFactory.class.getName(), serviceInfoFactory, properties);
- // also endpoint description factory
- endpointDescriptionFactory = new DefaultEndpointDescriptionFactory();
- endpointDescriptionFactoryRegistration = context.registerService(IEndpointDescriptionFactory.class.getName(), endpointDescriptionFactory, properties);
+ startServiceInfoFactory();
+ startEndpointDescriptionFactory();
+ startExecutor();
+ startLocators();
+ }
- executor = new ThreadsExecutor();
-
+ private void startLocators() {
locatorListeners = new HashMap();
// Create locator service tracker
locatorServiceTracker = new ServiceTracker(context,
@@ -111,6 +93,10 @@ public class Activator implements BundleActivator {
openLocators();
}
+ private void startExecutor() {
+ executor = new ThreadsExecutor();
+ }
+
private void openLocators() {
Object[] locators = locatorServiceTracker.getServices();
if (locators != null) {
@@ -125,9 +111,10 @@ public class Activator implements BundleActivator {
if (locator == null || context == null)
return;
synchronized (locatorListeners) {
- LocatorServiceListener locatorListener = new LocatorServiceListener(locator);
+ LocatorServiceListener locatorListener = new LocatorServiceListener(
+ locator);
locatorListeners.put(locator, locatorListener);
- processInitialLocatorServices(locator,locatorListener);
+ processInitialLocatorServices(locator, locatorListener);
}
}
@@ -135,12 +122,15 @@ public class Activator implements BundleActivator {
if (locator == null || context == null)
return;
synchronized (locatorListeners) {
- LocatorServiceListener locatorListener = locatorListeners.remove(locator);
- if (locatorListener != null) locatorListener.close();
+ LocatorServiceListener locatorListener = locatorListeners
+ .remove(locator);
+ if (locatorListener != null)
+ locatorListener.close();
}
}
- private void processInitialLocatorServices(final IDiscoveryLocator locator, final LocatorServiceListener locatorListener) {
+ private void processInitialLocatorServices(final IDiscoveryLocator locator,
+ final LocatorServiceListener locatorListener) {
IProgressRunnable runnable = new IProgressRunnable() {
public Object run(IProgressMonitor arg0) throws Exception {
if (context == null)
@@ -157,10 +147,11 @@ public class Activator implements BundleActivator {
executor.execute(runnable, null);
}
- private void shutdownLocatorListeners() {
+ private void closeLocatorListeners() {
synchronized (locatorListeners) {
- for(IDiscoveryLocator l: locatorListeners.keySet()) {
- LocatorServiceListener locatorListener = locatorListeners.get(l);
+ for (IDiscoveryLocator l : locatorListeners.keySet()) {
+ LocatorServiceListener locatorListener = locatorListeners
+ .get(l);
if (locatorListener != null) {
l.removeServiceListener(locatorListener);
locatorListener.close();
@@ -187,88 +178,48 @@ public class Activator implements BundleActivator {
* org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
- if (endpointDescriptionFactoryRegistration != null) {
- endpointDescriptionFactoryRegistration.unregister();
- endpointDescriptionFactoryRegistration = null;
- }
- if (endpointDescriptionFactory != null) {
- endpointDescriptionFactory.close();
- endpointDescriptionFactory = null;
- }
-
- if (serviceInfoFactoryRegistration != null) {
- serviceInfoFactoryRegistration.unregister();
- serviceInfoFactoryRegistration = null;
- }
- if (serviceInfoFactory != null) {
- serviceInfoFactory.close();
- serviceInfoFactory = null;
- }
-
- synchronized (endpointListenerServiceTrackerLock) {
- if (endpointListenerServiceTracker != null) {
- endpointListenerServiceTracker.close();
- endpointListenerServiceTracker = null;
- }
- }
- synchronized (logServiceTrackerLock) {
- if (logServiceTracker != null) {
- logServiceTracker.close();
- logServiceTracker = null;
- logService = null;
- }
+ closeEndpointDescriptionFactory();
+ closeServiceInfoFactory();
+ closeSAXParserTracker();
+ closeEndpointListenerTracker();
+ closeLogServiceTracker();
+ closeEndpointDescriptionFactoryTracker();
+ closeLocatorTracker();
+ closeLocatorListeners();
+ executor = null;
+ Activator.context = null;
+ Activator.instance = null;
+ }
+
+ private void closeLocatorTracker() {
+ if (locatorServiceTracker != null) {
+ locatorServiceTracker.close();
+ locatorServiceTracker = null;
}
+ }
+
+ private void closeEndpointDescriptionFactoryTracker() {
synchronized (endpointDescriptionFactoryServiceTrackerLock) {
if (endpointDescriptionFactoryServiceTracker != null) {
endpointDescriptionFactoryServiceTracker.close();
endpointDescriptionFactoryServiceTracker = null;
}
}
- if (locatorServiceTracker != null) {
- locatorServiceTracker.close();
- locatorServiceTracker = null;
- }
- shutdownLocatorListeners();
- executor = null;
- Activator.context = null;
- Activator.instance = null;
}
- protected LogService getLogService() {
- if (context == null)
- return null;
- synchronized (logServiceTrackerLock) {
- if (logServiceTracker == null) {
- logServiceTracker = new ServiceTracker(context,
- LogService.class.getName(), null);
- logServiceTracker.open();
+ private ServiceTracker endpointListenerServiceTracker;
+ private Object endpointListenerServiceTrackerLock = new Object();
+
+ private void closeEndpointListenerTracker() {
+ synchronized (endpointListenerServiceTrackerLock) {
+ if (endpointListenerServiceTracker != null) {
+ endpointListenerServiceTracker.close();
+ endpointListenerServiceTracker = null;
}
- logService = (LogService) logServiceTracker.getService();
- if (logService == null)
- logService = new SystemLogService(PLUGIN_ID);
- return logService;
}
}
- public void log(IStatus status) {
- if (logService == null)
- logService = getLogService();
- if (logService != null)
- logService.log(null, LogHelper.getLogCode(status),
- LogHelper.getLogMessage(status), status.getException());
- }
-
- public void log(ServiceReference sr, IStatus status) {
- log(sr, LogHelper.getLogCode(status), LogHelper.getLogMessage(status),
- status.getException());
- }
- public void log(ServiceReference sr, int level, String message, Throwable t) {
- if (logService == null)
- logService = getLogService();
- if (logService != null)
- logService.log(sr, level, message, t);
- }
private class LocatorTrackerCustomizer implements ServiceTrackerCustomizer {
@@ -432,17 +383,160 @@ public class Activator implements BundleActivator {
}
public String getFrameworkUUID() {
- if (context == null) return null;
- // code get and set the framework uuid property as specified in r2.enterprise.pdf pg 297
+ if (context == null)
+ return null;
+ // code get and set the framework uuid property as specified in
+ // r2.enterprise.pdf pg 297
synchronized ("org.osgi.framework.uuid") {
String result = context.getProperty("org.osgi.framework.uuid");
if (result == null) {
UUID newUUID = UUID.randomUUID();
result = newUUID.toString();
- System.setProperty("org.osgi.framework.uuid", newUUID.toString());
+ System.setProperty("org.osgi.framework.uuid",
+ newUUID.toString());
}
return result;
}
}
+ // Sax parser
+
+ private Object saxParserFactoryTrackerLock = new Object();
+ private ServiceTracker saxParserFactoryTracker;
+
+ public SAXParserFactory getSAXParserFactory() {
+ if (instance == null)
+ return null;
+ synchronized (saxParserFactoryTrackerLock) {
+ if (saxParserFactoryTracker == null) {
+ saxParserFactoryTracker = new ServiceTracker(context,
+ SAXParserFactory.class.getName(), null);
+ saxParserFactoryTracker.open();
+ }
+ return (SAXParserFactory) saxParserFactoryTracker.getService();
+ }
+ }
+
+ private void closeSAXParserTracker() {
+ synchronized (saxParserFactoryTrackerLock) {
+ if (saxParserFactoryTracker != null) {
+ saxParserFactoryTracker.close();
+ saxParserFactoryTracker = null;
+ }
+ }
+ }
+
+
+ private AbstractServiceInfoFactory serviceInfoFactory;
+ private ServiceRegistration serviceInfoFactoryRegistration;
+
+ // ServiceInfo factory
+ private void startServiceInfoFactory() {
+ // For the service info factory
+ // registration, set the service ranking property to Integer.MIN_VALUE
+ // so that any other registered factories will be preferred.
+ final Properties properties = new Properties();
+ properties.put(Constants.SERVICE_RANKING,
+ new Integer(Integer.MIN_VALUE));
+ serviceInfoFactory = new DefaultServiceInfoFactory();
+ serviceInfoFactoryRegistration = context.registerService(
+ IServiceInfoFactory.class.getName(), serviceInfoFactory,
+ properties);
+ }
+
+ private void closeServiceInfoFactory() {
+ if (serviceInfoFactoryRegistration != null) {
+ serviceInfoFactoryRegistration.unregister();
+ serviceInfoFactoryRegistration = null;
+ }
+ if (serviceInfoFactory != null) {
+ serviceInfoFactory.close();
+ serviceInfoFactory = null;
+ }
+ }
+
+ // endpoint description factory
+ private AbstractEndpointDescriptionFactory endpointDescriptionFactory;
+ private ServiceRegistration endpointDescriptionFactoryRegistration;
+
+ private void startEndpointDescriptionFactory() {
+ // For the endpoint description factory
+ // registration, set the service ranking property to Integer.MIN_VALUE
+ // so that any other registered factories will be preferred.
+ final Properties properties = new Properties();
+ properties.put(Constants.SERVICE_RANKING,
+ new Integer(Integer.MIN_VALUE));
+ endpointDescriptionFactory = new DefaultEndpointDescriptionFactory();
+ endpointDescriptionFactoryRegistration = context.registerService(
+ IEndpointDescriptionFactory.class.getName(),
+ endpointDescriptionFactory, properties);
+ }
+
+ private void closeEndpointDescriptionFactory() {
+ if (endpointDescriptionFactoryRegistration != null) {
+ endpointDescriptionFactoryRegistration.unregister();
+ endpointDescriptionFactoryRegistration = null;
+ }
+ if (endpointDescriptionFactory != null) {
+ endpointDescriptionFactory.close();
+ endpointDescriptionFactory = null;
+ }
+ }
+
+
+
+
+
+ // Logging
+
+ private ServiceTracker logServiceTracker = null;
+ private LogService logService = null;
+ private Object logServiceTrackerLock = new Object();
+
+ public LogService getLogService() {
+ if (context == null)
+ return null;
+ synchronized (logServiceTrackerLock) {
+ if (logServiceTracker == null) {
+ logServiceTracker = new ServiceTracker(context,
+ LogService.class.getName(), null);
+ logServiceTracker.open();
+ }
+ logService = (LogService) logServiceTracker.getService();
+ if (logService == null)
+ logService = new SystemLogService(PLUGIN_ID);
+ return logService;
+ }
+ }
+
+ public void log(IStatus status) {
+ if (logService == null)
+ logService = getLogService();
+ if (logService != null)
+ logService.log(null, LogHelper.getLogCode(status),
+ LogHelper.getLogMessage(status), status.getException());
+ }
+
+ public void log(ServiceReference sr, IStatus status) {
+ log(sr, LogHelper.getLogCode(status), LogHelper.getLogMessage(status),
+ status.getException());
+ }
+
+ public void log(ServiceReference sr, int level, String message, Throwable t) {
+ if (logService == null)
+ logService = getLogService();
+ if (logService != null)
+ logService.log(sr, level, message, t);
+ }
+
+ private void closeLogServiceTracker() {
+ synchronized (logServiceTrackerLock) {
+ if (logServiceTracker != null) {
+ logServiceTracker.close();
+ logServiceTracker = null;
+ logService = null;
+ }
+ }
+ }
+
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBuilder.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBuilder.java
new file mode 100644
index 000000000..6240cd7d6
--- /dev/null
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionBuilder.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Composent, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+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.IDFactory;
+import org.eclipse.ecf.core.identity.IIDFactory;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.core.identity.StringID;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionParseException;
+import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
+
+public class EndpointDescriptionBuilder {
+
+ public EndpointDescription[] createEndpointDescriptions(InputStream input) throws IOException, EndpointDescriptionParseException {
+ // First create parser
+ EndpointDescriptionParser parser = new EndpointDescriptionParser();
+ // Parse input stream
+ parser.parse(input);
+ // Get possible endpoint descriptions
+ List<EndpointDescriptionParser.EndpointDescription> parsedDescriptions = parser.getEndpointDescriptions();
+ List<EndpointDescription> results = new ArrayList();
+ // For each one parsed, get properties and
+ for(EndpointDescriptionParser.EndpointDescription ed: parsedDescriptions) {
+ Map endpointDescriptionProperties = createProperties(ed.getProperties());
+ if (endpointDescriptionProperties != null) results.add(new EndpointDescription(endpointDescriptionProperties));
+ }
+ return (EndpointDescription[]) results.toArray(new EndpointDescription[] {});
+ }
+
+ private String verifyStringProperty(Map<String,Object> 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 {
+ ID result = null;
+ // First check to see if the container id and namespace have been explicitly set
+ String containerIDName = verifyStringProperty(properties, RemoteConstants.ENDPOINT_CONTAINER_ID);
+ if (containerIDName != null) {
+ String containerNS = verifyStringProperty(properties, RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
+ Namespace ns = getNamespace(containerNS);
+ if (ns != null) result = createID(ns,containerIDName);
+ } else {
+ // We try to get the ID from the OSGi id
+ String osgiId = verifyStringProperty(properties, org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
+ if (osgiId == null) throw new IDCreateException("OSGi endpoint.id must not be null");
+ Namespace ns = findNamespaceForOSGiId(osgiId);
+ if (ns != null) result = createID(ns,osgiId);
+ }
+ return result;
+ }
+
+ private Namespace findNamespace(String namespaceName) {
+ return getIDFactory().getNamespaceByName(namespaceName);
+ }
+
+ private Namespace findNamespaceForOSGiId(String osgiId) {
+ int colonIndex = osgiId.indexOf(':');
+ if (colonIndex <= 0) return null;
+ String scheme = osgiId.substring(0,colonIndex-1);
+ // First try to find the Namespace using the protocol directly
+ Namespace ns = findNamespace(scheme);
+ if (ns == null) {
+ // Then try to find by comparing to all Namespace.getScheme()
+ ns = findNamespaceByScheme(scheme);
+ }
+ return ns;
+ }
+
+ private Namespace findNamespaceByScheme(String scheme) {
+ if (scheme == null) return null;
+ List namespaces = getIDFactory().getNamespaces();
+ for(Iterator i=namespaces.iterator(); i.hasNext(); ) {
+ Namespace ns = (Namespace) i.next();
+ if (scheme.equals(ns.getScheme())) {
+ // found it...so return
+ return ns;
+ }
+ }
+ return null;
+ }
+
+ private IIDFactory getIDFactory() {
+ return IDFactory.getDefault();
+ }
+
+ private Namespace getNamespace(String namespaceName) {
+ Namespace result = findNamespace(namespaceName);
+ return (result == null)?getIDFactory().getNamespaceByName(StringID.class.getName()):result;
+ }
+
+ private Map createProperties(Map<String, Object> properties) {
+ try {
+ ID containerID = getContainerID(properties);
+ if (containerID == null) throw new NullPointerException("ECF EndpointDescriptions must include non-null value for "+RemoteConstants.ENDPOINT_CONTAINER_ID+" of type ID");
+ properties.put(RemoteConstants.ENDPOINT_CONTAINER_ID, containerID);
+ properties.remove(RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
+ Long rsId = getRemoteServiceID(properties);
+ if (rsId == null) throw new NullPointerException("ECF EndpointDescription must include non-null value of "+RemoteConstants.ENDPOINT_REMOTESERVICE_ID+" of type Long");
+ properties.put(RemoteConstants.ENDPOINT_REMOTESERVICE_ID, rsId);
+
+ // XXX do targetID, idFilter IDs
+
+ return properties;
+ } catch (Exception e) {
+ logError("createStandardProperties","unexpected error getting ECF properties from properties="+properties,e);
+ return null;
+ }
+ }
+
+ private Long getRemoteServiceID(Map<String, Object> properties) {
+ Long remoteServiceID = (Long) properties.get(RemoteConstants.ENDPOINT_REMOTESERVICE_ID);
+ if (remoteServiceID != null) return remoteServiceID;
+ return new Long(0);
+ }
+
+ private ID createID(Namespace ns, String containerIDName) throws IDCreateException {
+ return getIDFactory().createID(ns, new Object[] { containerIDName });
+ }
+
+ private void logError(String string, String string2, Throwable e) {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
new file mode 100644
index 000000000..dda4aba4f
--- /dev/null
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/internal/osgi/services/remoteserviceadmin/EndpointDescriptionParser.java
@@ -0,0 +1,792 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Composent, Inc. and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.ecf.internal.osgi.services.remoteserviceadmin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class EndpointDescriptionParser {
+
+ private static List<String> multiValueTypes;
+
+ static {
+ multiValueTypes = Arrays.asList(new String[] { "String", "Long", //$NON-NLS-1$ //$NON-NLS-2$
+ "long", "Double", "double", "float", "Float", "int", "Integer", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ "byte", "Byte", "char", "Character", "boolean", "Boolean", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "short", "Short" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private static final String ENDPOINT_DESCRIPTIONS = "endpoint-descriptions"; //$NON-NLS-1$
+ private static final String ENDPOINT_DESCRIPTION = "endpoint-description"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY = "property"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_NAME = "name"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_VALUE = "value"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_VALUETYPE = "value-type"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_ARRAY = "array"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_LIST = "list"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_SET = "set"; //$NON-NLS-1$
+ private static final String ENDPOINT_PROPERTY_XML = "xml"; //$NON-NLS-1$
+
+ public static String[] noAttributes = new String[0];
+
+ private XMLReader xmlReader;
+ protected Locator locator = null; // document locator, if supported by the
+ // parser
+
+ class IgnoringHandler extends AbstractHandler {
+
+ public IgnoringHandler(AbstractHandler parent) {
+ super(parent);
+ this.elementHandled = "IgnoringAll"; //$NON-NLS-1$
+ }
+
+ public void startElement(String name, Attributes attributes) {
+ noSubElements(name, attributes);
+ }
+
+ }
+
+ /**
+ * Abstract base class for content handlers
+ */
+ abstract class AbstractHandler extends DefaultHandler {
+
+ protected ContentHandler parentHandler = null;
+ protected String elementHandled = null;
+
+ protected StringBuffer characters = null; // character data inside an
+ // element
+
+ public AbstractHandler() {
+ // Empty constructor for a root handler
+ }
+
+ public AbstractHandler(ContentHandler parentHandler) {
+ this.parentHandler = parentHandler;
+ xmlReader.setContentHandler(this);
+ }
+
+ public AbstractHandler(ContentHandler parentHandler,
+ String elementHandled) {
+ this.parentHandler = parentHandler;
+ xmlReader.setContentHandler(this);
+ this.elementHandled = elementHandled;
+ }
+
+ /**
+ * Set the document locator for the parser
+ *
+ * @see org.xml.sax.ContentHandler#setDocumentLocator
+ */
+ public void setDocumentLocator(Locator docLocator) {
+ locator = docLocator;
+ }
+
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
+ finishCharacters();
+ String name = makeSimpleName(localName, qName);
+ startElement(name, attributes);
+ }
+
+ public abstract void startElement(String name, Attributes attributes)
+ throws SAXException;
+
+ public void invalidElement(String name, Attributes attributes) {
+ unexpectedElement(this, name, attributes);
+ new IgnoringHandler(this);
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName) {
+ finishCharacters();
+ finished();
+ // Restore the parent content handler
+ xmlReader.setContentHandler(parentHandler);
+ }
+
+ /**
+ * An implementation for startElement when there are no sub-elements
+ */
+ protected void noSubElements(String name, Attributes attributes) {
+ unexpectedElement(this, name, attributes);
+ // Create a new handler to ignore subsequent nested elements
+ new IgnoringHandler(this);
+ }
+
+ /*
+ * Save up character data until endElement or nested startElement
+ *
+ * @see org.xml.sax.ContentHandler#characters
+ */
+ public void characters(char[] chars, int start, int length) {
+ if (this.characters == null) {
+ this.characters = new StringBuffer();
+ }
+ this.characters.append(chars, start, length);
+ }
+
+ // Consume the characters accumulated in this.characters.
+ // Called before startElement or endElement
+ private String finishCharacters() {
+ // common case -- no characters or only whitespace
+ if (this.characters == null || this.characters.length() == 0) {
+ return null;
+ }
+ if (allWhiteSpace(this.characters)) {
+ this.characters.setLength(0);
+ return null;
+ }
+
+ // process the characters
+ try {
+ String trimmedChars = this.characters.toString().trim();
+ if (trimmedChars.length() == 0) {
+ // this shouldn't happen due to the test for allWhiteSpace
+ // above
+ System.err.println("Unexpected non-whitespace characters: " //$NON-NLS-1$
+ + trimmedChars);
+ return null;
+ }
+ processCharacters(trimmedChars);
+ return trimmedChars;
+ } finally {
+ this.characters.setLength(0);
+ }
+ }
+
+ // Method to override in the handler of an element with CDATA.
+ protected void processCharacters(String data) {
+ if (data.length() > 0) {
+ unexpectedCharacterData(this, data);
+ }
+ }
+
+ private boolean allWhiteSpace(StringBuffer sb) {
+ int length = sb.length();
+ for (int i = 0; i < length; i += 1) {
+ if (!Character.isWhitespace(sb.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Called when this element and all elements nested into it have been
+ * handled.
+ */
+ protected void finished() {
+ // Do nothing by default
+ }
+
+ /*
+ * A name used to identify the handler.
+ */
+ public String getName() {
+ return (elementHandled != null ? elementHandled : "NoName"); //$NON-NLS-1$
+ }
+
+ /**
+ * Parse the attributes of an element with only required attributes.
+ */
+ protected String[] parseRequiredAttributes(Attributes attributes,
+ String[] required) {
+ return parseAttributes(attributes, required, noAttributes);
+ }
+
+ /**
+ * Parse the attributes of an element with a single optional attribute.
+ */
+ protected String parseOptionalAttribute(Attributes attributes,
+ String name) {
+ return parseAttributes(attributes, noAttributes,
+ new String[] { name })[0];
+ }
+
+ /**
+ * Parse the attributes of an element, given the list of required and
+ * optional ones. Return values in same order, null for those not
+ * present. Log warnings for extra attributes or missing required
+ * attributes.
+ */
+ protected String[] parseAttributes(Attributes attributes,
+ String[] required, String[] optional) {
+ String[] result = new String[required.length + optional.length];
+ for (int i = 0; i < attributes.getLength(); i += 1) {
+ String name = attributes.getLocalName(i);
+ String value = attributes.getValue(i).trim();
+ int j;
+ if ((j = indexOf(required, name)) >= 0) {
+ result[j] = value;
+ } else if ((j = indexOf(optional, name)) >= 0) {
+ result[required.length + j] = value;
+ } else {
+ unexpectedAttribute(elementHandled, name, value);
+ }
+ }
+ for (int i = 0; i < required.length; i += 1) {
+ checkRequiredAttribute(elementHandled, required[i], result[i]);
+ }
+ return result;
+ }
+
+ }
+
+ SAXParser getParser() throws ParserConfigurationException,
+ SAXException {
+ Activator a = Activator.getDefault();
+ if (a == null)
+ return null;
+
+ SAXParserFactory factory = a.getSAXParserFactory();
+ if (factory == null) {
+ throw new SAXException("Unable to acquire sax parser"); //$NON-NLS-1$
+ }
+ factory.setNamespaceAware(true);
+ factory.setValidating(false);
+ try {
+ factory.setFeature(
+ "http://xml.org/sax/features/string-interning", true); //$NON-NLS-1$
+ } catch (SAXException se) {
+ // some parsers may not support string interning
+ }
+ SAXParser theParser = factory.newSAXParser();
+ if (theParser == null) {
+ throw new SAXException("Unable to create sax parser"); //$NON-NLS-1$
+ }
+ xmlReader = theParser.getXMLReader();
+ return theParser;
+ }
+
+ abstract class RootHandler extends AbstractHandler {
+
+ public RootHandler() {
+ super();
+ }
+
+ public void initialize(DocHandler document, String rootName,
+ Attributes attributes) {
+ this.parentHandler = document;
+ this.elementHandled = rootName;
+ handleRootAttributes(attributes);
+ }
+
+ protected abstract void handleRootAttributes(Attributes attributes);
+
+ }
+
+ class DocHandler extends AbstractHandler {
+
+ RootHandler rootHandler;
+
+ public DocHandler(String rootName, RootHandler rootHandler) {
+ super(null, rootName);
+ this.rootHandler = rootHandler;
+ }
+
+ public void startElement(String name, Attributes attributes) {
+ if (name.equals(elementHandled)) {
+ rootHandler.initialize(this, name, attributes);
+ xmlReader.setContentHandler(rootHandler);
+ } else {
+ this.noSubElements(name, attributes);
+ }
+ }
+
+ }
+
+ class EndpointDescriptionDocHandler extends DocHandler {
+
+ public EndpointDescriptionDocHandler(String rootName,
+ RootHandler rootHandler) {
+ super(rootName, rootHandler);
+ }
+
+ public void processingInstruction(String target, String data)
+ throws SAXException {
+ // do nothing
+ }
+ }
+
+ class EndpointDescriptionsHandler extends RootHandler {
+
+ private List<EndpointDescription> endpointDescriptions = new ArrayList<EndpointDescription>();
+ private EndpointDescriptionHandler endpointDescriptionHandler;
+
+ protected void handleRootAttributes(Attributes attributes) {
+ }
+
+ public void startElement(String name, Attributes attributes)
+ throws SAXException {
+ if (ENDPOINT_DESCRIPTION.equals(name)) {
+ if (endpointDescriptionHandler == null) {
+ endpointDescriptionHandler = new EndpointDescriptionHandler(
+ this, attributes, endpointDescriptions);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ } else {
+ invalidElement(name, attributes);
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName) {
+ if (elementHandled.equals(localName)) {
+ endpointDescriptionHandler = null;
+ super.endElement(namespaceURI, localName, qName);
+ }
+ }
+
+ public List<EndpointDescription> getEndpointDescriptions() {
+ return endpointDescriptions;
+ }
+ }
+
+ class EndpointDescriptionHandler extends AbstractHandler {
+
+ private Map<String,Object> properties;
+ private List<EndpointDescription> descriptions;
+
+ public EndpointDescriptionHandler(ContentHandler parentHandler,
+ Attributes attributes, List<EndpointDescription> descriptions) {
+ super(parentHandler, ENDPOINT_DESCRIPTION);
+ this.properties = new HashMap<String, Object>();
+ this.descriptions = descriptions;
+ }
+
+ public void startElement(String name, Attributes attributes)
+ throws SAXException {
+ if (ENDPOINT_PROPERTY.equals(name)) {
+ new EndpointPropertyHandler(this, attributes, properties);
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName) {
+ if (elementHandled.equals(localName)) {
+ this.descriptions.add(new EndpointDescription(properties));
+ super.endElement(namespaceURI, localName, qName);
+ }
+ }
+
+ }
+
+ abstract class MultiValueHandler extends AbstractHandler {
+
+ protected String valueType;
+
+ public MultiValueHandler(ContentHandler parentHandler,
+ String elementHandled, String valueType) {
+ super(parentHandler, elementHandled);
+ this.valueType = valueType;
+ }
+
+ protected Object createValue(String value) {
+ if (value == null)
+ return null;
+ if (valueType.equals("String")) { //$NON-NLS-1$
+ return value;
+ } else if (valueType.equals("long") || valueType.equals("Long")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Long.valueOf(value);
+ } else if (valueType.equals("double") || valueType.equals("Double")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Double.valueOf(value);
+ } else if (valueType.equals("float") || valueType.equals("Float")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Float.valueOf(value);
+ } else if (valueType.equals("int") || valueType.equals("Integer")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Integer.valueOf(value);
+ } else if (valueType.equals("byte") || valueType.equals("Byte")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Byte.valueOf(value);
+ } else if (valueType.equals("char") //$NON-NLS-1$
+ || valueType.equals("Character")) { //$NON-NLS-1$
+ char[] chars = new char[1];
+ value.getChars(0, 1, chars, 0);
+ return Character.valueOf(chars[0]);
+ } else if (valueType.equals("boolean") //$NON-NLS-1$
+ || valueType.equals("Boolean")) { //$NON-NLS-1$
+ return Boolean.valueOf(value);
+ } else if (valueType.equals("short") || valueType.equals("Short")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Short.valueOf(value);
+ }
+ return null;
+ }
+
+ public void startElement(String name, Attributes attributes)
+ throws SAXException {
+ if (ENDPOINT_PROPERTY_VALUE.equals(name)) {
+ characters = new StringBuffer();
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName) {
+ if (ENDPOINT_PROPERTY_VALUE.equals(localName)) {
+ Object value = createValue(processValue((characters == null) ? null
+ : characters.toString()));
+ if (value != null)
+ addValue(value);
+ characters = null;
+ } else if (elementHandled.equals(localName)) {
+ super.endElement(namespaceURI, localName, qName);
+ }
+ }
+
+ private String processValue(String characters) {
+ if (characters == null || characters.length() == 0)
+ return null;
+ if (valueType.equals("String")) //$NON-NLS-1$
+ return characters;
+ int startIndex = 0;
+ while (Character.isWhitespace(characters.charAt(startIndex)))
+ startIndex++;
+ int endIndex = characters.length() - 1;
+ while (Character.isWhitespace(characters.charAt(endIndex)))
+ endIndex--;
+ return characters.substring(startIndex, endIndex + 1);
+ }
+
+ protected abstract void addValue(Object value);
+
+ public abstract Object getValues();
+ }
+
+ class ArrayMultiValueHandler extends MultiValueHandler {
+
+ private List<Object> values = new ArrayList<Object>();
+
+ public ArrayMultiValueHandler(ContentHandler parentHandler,
+ String elementHandled, String valueType) {
+ super(parentHandler, elementHandled, valueType);
+ }
+
+ protected Object[] createEmptyArrayOfType() {
+ if (valueType.equals("String")) { //$NON-NLS-1$
+ return new String[] {};
+ } else if (valueType.equals("long") || valueType.equals("Long")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return new Long[] {};
+ } else if (valueType.equals("double") || valueType.equals("Double")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return new Double[] {};
+ } else if (valueType.equals("float") || valueType.equals("Float")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return new Double[] {};
+ } else if (valueType.equals("int") || valueType.equals("Integer")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return new Integer[] {};
+ } else if (valueType.equals("byte") || valueType.equals("Byte")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return new Byte[] {};
+ } else if (valueType.equals("char") //$NON-NLS-1$
+ || valueType.equals("Character")) { //$NON-NLS-1$
+ return new Character[] {};
+ } else if (valueType.equals("boolean") //$NON-NLS-1$
+ || valueType.equals("Boolean")) { //$NON-NLS-1$
+ return new Boolean[] {};
+ } else if (valueType.equals("short") || valueType.equals("Short")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return new Short[] {};
+ } else
+ return null;
+ }
+
+ public Object getValues() {
+ return values.toArray(createEmptyArrayOfType());
+ }
+
+ protected void addValue(Object value) {
+ values.add(value);
+ }
+ }
+
+ class ListMultiValueHandler extends MultiValueHandler {
+
+ private List<Object> values = new ArrayList<Object>();
+
+ public ListMultiValueHandler(ContentHandler parentHandler,
+ String elementHandled, String valueType) {
+ super(parentHandler, elementHandled, valueType);
+ }
+
+ public Object getValues() {
+ return values;
+ }
+
+ protected void addValue(Object value) {
+ values.add(value);
+ }
+ }
+
+ class SetMultiValueHandler extends MultiValueHandler {
+
+ private Set<Object> values = new HashSet<Object>();
+
+ public SetMultiValueHandler(ContentHandler parentHandler,
+ String elementHandled, String valueType) {
+ super(parentHandler, elementHandled, valueType);
+ }
+
+ public Object getValues() {
+ return values;
+ }
+
+ protected void addValue(Object value) {
+ values.add(value);
+ }
+ }
+
+ class XMLValueHandler extends AbstractHandler {
+
+ private Map<String,String> nsPrefixMap = new HashMap<String,String>();
+ private StringBuffer buf;
+
+ public XMLValueHandler(ContentHandler parentHandler) {
+ super(parentHandler, ENDPOINT_PROPERTY_XML);
+ buf = new StringBuffer();
+ }
+
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
+ nsPrefixMap.put(uri, prefix);
+ }
+
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException {
+ buf.append("<").append(qName); //$NON-NLS-1$
+ for(Iterator<String> i=nsPrefixMap.keySet().iterator(); i.hasNext(); ) {
+ String nsURI = (String) i.next();
+ String prefix = (String) nsPrefixMap.get(nsURI);
+ i.remove();
+ if (nsURI != null) {
+ buf.append(" xmlns"); //$NON-NLS-1$
+ if (prefix != null) buf.append(":").append(prefix); //$NON-NLS-1$
+ buf.append("=\"").append(nsURI).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ for (int i = 0; i < attributes.getLength(); i++) {
+ buf.append(" "); //$NON-NLS-1$
+ buf.append(attributes.getQName(i)).append("=\"").append(attributes.getValue(i)).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ buf.append(">"); //$NON-NLS-1$
+ characters = new StringBuffer();
+ }
+
+ public void startElement(String name, Attributes attributes)
+ throws SAXException {
+ // not used
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName) {
+ if (elementHandled.equals(localName)) {
+ super.endElement(namespaceURI, localName, qName);
+ } else {
+ if (characters != null) buf.append(characters);
+ buf.append("</").append(qName).append(">"); //$NON-NLS-1$ //$NON-NLS-2$
+ characters = null;
+ }
+ }
+
+ public String getXML() {
+ return buf.toString();
+ }
+ }
+
+ class EndpointPropertyHandler extends AbstractHandler {
+
+ private Map<String,Object> properties;
+ private String name;
+ private String valueType = "String"; //$NON-NLS-1$
+ private String value;
+ private MultiValueHandler multiValueHandler;
+ private XMLValueHandler xmlValueHandler;
+
+ public EndpointPropertyHandler(ContentHandler parentHandler,
+ Attributes attributes, Map<String,Object> properties) throws SAXException {
+ super(parentHandler, ENDPOINT_PROPERTY);
+ name = parseRequiredAttributes(attributes,
+ new String[] { ENDPOINT_PROPERTY_NAME })[0];
+ value = parseOptionalAttribute(attributes, ENDPOINT_PROPERTY_VALUE);
+ String vt = parseOptionalAttribute(attributes,
+ ENDPOINT_PROPERTY_VALUETYPE);
+ if (vt != null) {
+ if (!multiValueTypes.contains(vt))
+ throw new SAXException("property element valueType=" + vt //$NON-NLS-1$
+ + " not allowed"); //$NON-NLS-1$
+ this.valueType = vt;
+ }
+ this.properties = properties;
+ if (value != null) {
+ String[] property = new String[] { name, value };
+ if (isValidProperty(property)) {
+ this.properties.put(property[0], property[1]);
+ }
+ }
+ }
+
+ public void startElement(String name, Attributes attributes)
+ throws SAXException {
+ // Should not happen if value is non-null
+ if (value != null)
+ throw new SAXException(
+ "property element has both value attribute and sub-element"); //$NON-NLS-1$
+ if (ENDPOINT_PROPERTY_ARRAY.equals(name)) {
+ if (multiValueHandler == null) {
+ multiValueHandler = new ArrayMultiValueHandler(this,
+ ENDPOINT_PROPERTY_ARRAY, valueType);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ } else if (ENDPOINT_PROPERTY_LIST.equals(name)) {
+ if (multiValueHandler == null) {
+ multiValueHandler = new ListMultiValueHandler(this,
+ ENDPOINT_PROPERTY_LIST, valueType);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ } else if (ENDPOINT_PROPERTY_SET.equals(name)) {
+ if (multiValueHandler == null) {
+ multiValueHandler = new SetMultiValueHandler(this,
+ ENDPOINT_PROPERTY_SET, valueType);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ } else if (ENDPOINT_PROPERTY_XML.equals(name)) {
+ // xml
+ if (xmlValueHandler == null) {
+ xmlValueHandler = new XMLValueHandler(this);
+ } else {
+ duplicateElement(this, name, attributes);
+ }
+ } else {
+ invalidElement(name, attributes);
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName,
+ String qName) {
+ if (elementHandled.equals(localName)) {
+ if (multiValueHandler != null) {
+ properties.put(name, multiValueHandler.getValues());
+ multiValueHandler = null;
+ } else if (xmlValueHandler != null) {
+ properties.put(name, xmlValueHandler.getXML());
+ xmlValueHandler = null;
+ }
+ super.endElement(namespaceURI, localName, qName);
+ }
+ }
+
+ private boolean isValidProperty(String[] property) {
+ return (property.length == 2 && property[0] != null && property[1] != null);
+ }
+ }
+
+ public class EndpointDescription {
+ private Map<String,Object> properties;
+
+ public EndpointDescription(Map<String,Object> properties) {
+ this.properties = properties;
+ }
+
+ public Map<String,Object> getProperties() {
+ return properties;
+ }
+
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("EndpointDescription [properties="); //$NON-NLS-1$
+ builder.append(properties);
+ builder.append("]"); //$NON-NLS-1$
+ return builder.toString();
+ }
+
+ }
+
+ public synchronized void parse(InputStream input) throws IOException {
+ try {
+ getParser();
+ EndpointDescriptionsHandler endpointDescriptionsHandler = new EndpointDescriptionsHandler();
+ xmlReader.setContentHandler(new EndpointDescriptionDocHandler(
+ ENDPOINT_DESCRIPTIONS, endpointDescriptionsHandler));
+ xmlReader.parse(new InputSource(input));
+ endpointDescriptions = endpointDescriptionsHandler
+ .getEndpointDescriptions();
+ } catch (SAXException e) {
+ throw new IOException(e.getMessage());
+ } catch (ParserConfigurationException e) {
+ throw new IOException(e.getMessage());
+ } finally {
+ input.close();
+ }
+
+ }
+
+ public static String makeSimpleName(String localName, String qualifiedName) {
+ if (localName != null && localName.length() > 0) {
+ return localName;
+ }
+ int nameSpaceIndex = qualifiedName.indexOf(":"); //$NON-NLS-1$
+ return (nameSpaceIndex == -1 ? qualifiedName : qualifiedName
+ .substring(nameSpaceIndex + 1));
+ }
+
+ public void unexpectedElement(AbstractHandler handler, String element,
+ Attributes attributes) {
+ }
+
+ public void unexpectedCharacterData(AbstractHandler handler, String cdata) {
+ }
+
+ public void unexpectedAttribute(String element, String attribute,
+ String value) {
+ }
+
+ static int indexOf(String[] array, String value) {
+ for (int i = 0; i < array.length; i += 1) {
+ if (value == null ? array[i] == null : value.equals(array[i])) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public void checkRequiredAttribute(String element, String name, Object value) {
+ }
+
+ public void duplicateElement(AbstractHandler handler, String element,
+ Attributes attributes) {
+ // ignore the duplicate element entirely because we have already logged
+ // it
+ new IgnoringHandler(handler);
+ }
+
+ private List<EndpointDescription> endpointDescriptions;
+
+ public List<EndpointDescription> getEndpointDescriptions() {
+ return endpointDescriptions;
+ }
+
+}
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 8e078f9c9..de5255095 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
@@ -39,14 +39,14 @@ public abstract class AbstractMetadataFactory {
org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS,
org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED,
// ECF properties
- RemoteConstants.ENDPOINT_ID,
- RemoteConstants.ENDPOINT_ID_NAMESPACE,
+ RemoteConstants.ENDPOINT_CONTAINER_ID,
+ RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE,
RemoteConstants.ENDPOINT_REMOTESERVICE_ID,
RemoteConstants.ENDPOINT_TARGET_ID,
RemoteConstants.ENDPOINT_TARGET_ID_NAMESPACE,
RemoteConstants.ENDPOINT_IDFILTER_IDS,
- RemoteConstants.ENDPOINT_IDFILTER_ID_COUNT,
- RemoteConstants.ENDPOINT_REMOTESERVICEFILTER
+ RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_COUNT,
+ RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER
});
protected String[] getStringArrayWithDefault(
@@ -125,24 +125,24 @@ public abstract class AbstractMetadataFactory {
protected void encodeIDArray(IServiceProperties result, ID[] idFilter) {
// First, for every id, setup prop name with index suffix
for(int i=0; i < idFilter.length; i++) {
- encodeString(result, RemoteConstants.ENDPOINT_IDFILTER_ID_NAME_+i, idFilter[i].toExternalForm());
- result.setPropertyString(RemoteConstants.ENDPOINT_IDFILTER_NAMESPACE_+i, idFilter[i].getNamespace().getName());
+ encodeString(result, RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_NAME_+i, idFilter[i].toExternalForm());
+ result.setPropertyString(RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_NAMESPACE_+i, idFilter[i].getNamespace().getName());
}
// Now add count
- result.setPropertyString(RemoteConstants.ENDPOINT_IDFILTER_ID_COUNT, new Integer(idFilter.length).toString());
+ result.setPropertyString(RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_COUNT, new Integer(idFilter.length).toString());
}
protected ID[] decodeIDArray(IServiceProperties props) {
// First, get the count
- String countValue = props.getPropertyString(RemoteConstants.ENDPOINT_IDFILTER_ID_COUNT);
+ String countValue = props.getPropertyString(RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_COUNT);
if (countValue == null) return null;
int count = new Integer(countValue).intValue();
if (count <= 0) return null;
List result = new ArrayList();
for(int i=0; i < count; i++) {
// decode string as name
- String name = decodeString(props,RemoteConstants.ENDPOINT_IDFILTER_ID_NAME_+i);
- String ns = props.getPropertyString(RemoteConstants.ENDPOINT_IDFILTER_NAMESPACE_+i);
+ String name = decodeString(props,RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_NAME_+i);
+ String ns = props.getPropertyString(RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_NAMESPACE_+i);
if (name != null && ns != null) {
ID id = createID(ns,name);
if (id != null) result.add(id);
@@ -178,18 +178,18 @@ public abstract class AbstractMetadataFactory {
if (intents != null && intents.size() > 0) result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, (String[]) intents.toArray(new String[] {}));
// endpoint ID
- String endpointName = decodeString(props,RemoteConstants.ENDPOINT_ID);
- String endpointNamespace = decodeString(props,RemoteConstants.ENDPOINT_ID_NAMESPACE);
+ String endpointName = decodeString(props,RemoteConstants.ENDPOINT_CONTAINER_ID);
+ String endpointNamespace = decodeString(props,RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
ID endpointID = createID(endpointNamespace,endpointName);
if (endpointID != null) {
- result.put(RemoteConstants.ENDPOINT_ID,endpointID);
+ result.put(RemoteConstants.ENDPOINT_CONTAINER_ID,endpointID);
}
// remote service id
Long remoteServiceId = decodeLong(props,RemoteConstants.ENDPOINT_REMOTESERVICE_ID);
result.put(RemoteConstants.ENDPOINT_REMOTESERVICE_ID, remoteServiceId);
// target ID
String targetName = decodeString(props,RemoteConstants.ENDPOINT_TARGET_ID);
- String targetNamespace = decodeString(props,RemoteConstants.ENDPOINT_ID_NAMESPACE);
+ String targetNamespace = decodeString(props,RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE);
if (targetName != null && targetNamespace != null) {
ID targetID = createID(targetNamespace,targetName);
if (targetID != null) {
@@ -202,9 +202,9 @@ public abstract class AbstractMetadataFactory {
result.put(RemoteConstants.ENDPOINT_IDFILTER_IDS, idFilter);
}
// remote service filter
- String remoteServiceFilter = decodeString(props,RemoteConstants.ENDPOINT_REMOTESERVICEFILTER);
+ String remoteServiceFilter = decodeString(props,RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
if (remoteServiceFilter != null) {
- result.put(RemoteConstants.ENDPOINT_REMOTESERVICEFILTER, remoteServiceFilter);
+ result.put(RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER, remoteServiceFilter);
}
decodeNonStandardServiceProperties(props,result);
return result;
@@ -261,12 +261,12 @@ public abstract class AbstractMetadataFactory {
}
// ECF endpoint ID = endpointDescription.getID()
- ID endpointID = endpointDescription.getID();
+ ID endpointID = endpointDescription.getContainerID();
// external form of ID
- encodeString(result, RemoteConstants.ENDPOINT_ID,
+ encodeString(result, RemoteConstants.ENDPOINT_CONTAINER_ID,
endpointID.toExternalForm());
// namespace
- encodeString(result, RemoteConstants.ENDPOINT_ID_NAMESPACE, endpointID
+ encodeString(result, RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE, endpointID
.getNamespace().getName());
// ECF remote service id = endpointDescription.getRemoteServiceId()
long remoteServiceId = endpointDescription.getRemoteServiceId();
@@ -292,7 +292,7 @@ public abstract class AbstractMetadataFactory {
// endpointDescription.getRemoteServiceFilter()
String remoteFilter = endpointDescription.getRemoteServiceFilter();
if (remoteFilter != null) {
- encodeString(result, RemoteConstants.ENDPOINT_REMOTESERVICEFILTER,
+ encodeString(result, RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER,
remoteFilter);
}
// encode non standar properties
@@ -320,8 +320,8 @@ public abstract class AbstractMetadataFactory {
for(Enumeration keys=props.getPropertyNames(); keys.hasMoreElements(); ) {
String key = (String) keys.nextElement();
if (!standardProperties.contains(key) &&
- !key.startsWith(RemoteConstants.ENDPOINT_IDFILTER_ID_NAME_) &&
- !key.startsWith(RemoteConstants.ENDPOINT_IDFILTER_NAMESPACE_)) {
+ !key.startsWith(RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_NAME_) &&
+ !key.startsWith(RemoteConstants.ENDPOINT_IDFILTER_IDARRAY_NAMESPACE_)) {
byte[] bytes = props.getPropertyBytes(key);
if (bytes != null) {
result.put(key, bytes);
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
index e02c4f0b2..3b7528048 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractServiceInfoFactory.java
@@ -114,7 +114,7 @@ public abstract class AbstractServiceInfoFactory extends
IDiscoveryAdvertiser advertiser, IServiceTypeID serviceTypeID,
String serviceName) throws URISyntaxException {
String path = "/" + serviceName;
- String str = endpointDescription.getID().getName();
+ String str = endpointDescription.getContainerID().getName();
URI uri = null;
while (true) {
try {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
index 17350da37..c2dfa83b6 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java
@@ -42,15 +42,15 @@ public class EndpointDescription extends
private void initRemoteServiceProperties() {
Map properties = getProperties();
- containerID = (ID) properties.get(RemoteConstants.ENDPOINT_ID);
+ containerID = (ID) properties.get(RemoteConstants.ENDPOINT_CONTAINER_ID);
if (containerID == null)
throw new NullPointerException(
- "ECF EndpointDescription must include non-null value for 'ecf.endpoint.id' of type ID");
+ "ECF EndpointDescriptions must include non-null value for "+RemoteConstants.ENDPOINT_CONTAINER_ID+" of type ID");
Object rsid = properties.get(RemoteConstants.ENDPOINT_REMOTESERVICE_ID);
if (rsid != null)
remoteServiceId = ((Long) rsid).longValue();
- else throw new NullPointerException("ECF EndpointDescription must include value of 'ecf.endpoint.rs.id' of type Long");
+ else throw new NullPointerException("ECF EndpointDescription must include non-null value of "+RemoteConstants.ENDPOINT_REMOTESERVICE_ID+" of type Long");
Object ctid = properties.get(RemoteConstants.ENDPOINT_TARGET_ID);
if (ctid != null)
@@ -60,7 +60,7 @@ public class EndpointDescription extends
if (idf != null)
idFilter = (ID[]) idf;
- Object rsf = properties.get(RemoteConstants.ENDPOINT_REMOTESERVICEFILTER);
+ Object rsf = properties.get(RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
if (rsf != null)
rsFilter = (String) rsf;
}
@@ -86,7 +86,7 @@ public class EndpointDescription extends
return hashCode;
}
- public ID getID() {
+ public ID getContainerID() {
return containerID;
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java
new file mode 100644
index 000000000..869d56da9
--- /dev/null
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java
@@ -0,0 +1,29 @@
+package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ecf.core.util.ECFException;
+
+public class EndpointDescriptionParseException extends ECFException {
+
+ private static final long serialVersionUID = -4481979787400184664L;
+
+ public EndpointDescriptionParseException() {
+ }
+
+ public EndpointDescriptionParseException(String message) {
+ super(message);
+ }
+
+ public EndpointDescriptionParseException(Throwable cause) {
+ super(cause);
+ }
+
+ public EndpointDescriptionParseException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public EndpointDescriptionParseException(IStatus status) {
+ super(status);
+ }
+
+}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
index 52dcc20b5..60934a435 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java
@@ -19,25 +19,25 @@ public class RemoteConstants {
public static final String DISCOVERY_SERVICE_NAME = "ecf.endpoint.discovery.servicename";
public static final String DISCOVERY_DEFAULT_SERVICE_NAME_PREFIX = "osgirsvc_";
- // ECF endpoint description properties <-> service info properties
- // container id external form
- public static final String ENDPOINT_ID = "ecf.endpoint.id";
- // container id namespace
- public static final String ENDPOINT_ID_NAMESPACE = "ecf.endpoint.id.ns";
- // remote service id
+ // container id. Value of type ID for EndpointDescription
+ public static final String ENDPOINT_CONTAINER_ID = "ecf.endpoint.id";
+ // container id namespace. Value of type String
+ public static final String ENDPOINT_CONTAINER_ID_NAMESPACE = "ecf.endpoint.id.ns";
+ // remote service id. Value of type Long
public static final String ENDPOINT_REMOTESERVICE_ID = "ecf.endpoint.rs.id";
-
+ // target id. Value of type ID
public static final String ENDPOINT_TARGET_ID = "ecf.endpoint.target.id";
+ // target namespace. Value of type String
public static final String ENDPOINT_TARGET_ID_NAMESPACE = "ecf.endpoint.target.id.ns";
-
+ // id filter. Value of type ID[]
public static final String ENDPOINT_IDFILTER_IDS = "ecf.endpoint.idfilter.ids";
- public static final String ENDPOINT_IDFILTER_ID_COUNT = "ecf.endpoint.idfilter.id.n";
+ public static final String ENDPOINT_IDFILTER_IDARRAY_COUNT = "ecf.endpoint.idfilter.id.n";
// id filter external form
- public static final String ENDPOINT_IDFILTER_ID_NAME_ = "ecf.endpoint.idfilter.id.name.";
+ public static final String ENDPOINT_IDFILTER_IDARRAY_NAME_ = "ecf.endpoint.idfilter.id.name.";
// id filter namespaces
- public static final String ENDPOINT_IDFILTER_NAMESPACE_ = "ecf.endpoint.idfilter.id.ns.";
+ public static final String ENDPOINT_IDFILTER_IDARRAY_NAMESPACE_ = "ecf.endpoint.idfilter.id.ns.";
// remote service filter
- public static final String ENDPOINT_REMOTESERVICEFILTER = "ecf.endpoint.rsfilter";
+ public static final String ENDPOINT_REMOTESERVICE_FILTER = "ecf.endpoint.rsfilter";
}
diff --git a/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java b/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
index 27494db5c..b4d796537 100644
--- a/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
+++ b/incubation/bundles/org.eclipse.ecf.provider.endpointdescription.localdiscovery/src/org/eclipse/ecf/provider/internal/endpointdescription/localdiscovery/Activator.java
@@ -9,19 +9,9 @@
******************************************************************************/
package org.eclipse.ecf.provider.internal.endpointdescription.localdiscovery;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import javax.xml.parsers.SAXParserFactory;
-import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.discovery.IServiceInfo;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescription;
import org.eclipse.ecf.osgi.services.remoteserviceadmin.IServiceInfoFactory;
-import org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteConstants;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
@@ -49,57 +39,6 @@ public class Activator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
instance = this;
-
- // test code
- testParseServiceDescription();
- }
-
- private Map<String,Object> convertProperties(Map properties) {
- Map<String,Object> result = new HashMap<String,Object>();
-
- String svcimportedcfgs = (String) properties.get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS);
- result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,svcimportedcfgs);
-
-
- String objectClass = (String) properties.get("objectClass");
- result.put("objectClass", new String[] { objectClass });
- String endpointid = (String) properties.get(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
- result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID, endpointid);
-
- String endpointsvcid = (String) properties.get(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID);
- result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID, new Long(endpointsvcid));
-
- String endpointfmkid = (String) properties.get(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID);
- result.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID, endpointfmkid);
-
- String containerid = (String) properties.get(RemoteConstants.ENDPOINT_ID);
- String containerns = (String) properties.get(RemoteConstants.ENDPOINT_ID_NAMESPACE);
- result.put(RemoteConstants.ENDPOINT_ID, IDFactory.getDefault().createID(containerns, containerid));
-
- String rsid = (String) properties.get(RemoteConstants.ENDPOINT_REMOTESERVICE_ID);
- result.put(RemoteConstants.ENDPOINT_REMOTESERVICE_ID, new Long(rsid));
-
- return result;
- }
-
- private void testParseServiceDescription() {
- try {
- URL file = context.getBundle().getEntry("/endpointdescription1.xml");
- InputStream ins = file.openStream();
- EndpointDescriptionParser parser = new EndpointDescriptionParser();
- parser.parse(ins);
- List<org.eclipse.ecf.provider.internal.endpointdescription.localdiscovery.EndpointDescriptionParser.EndpointDescription> descs = parser.getEndpointDescriptions();
- IServiceInfoFactory serviceInfoFactory = getServiceInfoFactory();
- for(EndpointDescriptionParser.EndpointDescription d: descs) {
- Map props = convertProperties(d.getProperties());
- EndpointDescription ed = new EndpointDescription(props);
- System.out.println("endpoint description="+ed);
- IServiceInfo serviceInfo = serviceInfoFactory.createServiceInfoForDiscovery(null, ed);
- System.out.println("serviceInfo="+serviceInfo);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
}
public synchronized IServiceInfoFactory getServiceInfoFactory() {
diff --git a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
index 3b3d93678..417709b2e 100644
--- a/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
+++ b/incubation/bundles/org.eclipse.ecf.tests.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/tests/osgi/services/remoteserviceadmin/AbstractMetadataFactoryTest.java
@@ -186,7 +186,7 @@ public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
protected void addRequiredECFProperties(Map<String,Object> props) {
// ecf.endpoint.id
- props.put(RemoteConstants.ENDPOINT_ID,createECFContainerID(props));
+ props.put(RemoteConstants.ENDPOINT_CONTAINER_ID,createECFContainerID(props));
// ecf.endpoint.
props.put(RemoteConstants.ENDPOINT_REMOTESERVICE_ID, createECFRemoteServiceId(props));
}
@@ -197,7 +197,7 @@ public abstract class AbstractMetadataFactoryTest extends ECFAbstractTestCase {
// ecf.endpoint.idfilter.ids
props.put(RemoteConstants.ENDPOINT_IDFILTER_IDS, createECFIDFilterIDs(props));
// ecf.endpoint.idfilter
- props.put(RemoteConstants.ENDPOINT_REMOTESERVICEFILTER, createECFIDFilter(props));
+ props.put(RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER, createECFIDFilter(props));
}
protected Object createECFIDFilter(Map<String, Object> props) {

Back to the top