diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi')
5 files changed, 105 insertions, 53 deletions
diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java index 65f1000265..ee7e5ba1bd 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointDescription.java @@ -65,9 +65,9 @@ import org.osgi.framework.Version; public class EndpointDescription { private final Map<String, Object> properties; private final List<String> interfaces; - private final long remoteServiceID; - private final String remoteFrameworkUUID; - private final String remoteID; + private final long serviceId; + private final String frameworkUUID; + private final String id; /** * Create an Endpoint Description from a Map. @@ -110,10 +110,10 @@ public class EndpointDescription { this.properties = Collections.unmodifiableMap(props); /* properties must be initialized before calling the following methods */ interfaces = verifyObjectClassProperty(); - remoteServiceID = verifyLongProperty(ENDPOINT_SERVICE_ID); - remoteFrameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); - remoteID = verifyStringProperty(ENDPOINT_ID); - if (remoteID == null) { + serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID); + frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); + id = verifyStringProperty(ENDPOINT_ID); + if (id == null) { throw new IllegalArgumentException(ENDPOINT_ID + " property must be set"); } @@ -204,10 +204,10 @@ public class EndpointDescription { this.properties = Collections.unmodifiableMap(props); /* properties must be initialized before calling the following methods */ interfaces = verifyObjectClassProperty(); - remoteServiceID = verifyLongProperty(ENDPOINT_SERVICE_ID); - remoteFrameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); - remoteID = verifyStringProperty(ENDPOINT_ID); - if (remoteID == null) { + serviceId = verifyLongProperty(ENDPOINT_SERVICE_ID); + frameworkUUID = verifyStringProperty(ENDPOINT_FRAMEWORK_UUID); + id = verifyStringProperty(ENDPOINT_ID); + if (id == null) { throw new IllegalArgumentException(ENDPOINT_ID + " property must be set"); } @@ -312,8 +312,8 @@ public class EndpointDescription { * * @return The id of the endpoint, never <code>null</code>. */ - public String getRemoteID() { - return remoteID; + public String getId() { + return id; } /** @@ -382,8 +382,8 @@ public class EndpointDescription { * not relate to an OSGi service. * */ - public long getRemoteServiceID() { - return remoteServiceID; + public long getServiceId() { + return serviceId; } /** @@ -477,8 +477,8 @@ public class EndpointDescription { * @return Remote Framework UUID, or null if this endpoint is not associated * with an OSGi framework having a framework uuid. */ - public String getRemoteFrameworkUUID() { - return remoteFrameworkUUID; + public String getFrameworkUUID() { + return frameworkUUID; } /** @@ -507,13 +507,13 @@ public class EndpointDescription { return true; } - if (this.getRemoteFrameworkUUID() == null) { + if (this.getFrameworkUUID() == null) { return false; } - return (this.getRemoteServiceID() == other.getRemoteServiceID()) - && this.getRemoteFrameworkUUID().equals( - other.getRemoteFrameworkUUID()); + return (this.getServiceId() == other.getServiceId()) + && this.getFrameworkUUID().equals( + other.getFrameworkUUID()); } /** @@ -522,7 +522,7 @@ public class EndpointDescription { * @return An integer which is a hash code value for this object. */ public int hashCode() { - return getRemoteID().hashCode(); + return getId().hashCode(); } /** @@ -544,8 +544,8 @@ public class EndpointDescription { if (!(other instanceof EndpointDescription)) { return false; } - return getRemoteID().equals( - ((EndpointDescription) other).getRemoteID()); + return getId().equals( + ((EndpointDescription) other).getId()); } /** @@ -580,6 +580,63 @@ public class EndpointDescription { } /** + * Returns the string representation of this EndpointDescription. + * + * @return String form of this EndpointDescription. + */ + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append('{'); + Iterator<Map.Entry<String, Object>> iter = properties.entrySet() + .iterator(); + boolean comma = false; + while (iter.hasNext()) { + Map.Entry<String, Object> entry = iter.next(); + if (comma) { + sb.append(", "); + } + else { + comma = true; + } + sb.append(entry.getKey()); + sb.append('='); + Object value = entry.getValue(); + if (value != null) { + Class< ? > valueType = value.getClass(); + if (Object[].class.isAssignableFrom(valueType)) { + append(sb, (Object[]) value); + continue; + } + } + sb.append(value); + } + sb.append('}'); + return sb.toString(); + } + + /** + * Append the specified Object array to the specified StringBuffer. + * + * @param sb Receiving StringBuffer. + * @param value Object array to append to the specified StringBuffer. + */ + private static void append(StringBuffer sb, Object[] value) { + sb.append('['); + boolean comma = false; + final int length = value.length; + for (int i = 0; i < length; i++) { + if (comma) { + sb.append(", "); + } + else { + comma = true; + } + sb.append(String.valueOf(value[i])); + } + sb.append(']'); + } + + /** * Unmodifiable Dictionary wrapper for a Map. This class is also used by * EndpointPermission. */ diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java index 9a56c53f4f..941b899fbb 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointListener.java @@ -23,17 +23,17 @@ package org.osgi.service.remoteserviceadmin; * is interested in Endpoint Descriptions. * * This white board service can be used in many different scenarios. However, - * the primary use case is to allow a remote manager to be informed of End Point + * the primary use case is to allow a remote manager to be informed of Endpoint * Descriptions available in the network and inform the network about available - * End Point Descriptions. + * Endpoint Descriptions. * * Both the network bundle and the manager bundle register an Endpoint Listener - * service. The manager informs the network bundle about End Points that it + * service. The manager informs the network bundle about Endpoints that it * creates. The network bundles then uses a protocol like SLP to announce these * local end-points to the network. * * If the network bundle discovers a new Endpoint through its discovery - * protocol, then it sends an End Point Description to all the End Point + * protocol, then it sends an Endpoint Description to all the Endpoint * Listener services that are registered (except its own) that have specified an * interest in that endpoint. * diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java index 84a7ba512e..433e22e543 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/EndpointPermission.java @@ -165,11 +165,11 @@ public final class EndpointPermission extends Permission { setTransients(null, parseActions(actions)); Map<String, Object> props; if ((localFrameworkUUID != null) - && localFrameworkUUID.equals(endpoint.getRemoteFrameworkUUID())) { + && localFrameworkUUID.equals(endpoint.getFrameworkUUID())) { props = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); props.putAll(endpoint.getProperties()); props.put(ENDPOINT_FRAMEWORK_UUID, new String[] { - endpoint.getRemoteFrameworkUUID(), "<<LOCAL>>"}); + endpoint.getFrameworkUUID(), "<<LOCAL>>"}); } else { props = endpoint.getProperties(); @@ -190,7 +190,7 @@ public final class EndpointPermission extends Permission { throw new IllegalArgumentException("invalid endpoint: null"); } StringBuffer sb = new StringBuffer("(" + ENDPOINT_ID + "="); - sb.append(endpoint.getRemoteID()); + sb.append(endpoint.getId()); sb.append(")"); return sb.toString(); } diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java index 0b436c361a..98f56a07ae 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdmin.java @@ -36,15 +36,13 @@ import org.osgi.framework.ServiceReference; public interface RemoteServiceAdmin { /** - * Export a service to a given endpoint. The Remote Service Admin must - * create an endpoint from the given description that can be used by other + * Export a service to a given Endpoint. The Remote Service Admin must + * create an Endpoint from the given description that can be used by other * Distrbution Providers to connect to this Remote Service Admin and use the * exported service. This method can return null if the service could not be - * exported because the endpoint could not be implemented by this Remote + * exported because the Endpoint could not be implemented by this Remote * Service Admin. * - * TODO Peter to update for case insensitive properties - * * The properties on a Service Reference are case insensitive while the * properties on a <code>properties</code> are case sensitive. A value in * the <code>properties</code> must therefore override any case variant in @@ -52,26 +50,23 @@ public interface RemoteServiceAdmin { * * <p> * If the caller does not have the appropriate - * <code>EndpointPermission[endpoint,EXPORT]</code> for an endpoint, and the + * <code>EndpointPermission[endpoint,EXPORT]</code> for an Endpoint, and the * Java Runtime Environment supports permissions, then the * {@link ExportRegistration#getException() getException} method on the * corresponding returned {@link ExportRegistration} will return a * <code>SecurityException</code>. * * @param reference The Service Reference to export. - * @param properties The properties to create a local endpoint that can be + * @param properties The properties to create a local Endpoint that can be * implemented by this Remote Service Admin. If this is null, the - * endpoint will be determined by the properties on the service. The + * Endpoint will be determined by the properties on the service. The * properties are the same as given for an exported service. They are * overlaid over any properties the service defines (case * insensitive). This parameter can be <code>null</code>, this should * be treated as an empty map. * - * TODO Peter The return description does not mesh with returning a - * list! Why a list and not just one? * @return An Export Registration that combines the Endpoint Description and - * the Service Reference or <code>null</code> if the service could - * not be exported. + * the Service Reference. Is never <code>null</code>. * @throws IllegalArgumentException If any of the properties has a value * that is not syntactically correct or if the service properties * and the overlaid properties do not contain a @@ -84,17 +79,17 @@ public interface RemoteServiceAdmin { Map<String, Object> properties); /** - * Import a service from an endpoint. The Remote Service Admin must use the - * given endpoint to create a proxy. This method can return null if the + * Import a service from an Endpoint. The Remote Service Admin must use the + * given Endpoint to create a proxy. This method can return null if the * service could not be imported. * * @param endpoint The Endpoint Description to be used for import. * @return An Import Registration that combines the Endpoint Description and - * the Service Reference or <code>null</code> if the endpoint could + * the Service Reference or <code>null</code> if the Endpoint could * not be imported. * @throws SecurityException If the caller does not have the appropriate * <code>EndpointPermission[endpoint,IMPORT]</code> for the - * endpoint, and the Java Runtime Environment supports permissions. + * Endpoint, and the Java Runtime Environment supports permissions. */ ImportRegistration importService(EndpointDescription endpoint); @@ -103,9 +98,9 @@ public interface RemoteServiceAdmin { * * <p> * If the caller does not have the appropriate - * <code>EndpointPermission[endpoint,READ]</code> for an endpoint, and the + * <code>EndpointPermission[endpoint,READ]</code> for an Endpoint, and the * Java Runtime Environment supports permissions, then returned collection - * will not contain a reference to the exported endpoint. + * will not contain a reference to the exported Endpoint. * * @return A <code>Collection</code> of {@link ExportReference}s that are * currently active. @@ -117,9 +112,9 @@ public interface RemoteServiceAdmin { * * <p> * If the caller does not have the appropriate - * <code>EndpointPermission[endpoint,READ]</code> for an endpoint, and the + * <code>EndpointPermission[endpoint,READ]</code> for an Endpoint, and the * Java Runtime Environment supports permissions, then returned collection - * will not contain a reference to the imported endpoint. + * will not contain a reference to the imported Endpoint. * * @return A <code>Collection</code> of {@link ImportReference}s that are * currently active. diff --git a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java index 0030b870c7..2941f8b117 100644 --- a/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java +++ b/sca-java-2.x/trunk/modules/node-impl-osgi/src/main/java/org/osgi/service/remoteserviceadmin/RemoteServiceAdminListener.java @@ -17,7 +17,7 @@ package org.osgi.service.remoteserviceadmin; /** - * A {@link RemoteServiceAdminEvent} listener is notified asynchronously of any + * A {@link RemoteServiceAdminEvent} listener is notified synchronously of any * export or import registrations and unregistrations. * * <p> @@ -36,7 +36,7 @@ package org.osgi.service.remoteserviceadmin; public interface RemoteServiceAdminListener { /** * Receive notification of any export or import registrations and - * unregistrations. + * unregistrations as well as errors and warnings. * * @param event The {@link RemoteServiceAdminEvent} object. */ |