Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java')
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java
new file mode 100644
index 000000000..d71c606fb
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/util/ServiceReferenceMap.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Raymond Augé 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:
+ * Raymond Augé <raymond.auge@liferay.com> - Bug 436698
+ ******************************************************************************/
+
+package org.eclipse.equinox.http.servlet.internal.util;
+
+import java.util.*;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * @author Raymond Augé
+ */
+public class ServiceReferenceMap extends AbstractMap<String, Object> {
+
+ public ServiceReferenceMap(ServiceReference<?> serviceReference) {
+ String[] propertyKeys = serviceReference.getPropertyKeys();
+
+ entries = new HashSet<Map.Entry<String,Object>>(propertyKeys.length);
+
+ for (String key : propertyKeys) {
+ Map.Entry<String,Object> entry = new ReferenceEntry(
+ key, serviceReference.getProperty(key));
+
+ entries.add(entry);
+ }
+ }
+
+ @Override
+ public Set<java.util.Map.Entry<String, Object>> entrySet() {
+ return entries;
+ }
+
+ private Set<java.util.Map.Entry<String, Object>> entries;
+
+ private class ReferenceEntry implements Map.Entry<String, Object> {
+
+ ReferenceEntry(String key, Object value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public Object setValue(Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getValue() {
+ return value;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ private String key;
+ private Object value;
+
+ }
+
+} \ No newline at end of file

Back to the top