Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkuppe2008-04-30 13:15:25 +0000
committermkuppe2008-04-30 13:15:25 +0000
commitf0b2fc5d47a4c18e3f5a38a577675b6d130af071 (patch)
treea8fd9a50ec4b21303b02e50f5afec51e6bdd055c /framework/bundles/org.eclipse.ecf.discovery
parentd9b30368485d9f428b92f785d55618d6fd9f010a (diff)
downloadorg.eclipse.ecf-f0b2fc5d47a4c18e3f5a38a577675b6d130af071.tar.gz
org.eclipse.ecf-f0b2fc5d47a4c18e3f5a38a577675b6d130af071.tar.xz
org.eclipse.ecf-f0b2fc5d47a4c18e3f5a38a577675b6d130af071.zip
FIXED - bug 228882: [Discovery][slp][provider] SLP not getting service properties
https://bugs.eclipse.org/bugs/show_bug.cgi?id=228882
Diffstat (limited to 'framework/bundles/org.eclipse.ecf.discovery')
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceProperties.java16
-rw-r--r--framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java67
2 files changed, 72 insertions, 11 deletions
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceProperties.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceProperties.java
index b44c83f55..ffa7450cd 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceProperties.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/IServiceProperties.java
@@ -9,8 +9,8 @@
package org.eclipse.ecf.discovery;
+import java.util.Dictionary;
import java.util.Enumeration;
-import java.util.Properties;
public interface IServiceProperties {
/**
@@ -97,7 +97,17 @@ public interface IServiceProperties {
public Object setProperty(String name, Object value);
/**
- * @return A copy of this {@link IServiceProperties} as a {@link Properties}
+ * @see Object#equals(Object)
*/
- public Properties asProperties();
+ public boolean equals(Object obj);
+
+ /**
+ * @see Object#hashCode()
+ */
+ public int hashCode();
+
+ /**
+ * @see Dictionary#size()
+ */
+ public int size();
}
diff --git a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java
index 6c365d241..7376f14b4 100644
--- a/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java
+++ b/framework/bundles/org.eclipse.ecf.discovery/src/org/eclipse/ecf/discovery/ServiceProperties.java
@@ -8,8 +8,7 @@
******************************************************************************/
package org.eclipse.ecf.discovery;
-import java.util.Enumeration;
-import java.util.Properties;
+import java.util.*;
/**
* Service properties implementation class for {@link IServiceProperties}. Subclasses
@@ -58,8 +57,9 @@ public class ServiceProperties implements IServiceProperties {
*/
public byte[] getPropertyBytes(String name) {
final Object val = props.get(name);
- if (val instanceof byte[]) {
- return (byte[]) val;
+ if (val instanceof ByteArrayWrapper) {
+ ByteArrayWrapper baw = (ByteArrayWrapper) val;
+ return baw.getByte();
}
return null;
}
@@ -84,7 +84,7 @@ public class ServiceProperties implements IServiceProperties {
* @see org.eclipse.ecf.discovery.IServiceProperties#setPropertyBytes(java.lang.String, byte[])
*/
public Object setPropertyBytes(String name, byte[] value) {
- return props.put(name, value);
+ return props.put(name, new ByteArrayWrapper(value));
}
/* (non-Javadoc)
@@ -95,9 +95,60 @@ public class ServiceProperties implements IServiceProperties {
}
/* (non-Javadoc)
- * @see org.eclipse.ecf.discovery.IServiceProperties#asProperties()
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof ServiceProperties) {
+ ServiceProperties sp = (ServiceProperties) obj;
+ return props.equals(sp.props);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
*/
- public Properties asProperties() {
- return new Properties(props);
+ public int hashCode() {
+ return props.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.discovery.IServiceProperties#size()
+ */
+ public int size() {
+ return props.size();
+ }
+
+ // proper equals/hashcode for byte[]
+ private class ByteArrayWrapper {
+
+ private final byte[] value;
+
+ public ByteArrayWrapper(byte[] value) {
+ this.value = value;
+ }
+
+ public byte[] getByte() {
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof ByteArrayWrapper) {
+ ByteArrayWrapper baw = (ByteArrayWrapper) obj;
+ return Arrays.equals(value, baw.value);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return value.hashCode();
+ }
+
}
}

Back to the top