Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin')
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractMetadataFactory.java6
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java92
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/BasicTopologyManager.java79
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java2
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java4
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescription.java22
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java81
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java26
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java345
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionParseException.java9
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java5
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java108
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java26
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java17
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteConstants.java30
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java56
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java629
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java10
-rw-r--r--incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ServiceInfoFactory.java8
19 files changed, 929 insertions, 626 deletions
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 891f683e9..82bcb6749 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
@@ -27,7 +27,7 @@ import org.osgi.framework.Version;
public abstract class AbstractMetadataFactory {
- protected static final String LIST_SEPARATOR = " ";
+ protected static final String LIST_SEPARATOR = " "; //$NON-NLS-1$
protected void encodeString(IServiceProperties props, String name,
String value) {
@@ -211,9 +211,9 @@ public abstract class AbstractMetadataFactory {
}
private String getPackageName(String className) {
- int lastDotIndex = className.lastIndexOf(".");
+ int lastDotIndex = className.lastIndexOf("."); //$NON-NLS-1$
if (lastDotIndex == -1)
- return "";
+ return ""; //$NON-NLS-1$
return className.substring(0, lastDotIndex);
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
index 5509628a3..9d7ce690a 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/AbstractTopologyManager.java
@@ -32,7 +32,7 @@ import org.osgi.util.tracker.ServiceTracker;
public abstract class AbstractTopologyManager {
- public static final String SERVICE_EXPORTED_INTERFACES_WILDCARD = "*";
+ public static final String SERVICE_EXPORTED_INTERFACES_WILDCARD = "*"; //$NON-NLS-1$
private BundleContext context;
@@ -96,14 +96,14 @@ public abstract class AbstractTopologyManager {
}
protected Filter createRSAFilter() {
- String filterString = "(&("
+ String filterString = "(&(" //$NON-NLS-1$
+ org.osgi.framework.Constants.OBJECTCLASS
- + "="
+ + "=" //$NON-NLS-1$
+ org.osgi.service.remoteserviceadmin.RemoteServiceAdmin.class
.getName()
- + ")("
+ + ")(" //$NON-NLS-1$
+ org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.SERVICE_PROP
- + "=*))";
+ + "=*))"; //$NON-NLS-1$
try {
return getContext().createFilter(filterString);
} catch (InvalidSyntaxException e) {
@@ -128,8 +128,8 @@ public abstract class AbstractTopologyManager {
EndpointDescription endpointDescription) {
IEndpointDescriptionAdvertiser advertiser = getEndpointDescriptionAdvertiser(endpointDescription);
if (advertiser == null) {
- logWarning("advertiseExportedRegistration",
- "No endpoint description advertiser available for endpointDescription="
+ logWarning("advertiseExportedRegistration", //$NON-NLS-1$
+ "No endpoint description advertiser available for endpointDescription=" //$NON-NLS-1$
+ endpointDescription);
return;
}
@@ -137,9 +137,9 @@ public abstract class AbstractTopologyManager {
// advertiser
IStatus result = advertiser.advertise(endpointDescription);
if (!result.isOK())
- logError("advertiseExportedRegistration",
- "Advertise of endpointDescription=" + endpointDescription
- + " FAILED", result);
+ logError("advertiseExportedRegistration", //$NON-NLS-1$
+ "Advertise of endpointDescription=" + endpointDescription //$NON-NLS-1$
+ + " FAILED", result); //$NON-NLS-1$
}
protected void unadvertiseEndpointDescription(
@@ -147,8 +147,8 @@ public abstract class AbstractTopologyManager {
IEndpointDescriptionAdvertiser advertiser = getEndpointDescriptionAdvertiser(endpointDescription);
if (advertiser == null) {
logError(
- "unadvertiseEndpointDescription",
- "No endpoint description advertiser available to unadvertise endpointDescription="
+ "unadvertiseEndpointDescription", //$NON-NLS-1$
+ "No endpoint description advertiser available to unadvertise endpointDescription=" //$NON-NLS-1$
+ endpointDescription);
return;
}
@@ -156,9 +156,9 @@ public abstract class AbstractTopologyManager {
// advertiser
IStatus result = advertiser.unadvertise(endpointDescription);
if (!result.isOK())
- logError("unadvertiseEndpointDescription",
- "Unadvertise of endpointDescription=" + endpointDescription
- + " FAILED", result);
+ logError("unadvertiseEndpointDescription", //$NON-NLS-1$
+ "Unadvertise of endpointDescription=" + endpointDescription //$NON-NLS-1$
+ + " FAILED", result); //$NON-NLS-1$
}
protected void logError(String methodName, String message,
@@ -188,9 +188,9 @@ public abstract class AbstractTopologyManager {
if (endpoint instanceof EndpointDescription)
handleEndpointAdded((EndpointDescription) endpoint, matchedFilter);
else
- logWarning("endpointAdded",
- "ECF Topology Manager: Ignoring Non-ECF endpointAdded="
- + endpoint + ",matchedFilter=" + matchedFilter);
+ logWarning("endpointAdded", //$NON-NLS-1$
+ "ECF Topology Manager: Ignoring Non-ECF endpointAdded=" //$NON-NLS-1$
+ + endpoint + ",matchedFilter=" + matchedFilter); //$NON-NLS-1$
}
protected void handleEndpointAdded(EndpointDescription endpointDescription,
@@ -199,30 +199,30 @@ public abstract class AbstractTopologyManager {
org.osgi.service.remoteserviceadmin.RemoteServiceAdmin rsa = getRemoteServiceAdmin();
if (rsa == null) {
- logError("handleEndpointAdded",
- "RemoteServiceAdmin not found for importing endpointDescription="
+ logError("handleEndpointAdded", //$NON-NLS-1$
+ "RemoteServiceAdmin not found for importing endpointDescription=" //$NON-NLS-1$
+ endpointDescription);
return;
}
- trace("handleEndpointAdded", "endpointDescription="
- + endpointDescription + " rsa=" + rsa);
+ trace("handleEndpointAdded", "endpointDescription=" //$NON-NLS-1$ //$NON-NLS-2$
+ + endpointDescription + " rsa=" + rsa); //$NON-NLS-1$
// now call rsa.import
org.osgi.service.remoteserviceadmin.ImportRegistration importRegistration = rsa
.importService(endpointDescription);
if (importRegistration == null) {
- logError("handleEndpointAdded",
- "Import registration is null for endpointDescription="
- + endpointDescription + " and rsa=" + rsa);
+ logError("handleEndpointAdded", //$NON-NLS-1$
+ "Import registration is null for endpointDescription=" //$NON-NLS-1$
+ + endpointDescription + " and rsa=" + rsa); //$NON-NLS-1$
} else {
Throwable t = importRegistration.getException();
if (t != null)
handleInvalidImportRegistration(importRegistration, t);
else {
- trace("handleEndpointAdded",
- "service imported. importRegistration="
+ trace("handleEndpointAdded", //$NON-NLS-1$
+ "service imported. importRegistration=" //$NON-NLS-1$
+ importRegistration);
synchronized (importedRegistrations) {
importedRegistrations.add(importRegistration);
@@ -233,7 +233,7 @@ public abstract class AbstractTopologyManager {
protected void handleInvalidImportRegistration(
ImportRegistration importRegistration, Throwable t) {
- logError("handleInvalidImportRegistration", "importRegistration="
+ logError("handleInvalidImportRegistration", "importRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
+ importRegistration, t);
}
@@ -243,9 +243,9 @@ public abstract class AbstractTopologyManager {
if (endpoint instanceof EndpointDescription)
handleEndpointRemoved((EndpointDescription) endpoint, matchedFilter);
else
- logWarning("endpointRemoved",
- "ECF Topology Manager: Ignoring Non-ECF endpointRemoved="
- + endpoint + ",matchedFilter=" + matchedFilter);
+ logWarning("endpointRemoved", //$NON-NLS-1$
+ "ECF Topology Manager: Ignoring Non-ECF endpointRemoved=" //$NON-NLS-1$
+ + endpoint + ",matchedFilter=" + matchedFilter); //$NON-NLS-1$
}
protected void handleEvent(ServiceEvent event, Collection contexts) {
@@ -268,7 +268,7 @@ public abstract class AbstractTopologyManager {
protected void handleEndpointRemoved(
EndpointDescription endpointDescription, String matchedFilter) {
- trace("handleEndpointRemoved", "endpointDescription="
+ trace("handleEndpointRemoved", "endpointDescription=" //$NON-NLS-1$ //$NON-NLS-2$
+ endpointDescription);
unimportService(endpointDescription);
}
@@ -287,10 +287,10 @@ public abstract class AbstractTopologyManager {
// if no remote service admin available, then log error and return
if (rsa == null) {
- logError("handleServiceRegistered",
- "No RemoteServiceAdmin found for serviceReference="
+ logError("handleServiceRegistered", //$NON-NLS-1$
+ "No RemoteServiceAdmin found for serviceReference=" //$NON-NLS-1$
+ serviceReference
- + ". Remote service NOT EXPORTED");
+ + ". Remote service NOT EXPORTED"); //$NON-NLS-1$
return;
}
@@ -300,16 +300,16 @@ public abstract class AbstractTopologyManager {
exportProperties
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES,
exportedInterfaces);
- trace("handleServiceRegistering", "serviceReference="
- + serviceReference + " exportProperties=" + exportProperties);
+ trace("handleServiceRegistering", "serviceReference=" //$NON-NLS-1$ //$NON-NLS-2$
+ + serviceReference + " exportProperties=" + exportProperties); //$NON-NLS-1$
Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> registrations = rsa
.exportService(serviceReference, exportProperties);
if (registrations == null || registrations.size() == 0) {
- logError("handleServiceRegistered",
- "No export registrations created by RemoteServiceAdmin="
- + rsa + ". ServiceReference=" + serviceReference
- + " NOT EXPORTED");
+ logError("handleServiceRegistered", //$NON-NLS-1$
+ "No export registrations created by RemoteServiceAdmin=" //$NON-NLS-1$
+ + rsa + ". ServiceReference=" + serviceReference //$NON-NLS-1$
+ + " NOT EXPORTED"); //$NON-NLS-1$
return;
}
@@ -321,8 +321,8 @@ public abstract class AbstractTopologyManager {
if (t != null)
handleInvalidExportRegistration(exportRegistration, t);
else {
- trace("handleServiceRegistering",
- "service exported. exportRegistration="
+ trace("handleServiceRegistering", //$NON-NLS-1$
+ "service exported. exportRegistration=" //$NON-NLS-1$
+ exportRegistration);
endpointDescriptions
.add((EndpointDescription) exportRegistration
@@ -344,7 +344,7 @@ public abstract class AbstractTopologyManager {
protected void handleInvalidExportRegistration(
ExportRegistration exportRegistration, Throwable t) {
- logError("handleInvalidExportRegistration", "exportRegistration="
+ logError("handleInvalidExportRegistration", "exportRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
+ exportRegistration, t);
}
@@ -398,7 +398,7 @@ public abstract class AbstractTopologyManager {
.keySet().iterator(); i.hasNext();) {
org.osgi.service.remoteserviceadmin.ExportRegistration exportRegistration = i
.next();
- trace("unexportService", "closing exportRegistration="
+ trace("unexportService", "closing exportRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
+ exportRegistration);
exportRegistration.close();
}
@@ -433,7 +433,7 @@ public abstract class AbstractTopologyManager {
// Now close all of them
if (removedRegistrations != null)
for (org.osgi.service.remoteserviceadmin.ImportRegistration removedReg : removedRegistrations) {
- trace("unimportService", "closing importRegistration="
+ trace("unimportService", "closing importRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
+ removedReg);
removedReg.close();
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/BasicTopologyManager.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/BasicTopologyManager.java
deleted file mode 100644
index 319592a82..000000000
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/BasicTopologyManager.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 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.osgi.services.remoteserviceadmin;
-
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.hooks.service.EventHook;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-
-public class BasicTopologyManager extends AbstractTopologyManager implements
- EventHook, EndpointListener {
-
- private ServiceRegistration endpointListenerRegistration;
-
- private ServiceRegistration eventHookRegistration;
-
- public BasicTopologyManager(BundleContext context) {
- super(context);
- }
-
- public void start() throws Exception {
- // Register as EndpointListener, so that it gets notified when Endpoints
- // are discovered
- Properties props = new Properties();
- props.put(
- org.osgi.service.remoteserviceadmin.EndpointListener.ENDPOINT_LISTENER_SCOPE,
- "("
- + org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID
- + "=*)");
- endpointListenerRegistration = getContext().registerService(
- EndpointListener.class.getName(), this, (Dictionary) props);
-
- // Register as EventHook, so that we get notified when remote services
- // are registered
- eventHookRegistration = getContext().registerService(
- EventHook.class.getName(), this, null);
- }
-
- public void endpointAdded(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpoint,
- String matchedFilter) {
- handleEndpointAdded(endpoint, matchedFilter);
- }
-
- public void endpointRemoved(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpoint,
- String matchedFilter) {
- handleEndpointRemoved(endpoint, matchedFilter);
- }
-
- public void event(ServiceEvent event, Collection contexts) {
- handleEvent(event, contexts);
- }
-
- public void close() {
- if (eventHookRegistration != null) {
- eventHookRegistration.unregister();
- eventHookRegistration = null;
- }
- if (endpointListenerRegistration != null) {
- endpointListenerRegistration.unregister();
- endpointListenerRegistration = null;
- }
- super.close();
- }
-
-}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
index 078392398..013aca7e5 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/ConsumerContainerSelector.java
@@ -23,7 +23,7 @@ public class ConsumerContainerSelector extends
public IRemoteServiceContainer selectConsumerContainer(
EndpointDescription endpointDescription) {
- trace("selectConsumerContainers", "endpointDescription=" + endpointDescription); //$NON-NLS-1$
+ trace("selectConsumerContainers", "endpointDescription=" + endpointDescription); //$NON-NLS-1$ //$NON-NLS-2$
// Get the endpointID
ID endpointContainerID = endpointDescription.getContainerID();
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java
index 32d127956..b5942fbb0 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/DiscoveredEndpointDescriptionFactory.java
@@ -72,8 +72,8 @@ public class DiscoveredEndpointDescriptionFactory extends
}
}
} catch (Exception e) {
- logError("createDiscoveredEndpointDescription",
- "Exception creating discovered endpoint description", e);
+ logError("createDiscoveredEndpointDescription", //$NON-NLS-1$
+ "Exception creating discovered endpoint description", e); //$NON-NLS-1$
return null;
}
}
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 48b67d1bb..04ad7bea9 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
@@ -64,7 +64,7 @@ public class EndpointDescription extends
return ((Long) r).longValue();
} catch (ClassCastException e) {
IllegalArgumentException iae = new IllegalArgumentException(
- "property value is not a Long: " + propName);
+ "property value is not a Long: " + propName); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
@@ -76,7 +76,7 @@ public class EndpointDescription extends
return (String) r;
} catch (ClassCastException e) {
IllegalArgumentException iae = new IllegalArgumentException(
- "property value is not a String: " + propName);
+ "property value is not a String: " + propName); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
@@ -89,8 +89,8 @@ public class EndpointDescription extends
return IDUtil.createID(idNamespace, idName);
} catch (IDCreateException e) {
IllegalArgumentException iae = new IllegalArgumentException(
- "cannot create a valid ID: idNamespace=" + idNamespace
- + ", idName=" + idName);
+ "cannot create a valid ID: idNamespace=" + idNamespace //$NON-NLS-1$
+ + ", idName=" + idName); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
@@ -112,8 +112,8 @@ public class EndpointDescription extends
results.add(IDUtil.createID(idNamespace, idName));
} catch (IDCreateException e) {
IllegalArgumentException iae = new IllegalArgumentException(
- "cannot create ID[]: idNamespace=" + idNamespace
- + " idName=" + idName);
+ "cannot create ID[]: idNamespace=" + idNamespace //$NON-NLS-1$
+ + " idName=" + idName); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
@@ -192,11 +192,11 @@ public class EndpointDescription extends
}
public String toString() {
- return "ECFEndpointDescription[containerID=" + containerID
- + ", remoteServiceId=" + getRemoteServiceId()
- + ", connectTargetID=" + connectTargetID + ", idFilter="
- + Arrays.toString(idFilter) + ", rsFilter=" + rsFilter
- + ", hashCode=" + hashCode + "]";
+ return "ECFEndpointDescription[containerID=" + containerID //$NON-NLS-1$
+ + ", remoteServiceId=" + getRemoteServiceId() //$NON-NLS-1$
+ + ", connectTargetID=" + connectTargetID + ", idFilter=" //$NON-NLS-1$ //$NON-NLS-2$
+ + Arrays.toString(idFilter) + ", rsFilter=" + rsFilter //$NON-NLS-1$
+ + ", hashCode=" + hashCode + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java
index 411e44de8..30c788d68 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionAdvertiser.java
@@ -43,13 +43,11 @@ public class EndpointDescriptionAdvertiser implements
discoveryAdvertiser.unregisterService(serviceInfo);
return Status.OK_STATUS;
} catch (Exception e) {
- return createErrorStatus((advertise ? "registerService"
- : "unregisterService")
- + " with serviceInfo="
- + serviceInfo
- + " for discoveryAdvertiser="
- + discoveryAdvertiser
- + " failed", e);
+ return createErrorStatus((advertise ? "registerService" //$NON-NLS-1$
+ : "unregisterService") //$NON-NLS-1$
+ + " with serviceInfo=" //$NON-NLS-1$
+ + serviceInfo + " for discoveryAdvertiser=" //$NON-NLS-1$
+ + discoveryAdvertiser + " failed", e); //$NON-NLS-1$
}
}
@@ -72,45 +70,44 @@ public class EndpointDescriptionAdvertiser implements
protected IStatus doDiscovery(EndpointDescription endpointDescription,
boolean advertise) {
Assert.isNotNull(endpointDescription);
- String messagePrefix = advertise ? "Advertise" : "Unadvertise";
+ String messagePrefix = advertise ? "Advertise" : "Unadvertise"; //$NON-NLS-1$ //$NON-NLS-2$
List<IStatus> statuses = new ArrayList<IStatus>();
- // First get serviceInfoFactory
- IServiceInfoFactory serviceInfoFactory = getServiceInfoFactory();
- if (serviceInfoFactory == null)
- return createErrorStatus(messagePrefix
- + " endpointDescription="
+ // First get serviceInfoFactory
+ IServiceInfoFactory serviceInfoFactory = getServiceInfoFactory();
+ if (serviceInfoFactory == null)
+ return createErrorStatus(messagePrefix
+ + " endpointDescription=" //$NON-NLS-1$
+ + endpointDescription
+ + ". No IServiceInfoFactory is available. Cannot unpublish endpointDescription=" //$NON-NLS-1$
+ + endpointDescription);
+ IDiscoveryAdvertiser[] discoveryAdvertisers = getDiscoveryAdvertisers();
+ if (discoveryAdvertisers == null || discoveryAdvertisers.length == 0)
+ return createErrorStatus(messagePrefix
+ + " endpointDescription=" //$NON-NLS-1$
+ + endpointDescription
+ + ". No endpointDescriptionLocator advertisers available. Cannot unpublish endpointDescription=" //$NON-NLS-1$
+ + endpointDescription);
+ for (int i = 0; i < discoveryAdvertisers.length; i++) {
+ IServiceInfo serviceInfo = (advertise ? serviceInfoFactory
+ .createServiceInfoForDiscovery(discoveryAdvertisers[i],
+ endpointDescription) : serviceInfoFactory
+ .removeServiceInfoForUndiscovery(discoveryAdvertisers[i],
+ endpointDescription));
+ if (serviceInfo == null) {
+ statuses.add(createErrorStatus(messagePrefix
+ + " endpointDescription=" //$NON-NLS-1$
+ endpointDescription
- + ". No IServiceInfoFactory is available. Cannot unpublish endpointDescription="
- + endpointDescription);
- IDiscoveryAdvertiser[] discoveryAdvertisers = getDiscoveryAdvertisers();
- if (discoveryAdvertisers == null
- || discoveryAdvertisers.length == 0)
- return createErrorStatus(messagePrefix
- + " endpointDescription="
- + endpointDescription
- + ". No endpointDescriptionLocator advertisers available. Cannot unpublish endpointDescription="
- + endpointDescription);
- for (int i = 0; i < discoveryAdvertisers.length; i++) {
- IServiceInfo serviceInfo = (advertise ? serviceInfoFactory
- .createServiceInfoForDiscovery(discoveryAdvertisers[i],
- endpointDescription) : serviceInfoFactory
- .removeServiceInfoForUndiscovery(
- discoveryAdvertisers[i], endpointDescription));
- if (serviceInfo == null) {
- statuses.add(createErrorStatus(messagePrefix
- + " endpointDescription="
- + endpointDescription
- + ". Service Info is null. Cannot publish endpointDescription="
- + endpointDescription));
- continue;
- }
- // Now actually unregister with advertiser
- statuses.add(doDiscovery(discoveryAdvertisers[i], serviceInfo,
- advertise));
+ + ". Service Info is null. Cannot publish endpointDescription=" //$NON-NLS-1$
+ + endpointDescription));
+ continue;
}
+ // Now actually unregister with advertiser
+ statuses.add(doDiscovery(discoveryAdvertisers[i], serviceInfo,
+ advertise));
+ }
return createResultStatus(statuses, messagePrefix
- + " endpointDesription=" + endpointDescription
- + ". Problem in unadvertise");
+ + " endpointDesription=" + endpointDescription //$NON-NLS-1$
+ + ". Problem in unadvertise"); //$NON-NLS-1$
}
public IStatus unadvertise(EndpointDescription endpointDescription) {
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
index bceb250dc..95a1a2c66 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionBundleTrackerCustomizer.java
@@ -33,8 +33,8 @@ import org.osgi.util.tracker.ServiceTracker;
public class EndpointDescriptionBundleTrackerCustomizer implements
BundleTrackerCustomizer {
- private static final String REMOTESERVICE_MANIFESTHEADER = "Remote-Service";
- private static final String XML_FILE_PATTERN = "*.xml";
+ private static final String REMOTESERVICE_MANIFESTHEADER = "Remote-Service"; //$NON-NLS-1$
+ private static final String XML_FILE_PATTERN = "*.xml"; //$NON-NLS-1$
private Map<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>> bundleDescriptionMap = Collections
.synchronizedMap(new HashMap<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>>());
@@ -77,7 +77,7 @@ public class EndpointDescriptionBundleTrackerCustomizer implements
REMOTESERVICE_MANIFESTHEADER);
if (remoteServicesHeaderValue != null) {
// First parse into comma-separated values
- String[] paths = remoteServicesHeaderValue.split(",");
+ String[] paths = remoteServicesHeaderValue.split(","); //$NON-NLS-1$
if (paths != null)
for (int i = 0; i < paths.length; i++)
handleEndpointDescriptionPath(bundle, paths[i]);
@@ -87,11 +87,11 @@ public class EndpointDescriptionBundleTrackerCustomizer implements
private void handleEndpointDescriptionPath(Bundle bundle,
String remoteServicesHeaderValue) {
// if it's empty, ignore
- if ("".equals(remoteServicesHeaderValue))
+ if ("".equals(remoteServicesHeaderValue)) //$NON-NLS-1$
return;
Enumeration<URL> e = null;
// if it endswith a '/', then scan for *.xml files
- if (remoteServicesHeaderValue.endsWith("/")) {
+ if (remoteServicesHeaderValue.endsWith("/")) { //$NON-NLS-1$
e = bundle.findEntries(remoteServicesHeaderValue, XML_FILE_PATTERN,
false);
} else {
@@ -100,13 +100,13 @@ public class EndpointDescriptionBundleTrackerCustomizer implements
if (lastSlashIndex == -1) {
// no slash...might be a file name or pattern, assumed to be
// at root of bundle
- e = bundle.findEntries("/", remoteServicesHeaderValue, false);
+ e = bundle.findEntries("/", remoteServicesHeaderValue, false); //$NON-NLS-1$
} else {
String path = remoteServicesHeaderValue.substring(0,
lastSlashIndex);
- if ("".equals(path)) {
+ if ("".equals(path)) { //$NON-NLS-1$
// path is empty so assume it's root
- path = "/";
+ path = "/"; //$NON-NLS-1$
}
String filePattern = remoteServicesHeaderValue
.substring(lastSlashIndex + 1);
@@ -140,13 +140,13 @@ public class EndpointDescriptionBundleTrackerCustomizer implements
IEndpointDescriptionReader endpointDescriptionReader = getEndpointDescriptionReader();
if (endpointDescriptionReader == null)
throw new NullPointerException(
- "No endpointDescriptionReader available for handleEndpointDescriptionFile fileURL="
+ "No endpointDescriptionReader available for handleEndpointDescriptionFile fileURL=" //$NON-NLS-1$
+ fileURL);
ins = fileURL.openStream();
return endpointDescriptionReader.readEndpointDescriptions(ins);
} catch (Exception e) {
- logError("handleEndpointDescriptionFile",
- "Exception creating endpoint descriptions from fileURL="
+ logError("handleEndpointDescriptionFile", //$NON-NLS-1$
+ "Exception creating endpoint descriptions from fileURL=" //$NON-NLS-1$
+ fileURL, e);
return null;
} finally {
@@ -154,8 +154,8 @@ public class EndpointDescriptionBundleTrackerCustomizer implements
try {
ins.close();
} catch (IOException e) {
- logError("handleEndpointDescriptionFile",
- "Exception closing endpointDescription input fileURL="
+ logError("handleEndpointDescriptionFile", //$NON-NLS-1$
+ "Exception closing endpointDescription input fileURL=" //$NON-NLS-1$
+ fileURL, e);
}
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
index 9c496f5c1..532891dc2 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
@@ -9,9 +9,15 @@
******************************************************************************/
package org.eclipse.ecf.osgi.services.remoteserviceadmin;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
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.List;
import java.util.Map;
@@ -19,9 +25,15 @@ import java.util.Properties;
import java.util.TreeMap;
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.IServiceEvent;
import org.eclipse.ecf.discovery.IServiceInfo;
+import org.eclipse.ecf.discovery.IServiceListener;
+import org.eclipse.ecf.discovery.identity.IServiceID;
+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.LogUtility;
import org.eclipse.ecf.internal.osgi.services.remoteserviceadmin.PropertiesUtil;
@@ -34,12 +46,14 @@ import org.eclipse.osgi.framework.eventmgr.EventManager;
import org.eclipse.osgi.framework.eventmgr.ListenerQueue;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
@@ -122,7 +136,7 @@ public class EndpointDescriptionLocator {
eventQueue.queueListeners(listeners.entrySet(), new EventDispatcher() {
public void dispatchEvent(Object eventListener,
Object listenerObject, int eventAction, Object eventObject) {
- final String logMethodName = "dispatchEvent";
+ final String logMethodName = "dispatchEvent"; //$NON-NLS-1$
final EndpointListenerEvent event = (EndpointListenerEvent) eventObject;
final EndpointListener endpointListener = event
.getEndpointListener();
@@ -138,25 +152,21 @@ public class EndpointDescriptionLocator {
endpointListener.endpointRemoved(endpointDescription,
matchingFilter);
} catch (Exception e) {
- String message = "Exception in EndpointListener listener="
- + endpointListener + " description="
- + endpointDescription + " matchingFilter="
+ String message = "Exception in EndpointListener listener=" //$NON-NLS-1$
+ + endpointListener + " description=" //$NON-NLS-1$
+ + endpointDescription + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
} catch (LinkageError e) {
- String message = "LinkageError in EndpointListener listener="
- + endpointListener
- + " description="
- + endpointDescription
- + " matchingFilter="
+ String message = "LinkageError in EndpointListener listener=" //$NON-NLS-1$
+ + endpointListener + " description=" //$NON-NLS-1$
+ + endpointDescription + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
} catch (AssertionError e) {
- String message = "AssertionError in EndpointListener listener="
- + endpointListener
- + " description="
- + endpointDescription
- + " matchingFilter="
+ String message = "AssertionError in EndpointListener listener=" //$NON-NLS-1$
+ + endpointListener + " description=" //$NON-NLS-1$
+ + endpointDescription + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
}
@@ -206,7 +216,7 @@ public class EndpointDescriptionLocator {
endpointListenerTracker.open();
locatorListeners = new HashMap();
- localLocatorServiceListener = new LocatorServiceListener(this);
+ localLocatorServiceListener = new LocatorServiceListener(null);
// Create locator service tracker, so new IDiscoveryLocators can
// be used to discover endpoint descriptions
locatorServiceTracker = new ServiceTracker(context,
@@ -224,8 +234,7 @@ public class EndpointDescriptionLocator {
}
// Create bundle tracker for reading local/xml-file endpoint
// descriptions
- bundleTrackerCustomizer = new EndpointDescriptionBundleTrackerCustomizer(
- context, localLocatorServiceListener);
+ bundleTrackerCustomizer = new EndpointDescriptionBundleTrackerCustomizer();
bundleTracker = new BundleTracker(context, Bundle.ACTIVE
| Bundle.STARTING, bundleTrackerCustomizer);
// This may trigger local endpoint description discovery
@@ -355,7 +364,7 @@ public class EndpointDescriptionLocator {
return;
synchronized (locatorListeners) {
LocatorServiceListener locatorListener = new LocatorServiceListener(
- this, locator);
+ locator);
locatorListeners.put(locator, locatorListener);
processInitialLocatorServices(locator, locatorListener);
}
@@ -416,11 +425,12 @@ public class EndpointDescriptionLocator {
}
} else {
- LogUtility.logWarning("queueEndpointDescription",
+ LogUtility.logWarning(
+ "queueEndpointDescription", //$NON-NLS-1$
DebugOptions.DISCOVERY, this.getClass(),
- "No matching EndpointListeners found for "
- + (discovered ? "discovered" : "undiscovered")
- + " endpointDescription=" + endpointDescription);
+ "No matching EndpointListeners found for " //$NON-NLS-1$
+ + (discovered ? "discovered" : "undiscovered") //$NON-NLS-1$ //$NON-NLS-2$
+ + " endpointDescription=" + endpointDescription); //$NON-NLS-1$
}
}
@@ -615,4 +625,295 @@ public class EndpointDescriptionLocator {
return results;
}
+ class EndpointDescriptionBundleTrackerCustomizer implements
+ BundleTrackerCustomizer {
+
+ private static final String REMOTESERVICE_MANIFESTHEADER = "Remote-Service"; //$NON-NLS-1$
+ private static final String XML_FILE_PATTERN = "*.xml"; //$NON-NLS-1$
+
+ private Map<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>> bundleDescriptionMap = Collections
+ .synchronizedMap(new HashMap<Long, Collection<org.osgi.service.remoteserviceadmin.EndpointDescription>>());
+
+ private Object endpointDescriptionReaderTrackerLock = new Object();
+ private ServiceTracker endpointDescriptionReaderTracker;
+
+ private IEndpointDescriptionReader getEndpointDescriptionReader() {
+ synchronized (endpointDescriptionReaderTrackerLock) {
+ if (endpointDescriptionReaderTracker == null) {
+ endpointDescriptionReaderTracker = new ServiceTracker(
+ context,
+ IEndpointDescriptionReader.class.getName(), null);
+ endpointDescriptionReaderTracker.open();
+ }
+ }
+ return (IEndpointDescriptionReader) endpointDescriptionReaderTracker
+ .getService();
+ }
+
+ public Object addingBundle(Bundle bundle, BundleEvent event) {
+ handleAddingBundle(bundle);
+ return bundle;
+ }
+
+ private void handleAddingBundle(Bundle bundle) {
+ if (context == null)
+ return;
+ String remoteServicesHeaderValue = (String) bundle.getHeaders()
+ .get(REMOTESERVICE_MANIFESTHEADER);
+ if (remoteServicesHeaderValue != null) {
+ // First parse into comma-separated values
+ String[] paths = remoteServicesHeaderValue.split(","); //$NON-NLS-1$
+ if (paths != null)
+ for (int i = 0; i < paths.length; i++)
+ handleEndpointDescriptionPath(bundle, paths[i]);
+ }
+ }
+
+ private void handleEndpointDescriptionPath(Bundle bundle,
+ String remoteServicesHeaderValue) {
+ // if it's empty, ignore
+ if ("".equals(remoteServicesHeaderValue)) //$NON-NLS-1$
+ return;
+ Enumeration<URL> e = null;
+ // if it endswith a '/', then scan for *.xml files
+ if (remoteServicesHeaderValue.endsWith("/")) { //$NON-NLS-1$
+ e = bundle.findEntries(remoteServicesHeaderValue,
+ XML_FILE_PATTERN, false);
+ } else {
+ // Break into path and filename/pattern
+ int lastSlashIndex = remoteServicesHeaderValue.lastIndexOf('/');
+ if (lastSlashIndex == -1) {
+ // no slash...might be a file name or pattern, assumed to be
+ // at root of bundle
+ e = bundle.findEntries(
+ "/", remoteServicesHeaderValue, false); //$NON-NLS-1$
+ } else {
+ String path = remoteServicesHeaderValue.substring(0,
+ lastSlashIndex);
+ if ("".equals(path)) { //$NON-NLS-1$
+ // path is empty so assume it's root
+ path = "/"; //$NON-NLS-1$
+ }
+ String filePattern = remoteServicesHeaderValue
+ .substring(lastSlashIndex + 1);
+ e = bundle.findEntries(path, filePattern, false);
+ }
+ }
+ // Now process any found
+ Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> endpointDescriptions = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
+ if (e != null) {
+ while (e.hasMoreElements()) {
+ org.osgi.service.remoteserviceadmin.EndpointDescription[] eps = handleEndpointDescriptionFile(
+ bundle, e.nextElement());
+ if (eps != null)
+ for (int i = 0; i < eps.length; i++)
+ endpointDescriptions.add(eps[i]);
+ }
+ }
+ // finally, handle them
+ if (endpointDescriptions.size() > 0) {
+ bundleDescriptionMap.put(new Long(bundle.getBundleId()),
+ endpointDescriptions);
+ for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : endpointDescriptions)
+ localLocatorServiceListener.handleEndpointDescription(ed,
+ true);
+ }
+ }
+
+ private org.osgi.service.remoteserviceadmin.EndpointDescription[] handleEndpointDescriptionFile(
+ Bundle bundle, URL fileURL) {
+ InputStream ins = null;
+ try {
+ IEndpointDescriptionReader endpointDescriptionReader = getEndpointDescriptionReader();
+ if (endpointDescriptionReader == null)
+ throw new NullPointerException(
+ "No endpointDescriptionReader available for handleEndpointDescriptionFile fileURL=" //$NON-NLS-1$
+ + fileURL);
+ ins = fileURL.openStream();
+ return endpointDescriptionReader.readEndpointDescriptions(ins);
+ } catch (Exception e) {
+ logError("handleEndpointDescriptionFile", //$NON-NLS-1$
+ "Exception creating endpoint descriptions from fileURL=" //$NON-NLS-1$
+ + fileURL, e);
+ return null;
+ } finally {
+ if (ins != null)
+ try {
+ ins.close();
+ } catch (IOException e) {
+ logError("handleEndpointDescriptionFile", //$NON-NLS-1$
+ "Exception closing endpointDescription input fileURL=" //$NON-NLS-1$
+ + fileURL, e);
+ }
+ }
+ }
+
+ private void logError(String method, String message, Throwable t) {
+ LogUtility.logError(method, DebugOptions.DISCOVERY,
+ this.getClass(), new Status(IStatus.ERROR,
+ Activator.PLUGIN_ID, IStatus.ERROR, message, t));
+ }
+
+ public void modifiedBundle(Bundle bundle, BundleEvent event,
+ Object object) {
+ }
+
+ public void removedBundle(Bundle bundle, BundleEvent event,
+ Object object) {
+ handleRemovedBundle(bundle);
+ }
+
+ private void handleRemovedBundle(Bundle bundle) {
+ Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> endpointDescriptions = bundleDescriptionMap
+ .remove(new Long(bundle.getBundleId()));
+ if (endpointDescriptions != null)
+ for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : endpointDescriptions)
+ localLocatorServiceListener.handleEndpointDescription(ed,
+ false);
+ }
+
+ public void close() {
+ synchronized (endpointDescriptionReaderTrackerLock) {
+ if (endpointDescriptionReaderTracker != null) {
+ endpointDescriptionReaderTracker.close();
+ endpointDescriptionReaderTracker = null;
+ }
+ }
+ bundleDescriptionMap.clear();
+ }
+ }
+
+ class LocatorServiceListener implements IServiceListener {
+
+ private Object listenerLock = new Object();
+ private IDiscoveryLocator locator;
+
+ private List<org.osgi.service.remoteserviceadmin.EndpointDescription> discoveredEndpointDescriptions = new ArrayList();
+
+ public LocatorServiceListener(IDiscoveryLocator locator) {
+ this.locator = locator;
+ if (locator != null)
+ this.locator.addServiceListener(this);
+ }
+
+ public void serviceDiscovered(IServiceEvent anEvent) {
+ handleService(anEvent.getServiceInfo(), true);
+ }
+
+ public void serviceUndiscovered(IServiceEvent anEvent) {
+ handleService(anEvent.getServiceInfo(), false);
+ }
+
+ private boolean matchServiceID(IServiceID serviceId) {
+ if (Arrays.asList(serviceId.getServiceTypeID().getServices())
+ .contains(RemoteConstants.SERVICE_TYPE))
+ return true;
+ return false;
+ }
+
+ void handleService(IServiceInfo serviceInfo, boolean discovered) {
+ IServiceID serviceID = serviceInfo.getServiceID();
+ if (matchServiceID(serviceID))
+ handleOSGiServiceEndpoint(serviceID, serviceInfo, discovered);
+ }
+
+ private void handleOSGiServiceEndpoint(IServiceID serviceId,
+ IServiceInfo serviceInfo, boolean discovered) {
+ if (locator == null)
+ return;
+ DiscoveredEndpointDescription discoveredEndpointDescription = getDiscoveredEndpointDescription(
+ serviceId, serviceInfo, discovered);
+ if (discoveredEndpointDescription != null) {
+ handleEndpointDescription(
+ discoveredEndpointDescription.getEndpointDescription(),
+ discovered);
+ } else {
+ logWarning("handleOSGiServiceEvent", //$NON-NLS-1$
+ "discoveredEndpointDescription is null for service info=" //$NON-NLS-1$
+ + serviceInfo + ",discovered=" + discovered); //$NON-NLS-1$
+ }
+ }
+
+ public void handleEndpointDescription(
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
+ boolean discovered) {
+ synchronized (listenerLock) {
+ if (discovered)
+ discoveredEndpointDescriptions.add(endpointDescription);
+ else
+ discoveredEndpointDescriptions.remove(endpointDescription);
+
+ queueEndpointDescription(endpointDescription, discovered);
+ }
+ }
+
+ public Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> getEndpointDescriptions() {
+ synchronized (listenerLock) {
+ Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> result = new ArrayList<org.osgi.service.remoteserviceadmin.EndpointDescription>();
+ result.addAll(discoveredEndpointDescriptions);
+ return result;
+ }
+ }
+
+ private void logWarning(String methodName, String message) {
+ LogUtility.logWarning(methodName, DebugOptions.DISCOVERY,
+ this.getClass(), message);
+ }
+
+ private void logError(String methodName, String message) {
+ logError(methodName, message, null);
+ }
+
+ 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"; //$NON-NLS-1$
+ IDiscoveredEndpointDescriptionFactory factory = getDiscoveredEndpointDescriptionFactory();
+ if (factory == null) {
+ logError(
+ methodName,
+ "No IEndpointDescriptionFactory found, could not create EndpointDescription for " //$NON-NLS-1$
+ + (discovered ? "discovered" : "undiscovered") //$NON-NLS-1$ //$NON-NLS-2$
+ + " serviceInfo=" + serviceInfo); //$NON-NLS-1$
+ return null;
+ }
+ try {
+ // Else get endpoint description factory to create
+ // EndpointDescription
+ // for given serviceID and serviceInfo
+ return (discovered) ? factory
+ .createDiscoveredEndpointDescription(locator,
+ serviceInfo) : factory
+ .getUndiscoveredEndpointDescription(locator, serviceId);
+ } catch (Exception e) {
+ logError(
+ methodName,
+ "Exception calling IEndpointDescriptionFactory." //$NON-NLS-1$
+ + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
+ : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
+ return null;
+ } catch (NoClassDefFoundError e) {
+ logError(
+ methodName,
+ "NoClassDefFoundError calling IEndpointDescriptionFactory." //$NON-NLS-1$
+ + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
+ : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ public synchronized void close() {
+ if (locator != null) {
+ locator.removeServiceListener(this);
+ locator = null;
+ }
+ discoveredEndpointDescriptions.clear();
+ }
+ }
}
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
index b4aeb8453..ed6de2b60 100644
--- 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
@@ -9,10 +9,7 @@
******************************************************************************/
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 {
+public class EndpointDescriptionParseException extends Exception {
private static final long serialVersionUID = -4481979787400184664L;
@@ -31,8 +28,4 @@ public class EndpointDescriptionParseException extends ECFException {
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/EndpointDescriptionReader.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
index 5b7ef27f8..e744d686e 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionReader.java
@@ -37,10 +37,11 @@ public class EndpointDescriptionReader implements IEndpointDescriptionReader {
try {
results.add(new EndpointDescription(parsedProperties));
} catch (Exception e) {
- LogUtility.logError("readEndpointDescriptions",
+ LogUtility.logError(
+ "readEndpointDescriptions", //$NON-NLS-1$
DebugOptions.ENDPOINT_DESCRIPTION_READER,
this.getClass(),
- "Exception parsing endpoint description properties", e);
+ "Exception parsing endpoint description properties", e); //$NON-NLS-1$
}
}
return results.toArray(new EndpointDescription[results.size()]);
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java
index d58a557f3..47a70f08c 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionWriter.java
@@ -18,7 +18,7 @@ import java.util.Set;
public class EndpointDescriptionWriter {
- protected String indent = " ";
+ protected String indent = " "; //$NON-NLS-1$
protected List<String> xmlNames;
@@ -58,23 +58,23 @@ public class EndpointDescriptionWriter {
void writeXml(int indentLevel, Writer writer) throws IOException {
indent(indentLevel, writer);
- writer.append("<xml>");
+ writer.append("<xml>"); //$NON-NLS-1$
newLine(writer);
indent(indentLevel + 1, writer);
writer.append((String) getValue());
newLine(writer);
indent(indentLevel, writer);
- writer.append("</xml>");
+ writer.append("</xml>"); //$NON-NLS-1$
newLine(writer);
}
public void writeProperty(int indentLevel, Writer writer)
throws IOException {
indent(indentLevel, writer);
- writer.append("<property name=\"").append(getName()).append("\">");
+ writer.append("<property name=\"").append(getName()).append("\">"); //$NON-NLS-1$ //$NON-NLS-2$
newLine(writer);
writeXml(indentLevel + 1, writer);
- writer.append("</property>");
+ writer.append("</property>"); //$NON-NLS-1$
newLine(writer);
}
}
@@ -92,21 +92,21 @@ public class EndpointDescriptionWriter {
public void writeProperty(int indentLevel, Writer writer)
throws IOException {
indent(indentLevel, writer);
- writer.append("<property name=\"").append(getName())
- .append("\" value-type=\"").append(getValueType())
- .append("\">");
+ writer.append("<property name=\"").append(getName()) //$NON-NLS-1$
+ .append("\" value-type=\"").append(getValueType()) //$NON-NLS-1$
+ .append("\">"); //$NON-NLS-1$
newLine(writer);
writePropertyValues(indentLevel + 1, writer);
indent(indentLevel, writer);
- writer.append("</property>");
+ writer.append("</property>"); //$NON-NLS-1$
newLine(writer);
}
void writePropertyValue(int indentLevel, Object value, Writer writer)
throws IOException {
indent(indentLevel, writer);
- writer.append("<value>").append(value.toString())
- .append("</value>");
+ writer.append("<value>").append(value.toString()) //$NON-NLS-1$
+ .append("</value>"); //$NON-NLS-1$
newLine(writer);
}
@@ -126,12 +126,12 @@ public class EndpointDescriptionWriter {
throws IOException {
Set s = (Set) getValue();
indent(indentLevel, writer);
- writer.append("<set>");
+ writer.append("<set>"); //$NON-NLS-1$
newLine(writer);
for (Iterator i = s.iterator(); i.hasNext();)
writePropertyValue(indentLevel + 1, i.next(), writer);
indent(indentLevel, writer);
- writer.append("</set>");
+ writer.append("</set>"); //$NON-NLS-1$
}
}
@@ -150,12 +150,12 @@ public class EndpointDescriptionWriter {
throws IOException {
List l = (List) getValue();
indent(indentLevel, writer);
- writer.append("<list>");
+ writer.append("<list>"); //$NON-NLS-1$
newLine(writer);
for (Iterator i = l.iterator(); i.hasNext();)
writePropertyValue(indentLevel + 1, i.next(), writer);
indent(indentLevel, writer);
- writer.append("</list>");
+ writer.append("</list>"); //$NON-NLS-1$
newLine(writer);
}
}
@@ -174,12 +174,12 @@ public class EndpointDescriptionWriter {
throws IOException {
Object[] a = (Object[]) getValue();
indent(indentLevel, writer);
- writer.append("<array>");
+ writer.append("<array>"); //$NON-NLS-1$
newLine(writer);
for (int i = 0; i < a.length; i++)
writePropertyValue(indentLevel + 1, a[i], writer);
indent(indentLevel, writer);
- writer.append("</array>");
+ writer.append("</array>"); //$NON-NLS-1$
newLine(writer);
}
}
@@ -189,11 +189,14 @@ public class EndpointDescriptionWriter {
org.osgi.service.remoteserviceadmin.EndpointDescription[] endpointDescriptions)
throws IOException {
- writeEndpointDescriptionsElementOpen(0, writer);
- for (int i = 0; i < endpointDescriptions.length; i++) {
+ indent(0, writer);
+ writer.append("<endpoint-descriptions xmlns=\"http://www.osgi.org/xmlns/rsa/v1.0.0\">"); //$NON-NLS-1$
+ newLine(writer);
+ for (int i = 0; i < endpointDescriptions.length; i++)
writeEndpointDescription(1, writer, endpointDescriptions[i]);
- }
- writeEndpointDescriptionsElementClose(0, writer);
+ indent(0, writer);
+ writer.append("</endpoint-descriptions>"); //$NON-NLS-1$
+ newLine(writer);
}
protected void writeEndpointDescription(
@@ -201,9 +204,13 @@ public class EndpointDescriptionWriter {
Writer writer,
org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription)
throws IOException {
- writeEndpointDescriptionElementOpen(indentLevel, writer);
+ indent(indentLevel, writer);
+ writer.append("<endpoint-description>"); //$NON-NLS-1$
+ newLine(writer);
writeProperties(indentLevel, writer, endpointDescription);
- writeEndpointDescriptionElementClose(indentLevel, writer);
+ indent(indentLevel, writer);
+ writer.append("</endpoint-description>"); //$NON-NLS-1$
+ newLine(writer);
}
protected void writeProperties(
@@ -235,6 +242,7 @@ public class EndpointDescriptionWriter {
protected void writeUnknownProperty(int indentLevel, Writer writer,
String name, Object value) {
+ // By default, do nothing
}
protected ComplexProperty getComplexProperty(String name, Object value) {
@@ -252,9 +260,9 @@ public class EndpointDescriptionWriter {
protected void writeValueProperty(int indentLevel, String name,
String valueType, Object value, Writer writer) throws IOException {
indent(indentLevel, writer);
- writer.append("<property name=\"").append(name)
- .append("\" value-type=\"").append(valueType)
- .append("\" value=\"").append(value.toString()).append("\"/>");
+ writer.append("<property name=\"").append(name) //$NON-NLS-1$
+ .append("\" value-type=\"").append(valueType) //$NON-NLS-1$
+ .append("\" value=\"").append(value.toString()).append("\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
newLine(writer);
}
@@ -283,28 +291,28 @@ public class EndpointDescriptionWriter {
protected String getValueType(Object value) {
// first determine if is array
if (value instanceof String)
- return "String";
+ return "String"; //$NON-NLS-1$
else if (value instanceof Long)
- return "Long";
+ return "Long"; //$NON-NLS-1$
else if (value instanceof Double)
- return "Double";
+ return "Double"; //$NON-NLS-1$
else if (value instanceof Float)
- return "Float";
+ return "Float"; //$NON-NLS-1$
else if (value instanceof Integer)
- return "Integer";
+ return "Integer"; //$NON-NLS-1$
else if (value instanceof Byte)
- return "Byte";
+ return "Byte"; //$NON-NLS-1$
else if (value instanceof Character)
- return "Character";
+ return "Character"; //$NON-NLS-1$
else if (value instanceof Boolean)
- return "Boolean";
+ return "Boolean"; //$NON-NLS-1$
else if (value instanceof Short)
- return "Short";
+ return "Short"; //$NON-NLS-1$
return null;
}
protected Writer newLine(Writer writer) throws IOException {
- return writer.append("\n");
+ return writer.append("\n"); //$NON-NLS-1$
}
protected Writer indent(int indentLevel, Writer writer) throws IOException {
@@ -313,32 +321,4 @@ public class EndpointDescriptionWriter {
return writer;
}
- protected void writeEndpointDescriptionsElementOpen(int indentLevel,
- Writer writer) throws IOException {
- indent(indentLevel, writer);
- writer.append("<endpoint-descriptions xmlns=\"http://www.osgi.org/xmlns/rsa/v1.0.0\">");
- newLine(writer);
- }
-
- protected void writeEndpointDescriptionsElementClose(int indentLevel,
- Writer writer) throws IOException {
- indent(indentLevel, writer);
- writer.append("</endpoint-descriptions>");
- newLine(writer);
- }
-
- protected void writeEndpointDescriptionElementOpen(int indentLevel,
- Writer writer) throws IOException {
- indent(indentLevel, writer);
- writer.append("<endpoint-description>");
- newLine(writer);
- }
-
- protected void writeEndpointDescriptionElementClose(int indentLevel,
- Writer writer) throws IOException {
- indent(indentLevel, writer);
- writer.append("</endpoint-description>");
- newLine(writer);
- }
-
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java
index c0d9ba984..66a3bc170 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/LocatorServiceListener.java
@@ -77,9 +77,9 @@ class LocatorServiceListener implements IServiceListener {
discoveredEndpointDescription.getEndpointDescription(),
discovered);
} else {
- logWarning("handleOSGiServiceEvent",
- "discoveredEndpointDescription is null for service info="
- + serviceInfo + ",discovered=" + discovered);
+ logWarning("handleOSGiServiceEvent", //$NON-NLS-1$
+ "discoveredEndpointDescription is null for service info=" //$NON-NLS-1$
+ + serviceInfo + ",discovered=" + discovered); //$NON-NLS-1$
}
}
@@ -122,15 +122,15 @@ class LocatorServiceListener implements IServiceListener {
private DiscoveredEndpointDescription getDiscoveredEndpointDescription(
IServiceID serviceId, IServiceInfo serviceInfo, boolean discovered) {
// Get IEndpointDescriptionFactory
- final String methodName = "getDiscoveredEndpointDescription";
+ final String methodName = "getDiscoveredEndpointDescription"; //$NON-NLS-1$
IDiscoveredEndpointDescriptionFactory factory = endpointDescriptionLocator
.getDiscoveredEndpointDescriptionFactory();
if (factory == null) {
logError(
methodName,
- "No IEndpointDescriptionFactory found, could not create EndpointDescription for "
- + (discovered ? "discovered" : "undiscovered")
- + " serviceInfo=" + serviceInfo);
+ "No IEndpointDescriptionFactory found, could not create EndpointDescription for " //$NON-NLS-1$
+ + (discovered ? "discovered" : "undiscovered") //$NON-NLS-1$ //$NON-NLS-2$
+ + " serviceInfo=" + serviceInfo); //$NON-NLS-1$
return null;
}
try {
@@ -143,16 +143,16 @@ class LocatorServiceListener implements IServiceListener {
} catch (Exception e) {
logError(
methodName,
- "Exception calling IEndpointDescriptionFactory."
- + ((discovered) ? "createDiscoveredEndpointDescription"
- : "getUndiscoveredEndpointDescription"), e);
+ "Exception calling IEndpointDescriptionFactory." //$NON-NLS-1$
+ + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
+ : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
return null;
} catch (NoClassDefFoundError e) {
logError(
methodName,
- "NoClassDefFoundError calling IEndpointDescriptionFactory."
- + ((discovered) ? "createDiscoveredEndpointDescription"
- : "getUndiscoveredEndpointDescription"), e);
+ "NoClassDefFoundError calling IEndpointDescriptionFactory." //$NON-NLS-1$
+ + ((discovered) ? "createDiscoveredEndpointDescription" //$NON-NLS-1$
+ : "getUndiscoveredEndpointDescription"), e); //$NON-NLS-1$
return null;
}
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java
index 557cacb09..e0ee22a6a 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/PackageVersionComparator.java
@@ -18,20 +18,21 @@ public class PackageVersionComparator implements IPackageVersionComparator {
public void comparePackageVersions(String packageName,
Version remoteVersion, Version localVersion)
throws RuntimeException {
- LogUtility.trace("comparePackageVersions",
+ LogUtility.trace(
+ "comparePackageVersions", //$NON-NLS-1$
DebugOptions.PACKAGE_VERSION_COMPARATOR, this.getClass(),
- "packageName=" + packageName + ",remoteVersion="
- + remoteVersion + ",localVersion=" + localVersion);
+ "packageName=" + packageName + ",remoteVersion=" //$NON-NLS-1$ //$NON-NLS-2$
+ + remoteVersion + ",localVersion=" + localVersion); //$NON-NLS-1$
// By default we do strict comparison of remote with local...they must
- // be exactly the same, or we thrown a runtim exception
+ // be exactly the same, or we thrown a runtime exception
int compareResult = localVersion.compareTo(remoteVersion);
// Now check compare result, and throw exception to fail compare
if (compareResult != 0)
throw new RuntimeException(
- "Package version compare failed with compareResult="
- + compareResult + " for package=" + packageName
- + " localVersion=" + localVersion
- + " remoteVersion=" + remoteVersion);
+ "Package version compare failed with compareResult=" //$NON-NLS-1$
+ + compareResult + " for package=" + packageName //$NON-NLS-1$
+ + " localVersion=" + localVersion //$NON-NLS-1$
+ + " remoteVersion=" + remoteVersion); //$NON-NLS-1$
}
}
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 c950c694d..b379fac35 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
@@ -15,34 +15,34 @@ public class RemoteConstants {
// not instantiable
}
- public static final String SERVICE_TYPE = "osgirsvc";
+ public static final String SERVICE_TYPE = "osgirsvc"; //$NON-NLS-1$
- public static final String DISCOVERY_SCOPE = "ecf.endpoint.discovery.scope";
- public static final String DISCOVERY_PROTOCOLS = "ecf.endpoint.discovery.protocols";
- public static final String DISCOVERY_NAMING_AUTHORITY = "ecf.endpoint.discovery.namingauthority";
- public static final String DISCOVERY_SERVICE_NAME = "ecf.endpoint.discovery.servicename";
- public static final String DISCOVERY_DEFAULT_SERVICE_NAME_PREFIX = "osgirsvc_";
+ public static final String DISCOVERY_SCOPE = "ecf.endpoint.discovery.scope"; //$NON-NLS-1$
+ public static final String DISCOVERY_PROTOCOLS = "ecf.endpoint.discovery.protocols"; //$NON-NLS-1$
+ public static final String DISCOVERY_NAMING_AUTHORITY = "ecf.endpoint.discovery.namingauthority"; //$NON-NLS-1$
+ public static final String DISCOVERY_SERVICE_NAME = "ecf.endpoint.discovery.servicename"; //$NON-NLS-1$
+ public static final String DISCOVERY_DEFAULT_SERVICE_NAME_PREFIX = "osgirsvc_"; //$NON-NLS-1$
// container id namespace. Value of type String
- public static final String ENDPOINT_CONTAINER_ID_NAMESPACE = "ecf.endpoint.id.ns";
+ public static final String ENDPOINT_CONTAINER_ID_NAMESPACE = "ecf.endpoint.id.ns"; //$NON-NLS-1$
// target id. Value of type String
- public static final String ENDPOINT_CONNECTTARGET_ID = "ecf.endpoint.connecttarget.id";
+ public static final String ENDPOINT_CONNECTTARGET_ID = "ecf.endpoint.connecttarget.id"; //$NON-NLS-1$
// id filter. Value of type String+
- public static final String ENDPOINT_IDFILTER_IDS = "ecf.endpoint.idfilter.ids";
+ public static final String ENDPOINT_IDFILTER_IDS = "ecf.endpoint.idfilter.ids"; //$NON-NLS-1$
// remote service filter. Value of type String
- public static final String ENDPOINT_REMOTESERVICE_FILTER = "ecf.endpoint.rsfilter";
+ public static final String ENDPOINT_REMOTESERVICE_FILTER = "ecf.endpoint.rsfilter"; //$NON-NLS-1$
// Value of
// org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS
// For ECF providers this is a constant
- public static final String ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE = "org.eclipse.ecf.config";
+ public static final String ENDPOINT_SERVICE_IMPORTED_CONFIGS_VALUE = "org.eclipse.ecf.config"; //$NON-NLS-1$
// Value of type String,ID,or Object[]
- public static final String SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS = "ecf.exported.containerfactoryargs";
+ public static final String SERVICE_EXPORTED_CONTAINER_FACTORY_ARGS = "ecf.exported.containerfactoryargs"; //$NON-NLS-1$
// Value of type IConnectContext
- public static final String SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT = "ecf.exported.containerconnectcontext";
+ public static final String SERVICE_EXPORTED_CONTAINER_CONNECT_CONTEXT = "ecf.exported.containerconnectcontext"; //$NON-NLS-1$
// Value of type ID
- public static final String SERVICE_EXPORTED_CONTAINER_ID = "ecf.exported.containerid";
+ public static final String SERVICE_EXPORTED_CONTAINER_ID = "ecf.exported.containerid"; //$NON-NLS-1$
- public static final String SERVICE_IMPORTED_VALUETYPE = "ecf.imported.valuetype";
+ public static final String SERVICE_IMPORTED_VALUETYPE = "ecf.imported.valuetype"; //$NON-NLS-1$
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java
new file mode 100644
index 000000000..251b434ed
--- /dev/null
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteReferenceNotFoundException.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 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.osgi.services.remoteserviceadmin;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.eclipse.ecf.core.identity.ID;
+
+public class RemoteReferenceNotFoundException extends Exception {
+
+ private static final long serialVersionUID = -4174685192086828376L;
+
+ private ID targetID;
+ private ID[] idFilter;
+ private Collection<String> interfaces;
+ private String rsFilter;
+
+ public RemoteReferenceNotFoundException(ID targetID, ID[] idFilter,
+ Collection<String> interfaces, String rsFilter) {
+ this.targetID = targetID;
+ this.idFilter = idFilter;
+ this.interfaces = interfaces;
+ this.rsFilter = rsFilter;
+ }
+
+ public ID getTargetID() {
+ return targetID;
+ }
+
+ public ID[] getIdFilter() {
+ return idFilter;
+ }
+
+ public Collection<String> getInterfaces() {
+ return interfaces;
+ }
+
+ public String getRsFilter() {
+ return rsFilter;
+ }
+
+ public String toString() {
+ return "RemoteReferenceNotFoundException[targetID=" + targetID
+ + ", idFilter=" + Arrays.toString(idFilter) + ", interfaces="
+ + interfaces + ", rsFilter=" + rsFilter + "]";
+ }
+
+}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
index e02e66f3e..7095591df 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.java
@@ -59,32 +59,36 @@ import org.osgi.service.remoteserviceadmin.EndpointPermission;
import org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener;
import org.osgi.util.tracker.ServiceTracker;
+@SuppressWarnings("deprecation")
public class RemoteServiceAdmin implements
org.osgi.service.remoteserviceadmin.RemoteServiceAdmin {
- public static final String SERVICE_PROP = "org.eclipse.ecf.rsa";
+ public static final String SERVICE_PROP = "org.eclipse.ecf.rsa"; //$NON-NLS-1$
private Bundle clientBundle;
private boolean hostAutoCreateContainer = new Boolean(
System.getProperty(
- "org.eclipse.ecf.osgi.services.remoteserviceadmin.hostAutoCreateContainer",
- "true")).booleanValue();
+ "org.eclipse.ecf.osgi.services.remoteserviceadmin.hostAutoCreateContainer", //$NON-NLS-1$
+ "true")).booleanValue(); //$NON-NLS-1$
private String[] hostDefaultConfigTypes = new String[] { System
.getProperty(
- "org.eclipse.ecf.osgi.services.remoteserviceadmin.hostDefaultConfigType",
- "ecf.generic.server") };
+ "org.eclipse.ecf.osgi.services.remoteserviceadmin.hostDefaultConfigType", //$NON-NLS-1$
+ "ecf.generic.server") }; //$NON-NLS-1$
private boolean consumerAutoCreateContainer = new Boolean(
System.getProperty(
- "org.eclipse.ecf.osgi.services.remoteserviceadmin.consumerAutoCreateContainer",
- "true")).booleanValue();
+ "org.eclipse.ecf.osgi.services.remoteserviceadmin.consumerAutoCreateContainer", //$NON-NLS-1$
+ "true")).booleanValue(); //$NON-NLS-1$
private PackageVersionComparator packageVersionComparator;
private ServiceTracker packageAdminTracker;
private Object packageAdminTrackerLock = new Object();
+ private Object eventAdminTrackerLock = new Object();
+ private ServiceTracker eventAdminTracker;
+
private Object remoteServiceAdminListenerTrackerLock = new Object();
private ServiceTracker remoteServiceAdminListenerTracker;
@@ -97,39 +101,11 @@ public class RemoteServiceAdmin implements
private Collection<ExportRegistration> exportedRegistrations = new ArrayList<ExportRegistration>();
private Collection<ImportRegistration> importedRegistrations = new ArrayList<ImportRegistration>();
- private BundleContext getClientBundleContext() {
- return clientBundle.getBundleContext();
- }
-
- private Bundle getClientBundle() {
- return clientBundle;
- }
-
- private boolean removeExportRegistration(
- ExportRegistration exportRegistration) {
- synchronized (exportedRegistrations) {
- boolean removed = exportedRegistrations.remove(exportRegistration);
- trace("removeExportRegistration", "exportRegistration="
- + exportRegistration + " exportedRegistrations="
- + exportedRegistrations + " removed=" + removed);
- return removed;
- }
- }
-
- private boolean removeImportRegistration(
- ImportRegistration importRegistration) {
- synchronized (importedRegistrations) {
- boolean removed = importedRegistrations.remove(importRegistration);
- trace("removeImportRegistration", "importRegistration="
- + importRegistration + " importedRegistrations="
- + importedRegistrations + " removed=" + removed);
- return removed;
- }
- }
-
public RemoteServiceAdmin(Bundle clientBundle) {
this.clientBundle = clientBundle;
Assert.isNotNull(this.clientBundle);
+ trace("RemoteServiceAdmin<init>",
+ "clientBundle=" + clientBundle.getSymbolicName());
// Only setup defaults if it hasn't already been done by some other
// Remote Service Admin instance
Properties props = new Properties();
@@ -177,42 +153,13 @@ public class RemoteServiceAdmin implements
packageVersionComparator = new PackageVersionComparator();
}
- private void closeDefaultContainerSelectors() {
- if (defaultHostContainerSelectorRegistration != null) {
- defaultHostContainerSelectorRegistration.unregister();
- defaultHostContainerSelectorRegistration = null;
- }
- if (defaultHostContainerSelector != null) {
- defaultHostContainerSelector.close();
- defaultHostContainerSelector = null;
- }
- if (defaultConsumerContainerSelectorRegistration != null) {
- defaultConsumerContainerSelectorRegistration.unregister();
- defaultConsumerContainerSelectorRegistration = null;
- }
- if (defaultConsumerContainerSelector != null) {
- defaultConsumerContainerSelector.close();
- defaultConsumerContainerSelector = null;
- }
- }
-
- private void checkEndpointPermission(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
- String permissionType) throws SecurityException {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- return;
- sm.checkPermission(new EndpointPermission(endpointDescription,
- Activator.getDefault().getFrameworkUUID(), permissionType));
- }
-
// RemoteServiceAdmin service interface impl methods
public Collection<org.osgi.service.remoteserviceadmin.ExportRegistration> exportService(
ServiceReference serviceReference,
Map<String, Object> overridingProperties) {
- trace("exportService", "serviceReference=" + serviceReference
- + ",properties=" + overridingProperties);
+ trace("exportService", "serviceReference=" + serviceReference //$NON-NLS-1$ //$NON-NLS-2$
+ + ",properties=" + overridingProperties); //$NON-NLS-1$
overridingProperties = (overridingProperties == null) ? Collections.EMPTY_MAP
: overridingProperties;
@@ -229,21 +176,27 @@ public class RemoteServiceAdmin implements
if (exportedInterfaces == null)
throw new IllegalArgumentException(
org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES
- + " not set");
- // Get optional service property for exported configs
+ + " not set"); //$NON-NLS-1$
+
+ // Get optional exported configs
String[] exportedConfigs = PropertiesUtil
- .getStringArrayFromPropertyValue(serviceReference
- .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS));
+ .getStringArrayFromPropertyValue(overridingProperties
+ .get(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS));
+ if (exportedConfigs == null) {
+ exportedConfigs = PropertiesUtil
+ .getStringArrayFromPropertyValue(serviceReference
+ .getProperty(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS));
+ }
// Get all intents (service.intents, service.exported.intents,
// service.exported.intents.extra)
- String[] serviceIntents = PropertiesUtil
- .getServiceIntents(serviceReference);
+ String[] serviceIntents = PropertiesUtil.getServiceIntents(
+ serviceReference, overridingProperties);
- // Get a host container selector
+ // Get a host container selector, and use it to
IHostContainerSelector hostContainerSelector = getHostContainerSelector();
if (hostContainerSelector == null) {
- logError("handleServiceRegistering",
- "No defaultHostContainerSelector available");
+ logError("handleServiceRegistering", //$NON-NLS-1$
+ "No defaultHostContainerSelector available"); //$NON-NLS-1$
return Collections.EMPTY_LIST;
}
// select ECF remote service containers that match given exported
@@ -254,7 +207,7 @@ public class RemoteServiceAdmin implements
// If none found, log a warning and we're done
if (rsContainers == null || rsContainers.length == 0) {
logWarning(
- "handleServiceRegistered", "No remote service containers found for serviceReference=" //$NON-NLS-1$
+ "handleServiceRegistered", "No remote service containers found for serviceReference=" //$NON-NLS-1$ //$NON-NLS-2$
+ serviceReference
+ ". Remote service NOT EXPORTED"); //$NON-NLS-1$
return Collections.EMPTY_LIST;
@@ -270,10 +223,13 @@ public class RemoteServiceAdmin implements
serviceReference, rsContainers[i].getContainer()
.getID());
// If we've already got one, then create a new
- // ExportRegistration for it
+ // ExportRegistration for it and we're done
if (exportEndpoint != null)
exportRegistration = new ExportRegistration(exportEndpoint);
else {
+ // otherwise, actually export the service to create a new
+ // ExportEndpoint
+ // and use it to create a new ExportRegistration
exportRegistration = new ExportRegistration(
exportService(serviceReference,
overridingProperties, exportedInterfaces,
@@ -295,7 +251,174 @@ public class RemoteServiceAdmin implements
exportRegistrations);
}
- public class ExportEndpoint {
+ public org.osgi.service.remoteserviceadmin.ImportRegistration importService(
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
+
+ trace("importService", "endpointDescription=" + endpointDescription); //$NON-NLS-1$ //$NON-NLS-2$
+
+ // First, make sure that the client bundle has the IMPORT endpoint
+ // permission
+ checkEndpointPermission(endpointDescription, EndpointPermission.IMPORT);
+
+ if (endpointDescription.getServiceId() == 0)
+ return handleNonOSGiService(endpointDescription);
+
+ // First check to see whether it's one of ECF's endpoint descriptions
+ if (endpointDescription instanceof EndpointDescription) {
+ EndpointDescription ed = (EndpointDescription) endpointDescription;
+ // Now get IConsumerContainerSelector, to select the ECF container
+ // for the given endpointDescription
+ IConsumerContainerSelector consumerContainerSelector = getConsumerContainerSelector();
+ // If there is none, then we can go no further
+ if (consumerContainerSelector == null) {
+ logError("importService", //$NON-NLS-1$
+ "No defaultConsumerContainerSelector available"); //$NON-NLS-1$
+ return null;
+ }
+ // Select the rsContainer to handle the endpoint description
+ IRemoteServiceContainer rsContainer = consumerContainerSelector
+ .selectConsumerContainer(ed);
+ // If none found, log a warning and we're done
+ if (rsContainer == null) {
+ logWarning(
+ "importService", "No remote service container selected for endpoint=" //$NON-NLS-1$ //$NON-NLS-2$
+ + endpointDescription
+ + ". Remote service NOT IMPORTED"); //$NON-NLS-1$
+ return null;
+ }
+ // If one selected then import the service to create an import
+ // registration
+ ImportRegistration importRegistration = null;
+ synchronized (importedRegistrations) {
+ ImportEndpoint importEndpoint = findImportEndpoint(ed);
+ if (importEndpoint != null)
+ importRegistration = new ImportRegistration(importEndpoint);
+ else {
+ importEndpoint = importService(ed, rsContainer);
+ importRegistration = new ImportRegistration(importEndpoint);
+ if (importRegistration.getException() == null)
+ importedRegistrations.add(importRegistration);
+ }
+ }
+ // publish import event
+ publishImportEvent(importRegistration);
+ // Finally, return the importRegistration. It may be null or not.
+ return importRegistration;
+ } else {
+ logWarning("importService", "endpointDescription=" //$NON-NLS-1$ //$NON-NLS-2$
+ + endpointDescription
+ + " is not ECF EndpointDescription...ignoring"); //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ public Collection<org.osgi.service.remoteserviceadmin.ExportReference> getExportedServices() {
+ Collection<org.osgi.service.remoteserviceadmin.ExportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ExportReference>();
+ synchronized (exportedRegistrations) {
+ for (ExportRegistration reg : exportedRegistrations) {
+ org.osgi.service.remoteserviceadmin.ExportReference eRef = reg
+ .getExportReference();
+ if (eRef != null
+ && checkEndpointPermissionRead("getExportedServices", //$NON-NLS-1$
+ eRef.getExportedEndpoint()))
+ results.add(eRef);
+ }
+ }
+ return results;
+ }
+
+ public Collection<org.osgi.service.remoteserviceadmin.ImportReference> getImportedEndpoints() {
+ Collection<org.osgi.service.remoteserviceadmin.ImportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ImportReference>();
+ synchronized (importedRegistrations) {
+ for (ImportRegistration reg : importedRegistrations) {
+ org.osgi.service.remoteserviceadmin.ImportReference iRef = reg
+ .getImportReference();
+ if (iRef != null
+ && checkEndpointPermissionRead("getImportedEndpoints", //$NON-NLS-1$
+ iRef.getImportedEndpoint()))
+ results.add(iRef);
+ }
+ }
+ return results;
+ }
+
+ // end RemoteServiceAdmin service interface impl methods
+
+ private boolean checkEndpointPermissionRead(
+ String methodName,
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
+ try {
+ checkEndpointPermission(endpointDescription,
+ EndpointPermission.READ);
+ return true;
+ } catch (SecurityException e) {
+ logError(methodName,
+ "permission check failed for read access to endpointDescription=" //$NON-NLS-1$
+ + endpointDescription, e);
+ return false;
+ }
+ }
+
+ private BundleContext getClientBundleContext() {
+ return clientBundle.getBundleContext();
+ }
+
+ private Bundle getClientBundle() {
+ return clientBundle;
+ }
+
+ private boolean removeExportRegistration(
+ ExportRegistration exportRegistration) {
+ synchronized (exportedRegistrations) {
+ boolean removed = exportedRegistrations.remove(exportRegistration);
+ trace("removeExportRegistration", "exportRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
+ + exportRegistration + " exportedRegistrations=" //$NON-NLS-1$
+ + exportedRegistrations + " removed=" + removed); //$NON-NLS-1$
+ return removed;
+ }
+ }
+
+ private boolean removeImportRegistration(
+ ImportRegistration importRegistration) {
+ synchronized (importedRegistrations) {
+ boolean removed = importedRegistrations.remove(importRegistration);
+ trace("removeImportRegistration", "importRegistration=" //$NON-NLS-1$ //$NON-NLS-2$
+ + importRegistration + " importedRegistrations=" //$NON-NLS-1$
+ + importedRegistrations + " removed=" + removed); //$NON-NLS-1$
+ return removed;
+ }
+ }
+
+ private void closeDefaultContainerSelectors() {
+ if (defaultHostContainerSelectorRegistration != null) {
+ defaultHostContainerSelectorRegistration.unregister();
+ defaultHostContainerSelectorRegistration = null;
+ }
+ if (defaultHostContainerSelector != null) {
+ defaultHostContainerSelector.close();
+ defaultHostContainerSelector = null;
+ }
+ if (defaultConsumerContainerSelectorRegistration != null) {
+ defaultConsumerContainerSelectorRegistration.unregister();
+ defaultConsumerContainerSelectorRegistration = null;
+ }
+ if (defaultConsumerContainerSelector != null) {
+ defaultConsumerContainerSelector.close();
+ defaultConsumerContainerSelector = null;
+ }
+ }
+
+ private void checkEndpointPermission(
+ org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription,
+ String permissionType) throws SecurityException {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ return;
+ sm.checkPermission(new EndpointPermission(endpointDescription,
+ Activator.getDefault().getFrameworkUUID(), permissionType));
+ }
+
+ class ExportEndpoint {
private ServiceReference serviceReference;
private EndpointDescription endpointDescription;
@@ -374,13 +497,13 @@ public class RemoteServiceAdmin implements
}
public synchronized String toString() {
- return "ExportEndpoint[rsRegistration=" + rsRegistration
- + ", exportReference=" + exportReference + "]";
+ return "ExportEndpoint[rsRegistration=" + rsRegistration //$NON-NLS-1$
+ + ", exportReference=" + exportReference + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
- public class ExportRegistration implements
+ class ExportRegistration implements
org.osgi.service.remoteserviceadmin.ExportRegistration {
private ExportEndpoint exportEndpoint;
@@ -406,7 +529,7 @@ public class RemoteServiceAdmin implements
Throwable t = getException();
if (t != null)
throw new IllegalStateException(
- "Cannot get export reference as export registration is invalid",
+ "Cannot get export reference as export registration is invalid", //$NON-NLS-1$
t);
return (exportEndpoint == null) ? null : exportEndpoint
.getExportReference();
@@ -480,12 +603,12 @@ public class RemoteServiceAdmin implements
}
public synchronized String toString() {
- return "ExportRegistration[exportEndpoint=" + exportEndpoint + "]";
+ return "ExportRegistration[exportEndpoint=" + exportEndpoint + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
- public class ExportReference implements
+ class ExportReference implements
org.osgi.service.remoteserviceadmin.ExportReference {
private ServiceReference serviceReference;
@@ -511,13 +634,13 @@ public class RemoteServiceAdmin implements
}
public synchronized String toString() {
- return "ExportReference[serviceReference=" + serviceReference
- + ", endpointDescription=" + endpointDescription + "]";
+ return "ExportReference[serviceReference=" + serviceReference //$NON-NLS-1$
+ + ", endpointDescription=" + endpointDescription + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
- public class ImportEndpoint {
+ class ImportEndpoint {
private IRemoteServiceContainerAdapter rsContainerAdapter;
private EndpointDescription endpointDescription;
@@ -614,9 +737,9 @@ public class RemoteServiceAdmin implements
}
public synchronized String toString() {
- return "ImportEndpoint[rsReference=" + rsReference
- + ", proxyRegistration=" + proxyRegistration
- + ", importReference=" + importReference + "]";
+ return "ImportEndpoint[rsReference=" + rsReference //$NON-NLS-1$
+ + ", proxyRegistration=" + proxyRegistration //$NON-NLS-1$
+ + ", importReference=" + importReference + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
synchronized boolean match(EndpointDescription ed) {
@@ -631,7 +754,7 @@ public class RemoteServiceAdmin implements
}
- public class ImportRegistration implements
+ class ImportRegistration implements
org.osgi.service.remoteserviceadmin.ImportRegistration {
private ImportEndpoint importEndpoint;
@@ -670,7 +793,7 @@ public class RemoteServiceAdmin implements
Throwable t = getException();
if (t != null)
throw new IllegalStateException(
- "Cannot get import reference as registration not properly initialized",
+ "Cannot get import reference as registration not properly initialized", //$NON-NLS-1$
t);
return importEndpoint == null ? null : importEndpoint
.getImportReference();
@@ -707,12 +830,12 @@ public class RemoteServiceAdmin implements
}
public synchronized String toString() {
- return "ImportRegistration[importEndpoint=" + importEndpoint + "]";
+ return "ImportRegistration[importEndpoint=" + importEndpoint + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
- public class ImportReference implements
+ class ImportReference implements
org.osgi.service.remoteserviceadmin.ImportReference {
private ServiceReference importedServiceReference;
@@ -738,9 +861,9 @@ public class RemoteServiceAdmin implements
}
public synchronized String toString() {
- return "ImportReference[importedServiceReference="
- + importedServiceReference + ", endpointDescription="
- + endpointDescription + "]";
+ return "ImportReference[importedServiceReference=" //$NON-NLS-1$
+ + importedServiceReference + ", endpointDescription=" //$NON-NLS-1$
+ + endpointDescription + "]"; //$NON-NLS-1$
}
}
@@ -765,8 +888,8 @@ public class RemoteServiceAdmin implements
EndpointDescription endpointDescription) {
EventAdmin eventAdmin = getEventAdmin();
if (eventAdmin == null) {
- logWarning("postEvent", "No event admin available to post event="
- + event + " with endpointDescription="
+ logWarning("postEvent", "No event admin available to post event=" //$NON-NLS-1$ //$NON-NLS-2$
+ + event + " with endpointDescription=" //$NON-NLS-1$
+ endpointDescription);
return;
}
@@ -774,48 +897,48 @@ public class RemoteServiceAdmin implements
String eventTypeName = null;
switch (eventType) {
case (RemoteServiceAdminEvent.EXPORT_REGISTRATION):
- eventTypeName = "EXPORT_REGISTRATION";
+ eventTypeName = "EXPORT_REGISTRATION"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.EXPORT_ERROR):
- eventTypeName = "EXPORT_ERROR";
+ eventTypeName = "EXPORT_ERROR"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.EXPORT_UNREGISTRATION):
- eventTypeName = "EXPORT_UNREGISTRATION";
+ eventTypeName = "EXPORT_UNREGISTRATION"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.EXPORT_WARNING):
- eventTypeName = "EXPORT_WARNING";
+ eventTypeName = "EXPORT_WARNING"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_REGISTRATION):
- eventTypeName = "IMPORT_REGISTRATION";
+ eventTypeName = "IMPORT_REGISTRATION"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_ERROR):
- eventTypeName = "IMPORT_ERROR";
+ eventTypeName = "IMPORT_ERROR"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_UNREGISTRATION):
- eventTypeName = "IMPORT_UNREGISTRATION";
+ eventTypeName = "IMPORT_UNREGISTRATION"; //$NON-NLS-1$
break;
case (RemoteServiceAdminEvent.IMPORT_WARNING):
- eventTypeName = "IMPORT_WARNING";
+ eventTypeName = "IMPORT_WARNING"; //$NON-NLS-1$
break;
}
if (eventTypeName == null)
- logError("postEvent", "Event type=" + eventType
- + " not understood for event=" + event + ". Not posting");
- String topic = "org/osgi/service/remoteserviceadmin/" + eventTypeName;
+ logError("postEvent", "Event type=" + eventType //$NON-NLS-1$ //$NON-NLS-2$
+ + " not understood for event=" + event + ". Not posting"); //$NON-NLS-1$ //$NON-NLS-2$
+ String topic = "org/osgi/service/remoteserviceadmin/" + eventTypeName; //$NON-NLS-1$
Bundle rsaBundle = getClientBundle();
Dictionary eventProperties = new Properties();
- eventProperties.put("clientBundle", rsaBundle);
- eventProperties.put("clientBundle.id",
+ eventProperties.put("clientBundle", rsaBundle); //$NON-NLS-1$
+ eventProperties.put("clientBundle.id", //$NON-NLS-1$
new Long(rsaBundle.getBundleId()));
- eventProperties.put("clientBundle.symbolicname",
+ eventProperties.put("clientBundle.symbolicname", //$NON-NLS-1$
rsaBundle.getSymbolicName());
- eventProperties.put("clientBundle.version", rsaBundle.getVersion());
+ eventProperties.put("clientBundle.version", rsaBundle.getVersion()); //$NON-NLS-1$
String[] signers = getSignersForBundle(clientBundle);
if (signers != null && signers.length > 0)
- eventProperties.put("clientBundle.signer", signers);
+ eventProperties.put("clientBundle.signer", signers); //$NON-NLS-1$
Throwable t = event.getException();
if (t != null)
- eventProperties.put("cause", t);
+ eventProperties.put("cause", t); //$NON-NLS-1$
long serviceId = endpointDescription.getServiceId();
if (serviceId != 0)
eventProperties
@@ -842,8 +965,8 @@ public class RemoteServiceAdmin implements
.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS,
importedConfigs.toArray(new String[importedConfigs
.size()]));
- eventProperties.put("timestamp", new Long(new Date().getTime()));
- eventProperties.put("event", event);
+ eventProperties.put("timestamp", new Long(new Date().getTime())); //$NON-NLS-1$
+ eventProperties.put("event", event); //$NON-NLS-1$
postRemoteServiceAdminEvent(topic, eventProperties);
}
@@ -917,53 +1040,6 @@ public class RemoteServiceAdmin implements
return results.toArray(new RemoteServiceAdminListener[results.size()]);
}
- public Collection<org.osgi.service.remoteserviceadmin.ExportReference> getExportedServices() {
- Collection<org.osgi.service.remoteserviceadmin.ExportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ExportReference>();
- synchronized (exportedRegistrations) {
- for (ExportRegistration reg : exportedRegistrations) {
- org.osgi.service.remoteserviceadmin.ExportReference eRef = reg
- .getExportReference();
- if (eRef != null
- && checkEndpointPermissionRead("getExportedServices",
- eRef.getExportedEndpoint()))
- results.add(eRef);
- }
- }
- return results;
- }
-
- private boolean checkEndpointPermissionRead(
- String methodName,
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- try {
- checkEndpointPermission(endpointDescription,
- EndpointPermission.READ);
- return true;
- } catch (SecurityException e) {
- logError(methodName,
- "permission check failed for read access to endpointDescription="
- + endpointDescription, e);
- return false;
- }
- }
-
- public Collection<org.osgi.service.remoteserviceadmin.ImportReference> getImportedEndpoints() {
- Collection<org.osgi.service.remoteserviceadmin.ImportReference> results = new ArrayList<org.osgi.service.remoteserviceadmin.ImportReference>();
- synchronized (importedRegistrations) {
- for (ImportRegistration reg : importedRegistrations) {
- org.osgi.service.remoteserviceadmin.ImportReference iRef = reg
- .getImportReference();
- if (iRef != null
- && checkEndpointPermissionRead("getImportedEndpoints",
- iRef.getImportedEndpoint()))
- results.add(iRef);
- }
- }
- return results;
- }
-
- // RemoteServiceAdmin service interface impl methods
-
private ExportEndpoint findExistingExportEndpoint(
ServiceReference serviceReference, ID containerID) {
for (ExportRegistration eReg : exportedRegistrations) {
@@ -975,67 +1051,6 @@ public class RemoteServiceAdmin implements
return null;
}
- public org.osgi.service.remoteserviceadmin.ImportRegistration importService(
- org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
- trace("importService", "endpointDescription=" + endpointDescription);
-
- checkEndpointPermission(endpointDescription, EndpointPermission.IMPORT);
-
- if (endpointDescription.getServiceId() == 0)
- return handleNonOSGiService(endpointDescription);
-
- // First check to see whether it's one of ECF's endpoint descriptions
- if (endpointDescription instanceof EndpointDescription) {
- EndpointDescription ed = (EndpointDescription) endpointDescription;
- // Now get IConsumerContainerSelector, to select the ECF container
- // for the given endpointDescription
- IConsumerContainerSelector consumerContainerSelector = getConsumerContainerSelector();
- // If there is none, then we can go no further
- if (consumerContainerSelector == null) {
- logError("importService",
- "No defaultConsumerContainerSelector available");
- return null;
- }
- // Select the rsContainer to handle the endpoint description
- IRemoteServiceContainer rsContainer = consumerContainerSelector
- .selectConsumerContainer(ed);
- // If none found, log a warning and we're done
- if (rsContainer == null) {
- logWarning(
- "importService", "No remote service container selected for endpoint=" //$NON-NLS-1$
- + endpointDescription
- + ". Remote service NOT IMPORTED"); //$NON-NLS-1$
- return null;
- }
- // If one selected then import the service to create an import
- // registration
- ImportRegistration importRegistration = null;
- synchronized (importedRegistrations) {
- ImportEndpoint importEndpoint = findImportEndpoint(ed);
- if (importEndpoint != null)
- importRegistration = new ImportRegistration(importEndpoint);
- else {
- importEndpoint = importService(ed, rsContainer);
- importRegistration = new ImportRegistration(importEndpoint);
- if (importRegistration.getException() == null)
- importedRegistrations.add(importRegistration);
- }
- }
- // publish import event
- publishImportEvent(importRegistration);
- // Finally, return the importRegistration. It may be null or not.
- return importRegistration;
- } else {
- logWarning("importService", "endpointDescription="
- + endpointDescription
- + " is not ECF EndpointDescription...ignoring");
- return null;
- }
- }
-
- private Object eventAdminTrackerLock = new Object();
- private ServiceTracker eventAdminTracker;
-
private EventAdmin getEventAdmin() {
synchronized (eventAdminTrackerLock) {
eventAdminTracker = new ServiceTracker(getClientBundleContext(),
@@ -1049,9 +1064,9 @@ public class RemoteServiceAdmin implements
Dictionary eventProperties) {
EventAdmin eventAdmin = getEventAdmin();
if (eventAdmin == null) {
- logError("postRemoteServiceAdminEvent",
- "No EventAdmin service available to send eventTopic="
- + topic + " eventProperties=" + eventProperties);
+ logError("postRemoteServiceAdminEvent", //$NON-NLS-1$
+ "No EventAdmin service available to send eventTopic=" //$NON-NLS-1$
+ + topic + " eventProperties=" + eventProperties); //$NON-NLS-1$
return;
}
eventAdmin.postEvent(new Event(topic, eventProperties));
@@ -1107,7 +1122,7 @@ public class RemoteServiceAdmin implements
}
}
- private IHostContainerSelector getHostContainerSelector() {
+ protected IHostContainerSelector getHostContainerSelector() {
synchronized (hostContainerSelectorTrackerLock) {
if (hostContainerSelectorTracker == null) {
hostContainerSelectorTracker = new ServiceTracker(
@@ -1120,7 +1135,7 @@ public class RemoteServiceAdmin implements
.getService();
}
- private IConsumerContainerSelector getConsumerContainerSelector() {
+ protected IConsumerContainerSelector getConsumerContainerSelector() {
synchronized (consumerContainerSelectorTrackerLock) {
if (consumerContainerSelectorTracker == null) {
consumerContainerSelectorTracker = new ServiceTracker(
@@ -1184,8 +1199,8 @@ public class RemoteServiceAdmin implements
if (version != null && !version.equals(Version.emptyVersion))
packageVersion = version.toString();
else
- logWarning("createExportEndpointDescription",
- "No or empty version specified for exported service interface="
+ logWarning("createExportEndpointDescription", //$NON-NLS-1$
+ "No or empty version specified for exported service interface=" //$NON-NLS-1$
+ exportedInterfaces[i]);
}
// Only set the package version if we have a non-null value
@@ -1364,8 +1379,8 @@ public class RemoteServiceAdmin implements
org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
// With non-OSGi service id (service id=0), we log a warning and return
// null;
- logWarning("handleNonOSGiService",
- "OSGi remote service id is 0 for endpointDescription="
+ logWarning("handleNonOSGiService", //$NON-NLS-1$
+ "OSGi remote service id is 0 for endpointDescription=" //$NON-NLS-1$
+ endpointDescription);
return null;
}
@@ -1383,8 +1398,8 @@ public class RemoteServiceAdmin implements
.getRemoteService(selectedRsReference);
if (rs == null)
throw new NullPointerException(
- "getRemoteService returned null for selectedRsReference="
- + selectedRsReference + ",rsContainerID="
+ "getRemoteService returned null for selectedRsReference=" //$NON-NLS-1$
+ + selectedRsReference + ",rsContainerID=" //$NON-NLS-1$
+ rsContainerID);
Map proxyProperties = createProxyProperties(endpointDescription,
@@ -1419,16 +1434,16 @@ public class RemoteServiceAdmin implements
try {
result.add(bundle.loadClass(interfaces[i]));
} catch (ClassNotFoundException e) {
- logError("loadInterfacesViaBundle", "interface="
- + interfaces[i] + " cannot be loaded by clientBundle="
+ logError("loadInterfacesViaBundle", "interface=" //$NON-NLS-1$ //$NON-NLS-2$
+ + interfaces[i] + " cannot be loaded by clientBundle=" //$NON-NLS-1$
+ bundle.getSymbolicName(), e);
continue;
} catch (IllegalStateException e) {
logError(
- "loadInterfacesViaBundle",
- "interface="
+ "loadInterfacesViaBundle", //$NON-NLS-1$
+ "interface=" //$NON-NLS-1$
+ interfaces[i]
- + " cannot be loaded since clientBundle is in illegal state",
+ + " cannot be loaded since clientBundle is in illegal state", //$NON-NLS-1$
e);
continue;
}
@@ -1436,7 +1451,7 @@ public class RemoteServiceAdmin implements
return result;
}
- protected class ProxyServiceFactory implements ServiceFactory {
+ class ProxyServiceFactory implements ServiceFactory {
private IRemoteService remoteService;
private Map<String, Version> interfaceVersions;
@@ -1475,10 +1490,10 @@ public class RemoteServiceAdmin implements
// load...otherwise the service can't be accessed
if (serviceInterfaceClasses.size() < 1)
throw new RuntimeException(
- "ProxyServiceFactory cannot load any serviceInterfaces="
+ "ProxyServiceFactory cannot load any serviceInterfaces=" //$NON-NLS-1$
+ serviceInterfaceClasses
- + " for serviceReference=" + serviceReference
- + " via clientBundle=" + bundleSymbolicName);
+ + " for serviceReference=" + serviceReference //$NON-NLS-1$
+ + " via clientBundle=" + bundleSymbolicName); //$NON-NLS-1$
// Now verify that the classes are of valid versions
verifyServiceInterfaceVersionsForProxy(requestingBundle,
@@ -1492,8 +1507,8 @@ public class RemoteServiceAdmin implements
.toArray(new Class[serviceInterfaceClasses.size()]));
} catch (ECFException e) {
throw new ServiceException(
- "ProxyServiceFactory cannot create proxy for clientBundle="
- + bundleSymbolicName + " from serviceReference="
+ "ProxyServiceFactory cannot create proxy for clientBundle=" //$NON-NLS-1$
+ + bundleSymbolicName + " from serviceReference=" //$NON-NLS-1$
+ serviceReference, e);
}
@@ -1600,9 +1615,9 @@ public class RemoteServiceAdmin implements
}
private String getPackageName(String className) {
- int lastDotIndex = className.lastIndexOf(".");
+ int lastDotIndex = className.lastIndexOf("."); //$NON-NLS-1$
if (lastDotIndex == -1)
- return "";
+ return ""; //$NON-NLS-1$
return className.substring(0, lastDotIndex);
}
@@ -1611,8 +1626,8 @@ public class RemoteServiceAdmin implements
IPackageVersionComparator packageVersionComparator = getPackageVersionComparator();
if (packageVersionComparator == null) {
logError(
- "verifyServiceInterfaceVersionsForProxy",
- "No package version comparator available, skipping package version comparison for service classes="
+ "verifyServiceInterfaceVersionsForProxy", //$NON-NLS-1$
+ "No package version comparator available, skipping package version comparison for service classes=" //$NON-NLS-1$
+ classes);
return;
}
@@ -1624,16 +1639,16 @@ public class RemoteServiceAdmin implements
getPackageAdmin(), clazz);
if (exportedPackage == null)
throw new NullPointerException(
- "No exported package found for class=" + className);
+ "No exported package found for class=" + className); //$NON-NLS-1$
// Now lookup version from specification
Version remotePackageVersion = interfaceVersions.get(className);
if (remotePackageVersion == null)
- throw new NullPointerException("Remote package=" + packageName
- + " has no Version");
+ throw new NullPointerException("Remote package=" + packageName //$NON-NLS-1$
+ + " has no Version"); //$NON-NLS-1$
Version localPackageVersion = exportedPackage.getVersion();
if (localPackageVersion == null)
- throw new NullPointerException("Local package=" + packageName
- + " has no Version");
+ throw new NullPointerException("Local package=" + packageName //$NON-NLS-1$
+ + " has no Version"); //$NON-NLS-1$
// Now do compare via package version comparator service
packageVersionComparator.comparePackageVersions(packageName,
@@ -1648,12 +1663,12 @@ public class RemoteServiceAdmin implements
if (rsRefs.size() == 0)
return null;
if (rsRefs.size() > 1) {
- logWarning("selectRemoteServiceReference", "rsRefs=" + rsRefs
- + ",targetID=" + targetID + ",idFilter=" + idFilter
- + ",interfaces=" + interfaces + ",rsFilter=" + rsFilter
- + ",rsContainer=" + rsContainer.getContainer().getID()
- + " has " + rsRefs.size()
- + " values. Selecting the first element");
+ logWarning("selectRemoteServiceReference", "rsRefs=" + rsRefs //$NON-NLS-1$ //$NON-NLS-2$
+ + ",targetID=" + targetID + ",idFilter=" + idFilter //$NON-NLS-1$ //$NON-NLS-2$
+ + ",interfaces=" + interfaces + ",rsFilter=" + rsFilter //$NON-NLS-1$ //$NON-NLS-2$
+ + ",rsContainer=" + rsContainer.getContainer().getID() //$NON-NLS-1$
+ + " has " + rsRefs.size() //$NON-NLS-1$
+ + " values. Selecting the first element"); //$NON-NLS-1$
}
return rsRefs.iterator().next();
}
@@ -1729,7 +1744,7 @@ public class RemoteServiceAdmin implements
IRemoteServiceRegistration remoteRegistration = null;
Throwable exception = null;
try {
- // Check security access
+ // Check security access for export
checkEndpointPermission(new EndpointDescription(serviceReference,
endpointDescriptionProperties), EndpointPermission.EXPORT);
@@ -1769,8 +1784,8 @@ public class RemoteServiceAdmin implements
private ImportEndpoint importService(
EndpointDescription endpointDescription,
IRemoteServiceContainer rsContainer) {
- trace("doImportService", "endpointDescription=" + endpointDescription
- + ",rsContainerID=" + rsContainer.getContainer().getID());
+ trace("doImportService", "endpointDescription=" + endpointDescription //$NON-NLS-1$ //$NON-NLS-2$
+ + ",rsContainerID=" + rsContainer.getContainer().getID()); //$NON-NLS-1$
// Get interfaces from endpoint description
Collection<String> interfaces = endpointDescription.getInterfaces();
Assert.isNotNull(interfaces);
@@ -1805,11 +1820,11 @@ public class RemoteServiceAdmin implements
.getRemoteServiceReferences(targetID, idFilter, intf,
rsFilter);
if (refs == null) {
- logWarning("doImportService",
- "getRemoteServiceReferences return null for targetID="
- + targetID + ",idFilter=" + idFilter
- + ",intf=" + intf + ",rsFilter=" + rsFilter
- + " on rsContainerID=" + rsContainerID);
+ logWarning("doImportService", //$NON-NLS-1$
+ "getRemoteServiceReferences return null for targetID=" //$NON-NLS-1$
+ + targetID + ",idFilter=" + idFilter //$NON-NLS-1$
+ + ",intf=" + intf + ",rsFilter=" + rsFilter //$NON-NLS-1$ //$NON-NLS-2$
+ + " on rsContainerID=" + rsContainerID); //$NON-NLS-1$
continue;
}
for (int i = 0; i < refs.length; i++)
@@ -1818,22 +1833,21 @@ public class RemoteServiceAdmin implements
IRemoteServiceReference selectedRsReference = selectRemoteServiceReference(
rsRefs, targetID, idFilter, interfaces, rsFilter,
rsContainer);
-
- if (selectedRsReference == null) {
- logWarning("doImportService",
- "selectRemoteServiceReference returned null for rsRefs="
- + rsRefs + ",targetID=" + targetID
- + ",idFilter=" + idFilter + ",interfaces="
- + interfaces + ",rsFilter=" + rsFilter
- + ",rsContainerID=" + rsContainerID);
- return null;
- }
+ // If none found, we obviously can't continue
+ if (selectedRsReference == null)
+ throw new RemoteReferenceNotFoundException(targetID, idFilter,
+ interfaces, rsFilter);
return createAndRegisterProxy(endpointDescription, rsContainer,
selectedRsReference);
} catch (Exception e) {
- return new ImportEndpoint(rsContainer.getContainerAdapter(),
- endpointDescription, e);
+ logError(
+ "importService", "selectRemoteServiceReference returned null for rsRefs=" //$NON-NLS-1$
+ + rsRefs + ",targetID=" + targetID //$NON-NLS-1$
+ + ",idFilter=" + idFilter + ",interfaces=" //$NON-NLS-1$ //$NON-NLS-2$
+ + interfaces + ",rsFilter=" + rsFilter //$NON-NLS-1$
+ + ",rsContainerID=" + rsContainerID, e);
+ return new ImportEndpoint(containerAdapter, endpointDescription, e);
}
}
@@ -1858,8 +1872,8 @@ public class RemoteServiceAdmin implements
}
public void close() {
- trace("close", "closing importedRegistrations=" + importedRegistrations
- + " exportedRegistrations=" + exportedRegistrations);
+ trace("close", "closing importedRegistrations=" + importedRegistrations //$NON-NLS-1$ //$NON-NLS-2$
+ + " exportedRegistrations=" + exportedRegistrations); //$NON-NLS-1$
closeRemoteServiceAdminListenerTracker();
closeEventAdminTracker();
closePackageAdminTracker();
@@ -1894,7 +1908,7 @@ public class RemoteServiceAdmin implements
}
// Now close all of them
for (ImportRegistration removedReg : removedRegistrations) {
- trace("unimportService", "closing importRegistration=" + removedReg);
+ trace("unimportService", "closing importRegistration=" + removedReg); //$NON-NLS-1$ //$NON-NLS-2$
removedReg.close();
}
}
@@ -1925,4 +1939,43 @@ public class RemoteServiceAdmin implements
logError(methodName, message, (Throwable) null);
}
+ public class RemoteServiceAdminEvent extends
+ org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent {
+
+ private ID containerID;
+
+ public RemoteServiceAdminEvent(
+ ID containerID,
+ int type,
+ Bundle source,
+ org.osgi.service.remoteserviceadmin.ExportReference exportReference,
+ Throwable exception) {
+ super(type, source, exportReference, exception);
+ this.containerID = containerID;
+ }
+
+ public RemoteServiceAdminEvent(
+ ID containerID,
+ int type,
+ Bundle source,
+ org.osgi.service.remoteserviceadmin.ImportReference importReference,
+ Throwable exception) {
+ super(type, source, importReference, exception);
+ this.containerID = containerID;
+ }
+
+ public ID getContainerID() {
+ return containerID;
+ }
+
+ public String toString() {
+ return "RemoteServiceAdminEvent[containerID=" + containerID //$NON-NLS-1$
+ + ", getType()=" + getType() + ", getSource()=" + getSource() //$NON-NLS-1$ //$NON-NLS-2$
+ + ", getException()=" + getException() //$NON-NLS-1$
+ + ", getImportReference()=" + getImportReference() //$NON-NLS-1$
+ + ", getExportReference()=" + getExportReference() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ }
+
}
diff --git a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java
index fb7336cfc..5e3d63c6f 100644
--- a/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java
+++ b/incubation/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdminEvent.java
@@ -27,11 +27,11 @@ public class RemoteServiceAdminEvent extends
}
public String toString() {
- return "RemoteServiceAdminEvent[containerID=" + containerID
- + ", getType()=" + getType() + ", getSource()=" + getSource()
- + ", getException()=" + getException()
- + ", getImportReference()=" + getImportReference()
- + ", getExportReference()=" + getExportReference() + "]";
+ return "RemoteServiceAdminEvent[containerID=" + containerID //$NON-NLS-1$
+ + ", getType()=" + getType() + ", getSource()=" + getSource() //$NON-NLS-1$ //$NON-NLS-2$
+ + ", getException()=" + getException() //$NON-NLS-1$
+ + ", getImportReference()=" + getImportReference() //$NON-NLS-1$
+ + ", getExportReference()=" + getExportReference() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
}
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 03700ab22..e3d25f552 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
@@ -90,9 +90,9 @@ public class ServiceInfoFactory extends AbstractMetadataFactory implements
}
} catch (Exception e) {
logError(
- "createServiceInfoForDiscovery",
- "Exception creating service info for endpointDescription="
- + endpointDescription + ",advertiser=" + advertiser,
+ "createServiceInfoForDiscovery", //$NON-NLS-1$
+ "Exception creating service info for endpointDescription=" //$NON-NLS-1$
+ + endpointDescription + ",advertiser=" + advertiser, //$NON-NLS-1$
e);
return null;
}
@@ -116,7 +116,7 @@ public class ServiceInfoFactory extends AbstractMetadataFactory implements
protected URI createURI(EndpointDescription endpointDescription,
IDiscoveryAdvertiser advertiser, IServiceTypeID serviceTypeID,
String serviceName) throws URISyntaxException {
- String path = "/" + serviceName;
+ String path = "/" + serviceName; //$NON-NLS-1$
String str = endpointDescription.getId();
URI uri = null;
while (true) {

Back to the top