You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2016/09/16 06:11:25 UTC
svn commit: r1760997 [2/2] - in /felix/trunk/configadmin: ./
src/main/java/org/apache/felix/cm/impl/ src/main/java/org/osgi/
src/main/java/org/osgi/service/ src/main/java/org/osgi/service/cm/
src/test/java/org/apache/felix/cm/ src/test/java/org/apache/...
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPermission.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPermission.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPermission.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPermission.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,631 @@
+/*
+ * Copyright (c) OSGi Alliance (2004, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.cm;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.security.BasicPermission;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Filter;
+
+/**
+ * Indicates a bundle's authority to configure bundles or be updated by
+ * Configuration Admin.
+ *
+ * @ThreadSafe
+ * @author $Id$
+ * @since 1.2
+ */
+
+public final class ConfigurationPermission extends BasicPermission {
+ static final long serialVersionUID = 5716868734811965383L;
+ /**
+ * Provides permission to create new configurations for other bundles as
+ * well as manipulate them. The action string {@value #CONFIGURE}.
+ */
+ public final static String CONFIGURE = "configure";
+
+ /**
+ * The permission to be updated, that is, act as a Managed Service or
+ * Managed Service Factory. The action string {@value #TARGET}.
+ *
+ * @since 1.4
+ */
+ public final static String TARGET = "target";
+
+ /**
+ * Provides permission to lock a configurations.
+ * The action string {@value #LOCK}.
+ *
+ * @since 1.6
+ */
+ public final static String LOCK = "lock";
+
+ private final static int ACTION_CONFIGURE = 0x00000001;
+ private final static int ACTION_TARGET = 0x00000002;
+ private final static int ACTION_ALL = ACTION_CONFIGURE | ACTION_TARGET;
+ final static int ACTION_NONE = 0;
+
+ /**
+ * The actions mask.
+ */
+ transient int action_mask;
+
+ /**
+ * The actions in canonical form.
+ *
+ * @serial
+ */
+ private volatile String actions = null;
+
+ /**
+ * Parsed name if it includes wildcards: "*"
+ */
+ private transient List<String> substrings;
+
+ /**
+ * Create a new ConfigurationPermission.
+ *
+ * @param name Name of the permission. Wildcards ({@code '*'}) are allowed
+ * in the name. During {@link #implies(Permission)}, the name is
+ * matched to the requested permission using the substring matching
+ * rules used by {@link Filter}s.
+ * @param actions Comma separated list of {@link #CONFIGURE},
+ * {@link #TARGET} (case insensitive).
+ */
+
+ public ConfigurationPermission(String name, String actions) {
+ this(name, parseActions(actions));
+ }
+
+ /**
+ * Package private constructor used by ConfigurationPermissionCollection.
+ *
+ * @param name location string
+ * @param mask action mask
+ */
+ ConfigurationPermission(String name, int mask) {
+ super(name);
+ setTransients(mask);
+ }
+
+ /**
+ * Called by constructors and when deserialized.
+ *
+ * @param mask action mask
+ */
+ private void setTransients(int mask) {
+ if ((mask == ACTION_NONE) || ((mask & ACTION_ALL) != mask)) {
+ throw new IllegalArgumentException("invalid action string");
+ }
+ action_mask = mask;
+ substrings = parseSubstring(getName());
+ }
+
+ /**
+ * Parse action string into action mask.
+ *
+ * @param actions Action string.
+ * @return action mask.
+ */
+ private static int parseActions(String actions) {
+ boolean seencomma = false;
+
+ int mask = ACTION_NONE;
+
+ if (actions == null) {
+ return mask;
+ }
+
+ char[] a = actions.toCharArray();
+
+ int i = a.length - 1;
+ if (i < 0)
+ return mask;
+
+ while (i != -1) {
+ char c;
+
+ // skip whitespace
+ while ((i != -1) && ((c = a[i]) == ' ' || c == '\r' || c == '\n' || c == '\f' || c == '\t'))
+ i--;
+
+ // check for the known strings
+ int matchlen;
+
+ if (i >= 5 && (a[i - 5] == 't' || a[i - 5] == 'T')
+ && (a[i - 4] == 'a' || a[i - 4] == 'A')
+ && (a[i - 3] == 'r' || a[i - 3] == 'R')
+ && (a[i - 2] == 'g' || a[i - 2] == 'G')
+ && (a[i - 1] == 'e' || a[i - 1] == 'E')
+ && (a[i] == 't' || a[i] == 'T')) {
+ matchlen = 6;
+ mask |= ACTION_TARGET;
+
+ } else
+ if (i >= 8 && (a[i - 8] == 'c' || a[i - 8] == 'C')
+ && (a[i - 7] == 'o' || a[i - 7] == 'O')
+ && (a[i - 6] == 'n' || a[i - 6] == 'N')
+ && (a[i - 5] == 'f' || a[i - 5] == 'F')
+ && (a[i - 4] == 'i' || a[i - 4] == 'I')
+ && (a[i - 3] == 'g' || a[i - 3] == 'G')
+ && (a[i - 2] == 'u' || a[i - 2] == 'U')
+ && (a[i - 1] == 'r' || a[i - 1] == 'R')
+ && (a[i] == 'e' || a[i] == 'E')) {
+ matchlen = 9;
+ mask |= ACTION_CONFIGURE;
+
+ } else {
+ // parse error
+ throw new IllegalArgumentException("invalid actions: " + actions);
+ }
+
+ // make sure we didn't just match the tail of a word
+ // like "ackbarftarget". Also, skip to the comma.
+ seencomma = false;
+ while (i >= matchlen && !seencomma) {
+ switch (a[i - matchlen]) {
+ case ',' :
+ seencomma = true;
+ /* FALLTHROUGH */
+ case ' ' :
+ case '\r' :
+ case '\n' :
+ case '\f' :
+ case '\t' :
+ break;
+ default :
+ throw new IllegalArgumentException("invalid permission: " + actions);
+ }
+ i--;
+ }
+
+ // point i at the location of the comma minus one (or -1).
+ i -= matchlen;
+ }
+
+ if (seencomma) {
+ throw new IllegalArgumentException("invalid actions: " + actions);
+ }
+
+ return mask;
+ }
+
+ /**
+ * Parse the name for wildcard processing.
+ *
+ * @param name The name of the permission.
+ * @return {@code null} is the name has no wildcards or a
+ * {@code List<String>} where element is a substring to match or
+ * null for {@code '*'}.
+ */
+ private static List<String> parseSubstring(String name) {
+ if (name.indexOf('*') < 0) {
+ return null;
+ }
+ char[] chars = name.toCharArray();
+ StringBuilder sb = new StringBuilder(chars.length);
+
+ List<String> sub = new ArrayList<String>(10);
+
+ for (int pos = 0; pos < chars.length; pos++) {
+ char c = chars[pos];
+
+ switch (c) {
+ case '*' : {
+ if (sb.length() > 0) {
+ sub.add(sb.toString());
+ }
+ sb.setLength(0);
+ sub.add(null);
+ break;
+ }
+
+ case '\\' : {
+ pos++;
+ if (pos < chars.length) {
+ c = chars[pos];
+ }
+ /* fall through into default */
+ }
+
+ default : {
+ sb.append(c);
+ break;
+ }
+ }
+ }
+ if (sb.length() > 0) {
+ sub.add(sb.toString());
+ }
+
+ int size = sub.size();
+
+ if (size == 0) {
+ return null;
+ }
+
+ if (size == 1) {
+ if (sub.get(0) != null) {
+ return null;
+ }
+ }
+ return sub;
+ }
+
+ /**
+ * Determines if a {@code ConfigurationPermission} object "implies" the
+ * specified permission.
+ *
+ * @param p The target permission to check.
+ * @return {@code true} if the specified permission is implied by this
+ * object; {@code false} otherwise.
+ */
+
+ @Override
+ public boolean implies(Permission p) {
+ if (!(p instanceof ConfigurationPermission)) {
+ return false;
+ }
+ ConfigurationPermission requested = (ConfigurationPermission) p;
+ return implies0(requested, ACTION_NONE);
+ }
+
+ /**
+ * Internal implies method. Used by the implies and the permission
+ * collection implies methods.
+ *
+ * @param requested The requested ConfigurationPermission which has already
+ * be validated as a proper argument.
+ * @param effective The effective actions with which to start.
+ * @return {@code true} if the specified permission is implied by this
+ * object; {@code false} otherwise.
+ */
+ boolean implies0(ConfigurationPermission requested, int effective) {
+ /* check actions first - much faster */
+ effective |= action_mask;
+ final int desired = requested.action_mask;
+ if ((effective & desired) != desired) {
+ return false;
+ }
+ String requestedName = requested.getName();
+ if (substrings == null) {
+ return getName().equals(requestedName);
+ }
+ for (int i = 0, pos = 0, size = substrings.size(); i < size; i++) {
+ String substr = substrings.get(i);
+
+ if (i + 1 < size) /* if this is not that last substr */{
+ if (substr == null) /* * */{
+ String substr2 = substrings.get(i + 1);
+
+ if (substr2 == null) /* ** */
+ continue; /* ignore first star */
+ /* xxx */
+ int index = requestedName.indexOf(substr2, pos);
+ if (index == -1) {
+ return false;
+ }
+
+ pos = index + substr2.length();
+ if (i + 2 < size) // if there are more
+ // substrings, increment
+ // over the string we just
+ // matched; otherwise need
+ // to do the last substr
+ // check
+ i++;
+ } else /* xxx */{
+ int len = substr.length();
+ if (requestedName.regionMatches(pos, substr, 0, len)) {
+ pos += len;
+ } else {
+ return false;
+ }
+ }
+ } else /* last substr */{
+ if (substr == null) /* * */{
+ return true;
+ }
+ /* xxx */
+ return requestedName.endsWith(substr);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Determines the equality of two {@code ConfigurationPermission} objects.
+ * <p>
+ * Two {@code ConfigurationPermission} objects are equal.
+ *
+ * @param obj The object being compared for equality with this object.
+ * @return {@code true} if {@code obj} is equivalent to this
+ * {@code ConfigurationPermission}; {@code false} otherwise.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+
+ if (!(obj instanceof ConfigurationPermission)) {
+ return false;
+ }
+
+ ConfigurationPermission cp = (ConfigurationPermission) obj;
+
+ return (action_mask == cp.action_mask) && getName().equals(cp.getName());
+ }
+
+ /**
+ * Returns the hash code value for this object.
+ *
+ * @return Hash code value for this object.
+ */
+
+ @Override
+ public int hashCode() {
+ int h = 31 * 17 + getName().hashCode();
+ h = 31 * h + getActions().hashCode();
+ return h;
+ }
+
+ /**
+ * Returns the canonical string representation of the
+ * {@code ConfigurationPermission} actions.
+ *
+ * <p>
+ * Always returns present {@code ConfigurationPermission} actions in the
+ * following order: {@value #CONFIGURE}, {@value #TARGET}
+ *
+ * @return Canonical string representation of the
+ * {@code ConfigurationPermission} actions.
+ */
+ @Override
+ public String getActions() {
+ String result = actions;
+ if (result == null) {
+ StringBuilder sb = new StringBuilder();
+ boolean comma = false;
+
+ int mask = action_mask;
+ if ((mask & ACTION_CONFIGURE) == ACTION_CONFIGURE) {
+ sb.append(CONFIGURE);
+ comma = true;
+ }
+
+ if ((mask & ACTION_TARGET) == ACTION_TARGET) {
+ if (comma)
+ sb.append(',');
+ sb.append(TARGET);
+ }
+
+ actions = result = sb.toString();
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns a new {@code PermissionCollection} object suitable for storing
+ * {@code ConfigurationPermission}s.
+ *
+ * @return A new {@code PermissionCollection} object.
+ */
+ @Override
+ public PermissionCollection newPermissionCollection() {
+ return new ConfigurationPermissionCollection();
+ }
+
+ /**
+ * WriteObject is called to save the state of this permission object to a
+ * stream. The actions are serialized, and the superclass takes care of the
+ * name.
+ */
+ private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException {
+ // Write out the actions. The superclass takes care of the name
+ // call getActions to make sure actions field is initialized
+ if (actions == null)
+ getActions();
+ s.defaultWriteObject();
+ }
+
+ /**
+ * readObject is called to restore the state of this permission from a
+ * stream.
+ */
+ private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
+ // Read in the data, then initialize the transients
+ s.defaultReadObject();
+ setTransients(parseActions(actions));
+ }
+}
+
+/**
+ * Stores a set of {@code ConfigurationPermission} permissions.
+ *
+ * @see java.security.Permission
+ * @see java.security.Permissions
+ * @see java.security.PermissionCollection
+ */
+final class ConfigurationPermissionCollection extends PermissionCollection {
+ static final long serialVersionUID = -6917638867081695839L;
+ /**
+ * Collection of permissions.
+ *
+ * @serial
+ * @GuardedBy this
+ */
+ private Map<String, ConfigurationPermission> permissions;
+
+ /**
+ * Boolean saying if "*" is in the collection.
+ *
+ * @serial
+ * @GuardedBy this
+ */
+ private boolean all_allowed;
+
+ /**
+ * Creates an empty {@code ConfigurationPermissionCollection} object.
+ *
+ */
+ public ConfigurationPermissionCollection() {
+ permissions = new HashMap<String, ConfigurationPermission>();
+ all_allowed = false;
+ }
+
+ /**
+ * Adds the specified permission to the
+ * {@code ConfigurationPermissionCollection}. The key for the hash is the
+ * interface name of the service.
+ *
+ * @param permission The {@code Permission} object to add.
+ *
+ * @exception IllegalArgumentException If the permission is not an
+ * {@code ConfigurationPermission}.
+ *
+ * @exception SecurityException If this ConfigurationPermissionCollection
+ * object has been marked read-only.
+ */
+
+ @Override
+ public void add(Permission permission) {
+ if (!(permission instanceof ConfigurationPermission)) {
+ throw new IllegalArgumentException("invalid permission: " + permission);
+ }
+
+ if (isReadOnly())
+ throw new SecurityException("attempt to add a Permission to a " + "readonly PermissionCollection");
+
+ final ConfigurationPermission cp = (ConfigurationPermission) permission;
+ final String name = cp.getName();
+ synchronized (this) {
+ Map<String, ConfigurationPermission> pc = permissions;
+ final ConfigurationPermission existing = pc.get(name);
+ if (existing != null) {
+ final int oldMask = existing.action_mask;
+ final int newMask = cp.action_mask;
+ if (oldMask != newMask) {
+ pc.put(name, new ConfigurationPermission(name, oldMask | newMask));
+ }
+ } else {
+ pc.put(name, cp);
+ }
+
+ if (!all_allowed) {
+ if (name.equals("*")) {
+ all_allowed = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * Determines if the specified permissions implies the permissions expressed
+ * in {@code permission}.
+ *
+ * @param permission The Permission object to compare with this
+ * {@code ConfigurationPermission} object.
+ * @return {@code true} if {@code permission} is a proper subset of a
+ * permission in the set; {@code false} otherwise.
+ */
+ @Override
+ public boolean implies(Permission permission) {
+ if (!(permission instanceof ConfigurationPermission)) {
+ return false;
+ }
+ final ConfigurationPermission requested = (ConfigurationPermission) permission;
+ int effective = ConfigurationPermission.ACTION_NONE;
+
+ Collection<ConfigurationPermission> perms;
+ synchronized (this) {
+ Map<String, ConfigurationPermission> pc = permissions;
+ /* short circuit if the "*" Permission was added */
+ if (all_allowed) {
+ ConfigurationPermission cp = pc.get("*");
+ if (cp != null) {
+ effective |= cp.action_mask;
+ final int desired = requested.action_mask;
+ if ((effective & desired) == desired) {
+ return true;
+ }
+ }
+ }
+ perms = pc.values();
+ }
+ /* iterate one by one over permissions */
+ for (ConfigurationPermission perm : perms) {
+ if (perm.implies0(requested, effective)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns an enumeration of all {@code ConfigurationPermission} objects in
+ * the container.
+ *
+ * @return Enumeration of all {@code ConfigurationPermission} objects.
+ */
+ @Override
+ public synchronized Enumeration<Permission> elements() {
+ List<Permission> all = new ArrayList<Permission>(permissions.values());
+ return Collections.enumeration(all);
+ }
+
+ /* serialization logic */
+ private static final ObjectStreamField[] serialPersistentFields = {new ObjectStreamField("hasElement", Boolean.TYPE), new ObjectStreamField("permissions", HashMap.class),
+ new ObjectStreamField("all_allowed", Boolean.TYPE) };
+
+ private synchronized void writeObject(ObjectOutputStream out) throws IOException {
+ ObjectOutputStream.PutField pfields = out.putFields();
+ pfields.put("hasElement", false);
+ pfields.put("permissions", permissions);
+ pfields.put("all_allowed", all_allowed);
+ out.writeFields();
+ }
+
+ private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gfields = in.readFields();
+ boolean hasElement = gfields.get("hasElement", false);
+ if (hasElement) { // old format
+ permissions = new HashMap<String, ConfigurationPermission>();
+ permissions.put("*", new ConfigurationPermission("*", ConfigurationPermission.CONFIGURE));
+ all_allowed = true;
+ } else {
+ @SuppressWarnings("unchecked")
+ HashMap<String, ConfigurationPermission> p = (HashMap<String, ConfigurationPermission>) gfields.get("permissions", new HashMap<String, ConfigurationPermission>());
+ permissions = p;
+ all_allowed = gfields.get("all_allowed", false);
+ }
+ }
+}
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPermission.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPermission.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPlugin.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPlugin.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPlugin.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) OSGi Alliance (2001, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.cm;
+
+import java.util.Dictionary;
+
+import org.osgi.annotation.versioning.ConsumerType;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A service interface for processing configuration dictionary before the
+ * update.
+ *
+ * <p>
+ * A bundle registers a {@code ConfigurationPlugin} object in order to process
+ * configuration updates before they reach the Managed Service or Managed
+ * Service Factory. The Configuration Admin service will detect registrations of
+ * Configuration Plugin services and must call these services every time before
+ * it calls the {@code ManagedService} or {@code ManagedServiceFactory}
+ * {@code updated} method. The Configuration Plugin service thus has the
+ * opportunity to view and modify the properties before they are passed to the
+ * Managed Service or Managed Service Factory.
+ *
+ * <p>
+ * Configuration Plugin (plugin) services have full read/write access to all
+ * configuration information that passes through them.
+ *
+ * <p>
+ * The {@code Integer} {@code service.cmRanking} registration property may be
+ * specified. Not specifying this registration property, or setting it to
+ * something other than an {@code Integer}, is the same as setting it to the
+ * {@code Integer} zero. The {@code service.cmRanking} property determines the
+ * order in which plugins are invoked. Lower ranked plugins are called before
+ * higher ranked ones. In the event of more than one plugin having the same
+ * value of {@code service.cmRanking}, then the Configuration Admin service
+ * arbitrarily chooses the order in which they are called.
+ *
+ * <p>
+ * By convention, plugins with {@code service.cmRanking < 0} or
+ * {@code service.cmRanking > 1000} should not make modifications to the
+ * properties.
+ *
+ * <p>
+ * The Configuration Admin service has the right to hide properties from
+ * plugins, or to ignore some or all the changes that they make. This might be
+ * done for security reasons. Any such behavior is entirely implementation
+ * defined.
+ *
+ * <p>
+ * A plugin may optionally specify a {@code cm.target} registration property
+ * whose value is the PID of the Managed Service or Managed Service Factory
+ * whose configuration updates the plugin is intended to intercept. The plugin
+ * will then only be called with configuration updates that are targeted at the
+ * Managed Service or Managed Service Factory with the specified PID. Omitting
+ * the {@code cm.target} registration property means that the plugin is called
+ * for all configuration updates.
+ *
+ * @author $Id$
+ * @ThreadSafe
+ */
+@ConsumerType
+public interface ConfigurationPlugin {
+ /**
+ * A service property to limit the Managed Service or Managed Service
+ * Factory configuration dictionaries a Configuration Plugin service
+ * receives.
+ *
+ * This property contains a {@code String[]} of PIDs. A Configuration Admin
+ * service must call a Configuration Plugin service only when this property
+ * is not set, or the target service's PID is listed in this property.
+ */
+ public static final String CM_TARGET = "cm.target";
+ /**
+ * A service property to specify the order in which plugins are invoked.
+ *
+ * This property contains an {@code Integer} ranking of the plugin. Not
+ * specifying this registration property, or setting it to something other
+ * than an {@code Integer}, is the same as setting it to the {@code Integer}
+ * zero. This property determines the order in which plugins are invoked.
+ * Lower ranked plugins are called before higher ranked ones.
+ *
+ * @since 1.2
+ */
+ public static final String CM_RANKING = "service.cmRanking";
+
+ /**
+ * View and possibly modify the a set of configuration properties before
+ * they are sent to the Managed Service or the Managed Service Factory. The
+ * Configuration Plugin services are called in increasing order of their
+ * {@code service.cmRanking} property. If this property is undefined or is a
+ * non- {@code Integer} type, 0 is used.
+ *
+ * <p>
+ * This method should not modify the properties unless the
+ * {@code service.cmRanking} of this plugin is in the range
+ * {@code 0 <= service.cmRanking <= 1000}.
+ * <p>
+ * If this method throws any {@code Exception}, the Configuration Admin
+ * service must catch it and should log it.
+ *
+ * <p>
+ * A Configuration Plugin will only be called for properties from
+ * configurations that have a location for which the Configuration Plugin
+ * has permission when security is active. When security is not active, no
+ * filtering is done.
+ *
+ * @param reference reference to the Managed Service or Managed Service
+ * Factory
+ * @param properties The configuration properties. This argument must not
+ * contain the "service.bundleLocation" property. The value of this
+ * property may be obtained from the
+ * {@code Configuration.getBundleLocation} method.
+ */
+ public void modifyConfiguration(ServiceReference<?> reference, Dictionary<String, Object> properties);
+}
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPlugin.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ConfigurationPlugin.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/LockedConfigurationException.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/LockedConfigurationException.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/LockedConfigurationException.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/LockedConfigurationException.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) OSGi Alliance (2001, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.cm;
+
+import java.io.IOException;
+
+/**
+ * An {@code Exception} class to inform the client of a {@code Configuration}
+ * about the locked state of a configuration object.
+ *
+ * @author $Id$
+ * @since 1.6
+ */
+public class LockedConfigurationException extends IOException {
+ static final long serialVersionUID = 1898442024230518832L;
+
+ /**
+ * Create a {@code LockedConfigurationException} object.
+ *
+ * @param reason reason for failure
+ */
+ public LockedConfigurationException(String reason) {
+ super(reason);
+ }
+}
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/LockedConfigurationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/LockedConfigurationException.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedService.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedService.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedService.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedService.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) OSGi Alliance (2001, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.cm;
+
+import java.util.Dictionary;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * A service that can receive configuration data from a Configuration Admin
+ * service.
+ *
+ * <p>
+ * A Managed Service is a service that needs configuration data. Such an object
+ * should be registered with the Framework registry with the {@code service.pid}
+ * property set to some unique identifier called a PID.
+ *
+ * <p>
+ * If the Configuration Admin service has a {@code Configuration} object
+ * corresponding to this PID, it will callback the {@code updated()} method of
+ * the {@code ManagedService} object, passing the properties of that
+ * {@code Configuration} object.
+ *
+ * <p>
+ * If it has no such {@code Configuration} object, then it calls back with a
+ * {@code null} properties argument. Registering a Managed Service will always
+ * result in a callback to the {@code updated()} method provided the
+ * Configuration Admin service is, or becomes active. This callback must always
+ * be done asynchronously.
+ *
+ * <p>
+ * Else, every time that either of the {@code updated()} methods is called on
+ * that {@code Configuration} object, the {@code ManagedService.updated()}
+ * method with the new properties is called. If the {@code delete()} method is
+ * called on that {@code Configuration} object, {@code ManagedService.updated()}
+ * is called with a {@code null} for the properties parameter. All these
+ * callbacks must be done asynchronously.
+ *
+ * <p>
+ * The following example shows the code of a serial port that will create a port
+ * depending on configuration information.
+ *
+ * <pre>
+ *
+ * class SerialPort implements ManagedService {
+ *
+ * ServiceRegistration registration;
+ * Hashtable configuration;
+ * CommPortIdentifier id;
+ *
+ * synchronized void open(CommPortIdentifier id,
+ * BundleContext context) {
+ * this.id = id;
+ * registration = context.registerService(
+ * ManagedService.class.getName(),
+ * this,
+ * getDefaults()
+ * );
+ * }
+ *
+ * Hashtable getDefaults() {
+ * Hashtable defaults = new Hashtable();
+ * defaults.put( "port", id.getName() );
+ * defaults.put( "product", "unknown" );
+ * defaults.put( "baud", "9600" );
+ * defaults.put( Constants.SERVICE_PID,
+ * "com.acme.serialport." + id.getName() );
+ * return defaults;
+ * }
+ *
+ * public synchronized void updated(
+ * Dictionary configuration ) {
+ * if ( configuration == null )
+ * registration.setProperties( getDefaults() );
+ * else {
+ * setSpeed( configuration.get("baud") );
+ * registration.setProperties( configuration );
+ * }
+ * }
+ * ...
+ * }
+ *
+ * </pre>
+ *
+ * <p>
+ * As a convention, it is recommended that when a Managed Service is updated, it
+ * should copy all the properties it does not recognize into the service
+ * registration properties. This will allow the Configuration Admin service to
+ * set properties on services which can then be used by other applications.
+ *
+ * <p>
+ * Normally, a single Managed Service for a given PID is given the configuration
+ * dictionary, this is the configuration that is bound to the location of the
+ * registering bundle. However, when security is on, a Managed Service can have
+ * Configuration Permission to also be updated for other locations.
+ *
+ * @author $Id$
+ * @ThreadSafe
+ */
+@ConsumerType
+public interface ManagedService {
+ /**
+ * Update the configuration for a Managed Service.
+ *
+ * <p>
+ * When the implementation of {@code updated(Dictionary)} detects any kind
+ * of error in the configuration properties, it should create a new
+ * {@code ConfigurationException} which describes the problem. This can
+ * allow a management system to provide useful information to a human
+ * administrator.
+ *
+ * <p>
+ * If this method throws any other {@code Exception}, the Configuration
+ * Admin service must catch it and should log it.
+ * <p>
+ * The Configuration Admin service must call this method asynchronously with
+ * the method that initiated the callback. This implies that implementors of
+ * Managed Service can be assured that the callback will not take place
+ * during registration when they execute the registration in a synchronized
+ * method.
+ *
+ * <p>
+ * If the location allows multiple managed services to be called back for a
+ * single configuration then the callbacks must occur in service ranking
+ * order. Changes in the location must be reflected by deleting the
+ * configuration if the configuration is no longer visible and updating when
+ * it becomes visible.
+ *
+ * <p>
+ * If no configuration exists for the corresponding PID, or the bundle has
+ * no access to the configuration, then the bundle must be called back with
+ * a {@code null} to signal that CM is active but there is no data.
+ *
+ * @param properties A copy of the Configuration properties, or {@code null}
+ * . This argument must not contain the "service.bundleLocation"
+ * property. The value of this property may be obtained from the
+ * {@code Configuration.getBundleLocation} method.
+ * @throws ConfigurationException when the update fails
+ * @security ConfigurationPermission[c.location,TARGET] Required by the
+ * bundle that registered this service
+ */
+ public void updated(Dictionary<String, ?> properties) throws ConfigurationException;
+}
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedService.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedServiceFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedServiceFactory.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedServiceFactory.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedServiceFactory.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) OSGi Alliance (2001, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.cm;
+
+import java.util.Dictionary;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * Manage multiple service instances.
+ *
+ * Bundles registering this interface are giving the Configuration Admin service
+ * the ability to create and configure a number of instances of a service that
+ * the implementing bundle can provide. For example, a bundle implementing a
+ * DHCP server could be instantiated multiple times for different interfaces
+ * using a factory.
+ *
+ * <p>
+ * Each of these <i>service instances </i> is represented, in the persistent
+ * storage of the Configuration Admin service, by a factory
+ * {@code Configuration} object that has a PID. When such a
+ * {@code Configuration} is updated, the Configuration Admin service calls the
+ * {@code ManagedServiceFactory} updated method with the new properties. When
+ * {@code updated} is called with a new PID, the Managed Service Factory should
+ * create a new factory instance based on these configuration properties. When
+ * called with a PID that it has seen before, it should update that existing
+ * service instance with the new configuration information.
+ *
+ * <p>
+ * In general it is expected that the implementation of this interface will
+ * maintain a data structure that maps PIDs to the factory instances that it has
+ * created. The semantics of a factory instance are defined by the Managed
+ * Service Factory. However, if the factory instance is registered as a service
+ * object with the service registry, its PID should match the PID of the
+ * corresponding {@code Configuration} object (but it should <b>not </b> be
+ * registered as a Managed Service!).
+ *
+ * <p>
+ * An example that demonstrates the use of a factory. It will create serial
+ * ports under command of the Configuration Admin service.
+ *
+ * <pre>
+ *
+ * class SerialPortFactory
+ * implements ManagedServiceFactory {
+ * ServiceRegistration registration;
+ * Hashtable ports;
+ * void start(BundleContext context) {
+ * Hashtable properties = new Hashtable();
+ * properties.put( Constants.SERVICE_PID,
+ * "com.acme.serialportfactory" );
+ * registration = context.registerService(
+ * ManagedServiceFactory.class.getName(),
+ * this,
+ * properties
+ * );
+ * }
+ * public void updated( String pid,
+ * Dictionary properties ) {
+ * String portName = (String) properties.get("port");
+ * SerialPortService port =
+ * (SerialPort) ports.get( pid );
+ * if ( port == null ) {
+ * port = new SerialPortService();
+ * ports.put( pid, port );
+ * port.open();
+ * }
+ * if ( port.getPortName().equals(portName) )
+ * return;
+ * port.setPortName( portName );
+ * }
+ * public void deleted( String pid ) {
+ * SerialPortService port =
+ * (SerialPort) ports.get( pid );
+ * port.close();
+ * ports.remove( pid );
+ * }
+ * ...
+ * }
+ *
+ * </pre>
+ *
+ * @author $Id$
+ * @ThreadSafe
+ */
+@ConsumerType
+public interface ManagedServiceFactory {
+ /**
+ * Return a descriptive name of this factory.
+ *
+ * @return the name for the factory, which might be localized
+ */
+ public String getName();
+
+ /**
+ * Create a new instance, or update the configuration of an existing
+ * instance.
+ *
+ * If the PID of the {@code Configuration} object is new for the Managed
+ * Service Factory, then create a new factory instance, using the
+ * configuration {@code properties} provided. Else, update the service
+ * instance with the provided {@code properties}.
+ *
+ * <p>
+ * If the factory instance is registered with the Framework, then the
+ * configuration {@code properties} should be copied to its registry
+ * properties. This is not mandatory and security sensitive properties
+ * should obviously not be copied.
+ *
+ * <p>
+ * If this method throws any {@code Exception}, the Configuration Admin
+ * service must catch it and should log it.
+ *
+ * <p>
+ * When the implementation of updated detects any kind of error in the
+ * configuration properties, it should create a new
+ * {@link ConfigurationException} which describes the problem.
+ *
+ * <p>
+ * The Configuration Admin service must call this method asynchronously.
+ * This implies that implementors of the {@code ManagedServiceFactory} class
+ * can be assured that the callback will not take place during registration
+ * when they execute the registration in a synchronized method.
+ *
+ * <p>
+ * If the security allows multiple managed service factories to be called
+ * back for a single configuration then the callbacks must occur in service
+ * ranking order.
+ *
+ * <p>
+ * It is valid to create multiple factory instances that are bound to
+ * different locations. Managed Service Factory services must only be
+ * updated with configurations that are bound to their location or that
+ * start with the {@code ?} prefix and for which they have permission.
+ * Changes in the location must be reflected by deleting the corresponding
+ * configuration if the configuration is no longer visible or updating when
+ * it becomes visible.
+ *
+ * @param pid The PID for this configuration.
+ * @param properties A copy of the configuration properties. This argument
+ * must not contain the service.bundleLocation" property. The value
+ * of this property may be obtained from the
+ * {@code Configuration.getBundleLocation} method.
+ * @throws ConfigurationException when the configuration properties are
+ * invalid.
+ * @security ConfigurationPermission[c.location,TARGET] Required by the
+ * bundle that registered this service
+ */
+ public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException;
+
+ /**
+ * Remove a factory instance.
+ *
+ * Remove the factory instance associated with the PID. If the instance was
+ * registered with the service registry, it should be unregistered. The
+ * Configuration Admin must call deleted for each instance it received in
+ * {@link #updated(String, Dictionary)}.
+ *
+ * <p>
+ * If this method throws any {@code Exception}, the Configuration Admin
+ * service must catch it and should log it.
+ * <p>
+ * The Configuration Admin service must call this method asynchronously.
+ *
+ * @param pid the PID of the service to be removed
+ */
+ public void deleted(String pid);
+}
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedServiceFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/ManagedServiceFactory.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/SynchronousConfigurationListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/SynchronousConfigurationListener.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/SynchronousConfigurationListener.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/SynchronousConfigurationListener.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) OSGi Alliance (2012, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.osgi.service.cm;
+
+import org.osgi.annotation.versioning.ConsumerType;
+
+/**
+ * Synchronous Listener for Configuration Events. When a
+ * {@code ConfigurationEvent} is fired, it is synchronously delivered to all
+ * {@code SynchronousConfigurationListener}s.
+ *
+ * <p>
+ * {@code SynchronousConfigurationListener} objects are registered with the
+ * Framework service registry and are synchronously notified with a
+ * {@code ConfigurationEvent} object when an event is fired.
+ * <p>
+ * {@code SynchronousConfigurationListener} objects can inspect the received
+ * {@code ConfigurationEvent} object to determine its type, the PID of the
+ * {@code Configuration} object with which it is associated, and the
+ * Configuration Admin service that fired the event.
+ *
+ * <p>
+ * Security Considerations. Bundles wishing to synchronously monitor
+ * configuration events will require
+ * {@code ServicePermission[SynchronousConfigurationListener,REGISTER]} to
+ * register a {@code SynchronousConfigurationListener} service.
+ *
+ * @author $Id$
+ * @since 1.5
+ * @ThreadSafe
+ */
+@ConsumerType
+public interface SynchronousConfigurationListener extends ConfigurationListener {
+ // Marker interface
+}
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/SynchronousConfigurationListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/SynchronousConfigurationListener.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Added: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/main/java/org/osgi/service/cm/package-info.java?rev=1760997&view=auto
==============================================================================
--- felix/trunk/configadmin/src/main/java/org/osgi/service/cm/package-info.java (added)
+++ felix/trunk/configadmin/src/main/java/org/osgi/service/cm/package-info.java Fri Sep 16 06:11:25 2016
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) OSGi Alliance (2010, 2016). All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Configuration Admin Package Version 1.6.
+ *
+ * <p>
+ * Bundles wishing to use this package must list the package in the
+ * Import-Package header of the bundle's manifest. This package has two types of
+ * users: the consumers that use the API in this package and the providers that
+ * implement the API in this package.
+ *
+ * <p>
+ * Example import for consumers using the API in this package:
+ * <p>
+ * {@code Import-Package: org.osgi.service.cm; version="[1.6,2.0)"}
+ * <p>
+ * Example import for providers implementing the API in this package:
+ * <p>
+ * {@code Import-Package: org.osgi.service.cm; version="[1.6,1.7)"}
+ *
+ * @author $Id$
+ */
+
+@Version("1.6")
+package org.osgi.service.cm;
+
+import org.osgi.annotation.versioning.Version;
+
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/configadmin/src/main/java/org/osgi/service/cm/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundleContext.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundleContext.java?rev=1760997&r1=1760996&r2=1760997&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundleContext.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/MockBundleContext.java Fri Sep 16 06:11:25 2016
@@ -30,7 +30,9 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleListener;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceObjects;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -321,4 +323,17 @@ public class MockBundleContext implement
{
return null;
}
+
+
+ public <S> ServiceRegistration<S> registerService(Class<S> clazz, ServiceFactory<S> factory,
+ Dictionary<String, ?> properties)
+ {
+ return null;
+ }
+
+
+ public <S> ServiceObjects<S> getServiceObjects(ServiceReference<S> reference)
+ {
+ return null;
+ }
}
Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java?rev=1760997&r1=1760996&r2=1760997&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/ConfigurationManagerTest.java Fri Sep 16 06:11:25 2016
@@ -214,6 +214,7 @@ public class ConfigurationManagerTest ex
SynchronousConfigurationListener syncListener1 = new SynchronousConfigurationListener()
{
+ @Override
public void configurationEvent(ConfigurationEvent event)
{
result.add("L1");
@@ -221,6 +222,7 @@ public class ConfigurationManagerTest ex
};
SynchronousConfigurationListener syncListener2 = new SynchronousConfigurationListener()
{
+ @Override
public void configurationEvent(ConfigurationEvent event)
{
result.add("L2");
@@ -228,6 +230,7 @@ public class ConfigurationManagerTest ex
};
SynchronousConfigurationListener syncListener3 = new SynchronousConfigurationListener()
{
+ @Override
public void configurationEvent(ConfigurationEvent event)
{
result.add("L3");
@@ -272,7 +275,7 @@ public class ConfigurationManagerTest ex
utField.setAccessible( true );
utField.set( configMgr, new UpdateThread( configMgr, null, "Test updater" ));
- Dictionary<String, String> props = new Hashtable<String, String>();
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put( Constants.SERVICE_PID, "org.acme.testpid" );
ConfigurationImpl config = new ConfigurationImpl( configMgr, new MockPersistenceManager(), props );
configMgr.updated( config, true );
Modified: felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java?rev=1760997&r1=1760996&r2=1760997&view=diff
==============================================================================
--- felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java (original)
+++ felix/trunk/configadmin/src/test/java/org/apache/felix/cm/impl/RankingComparatorTest.java Fri Sep 16 06:11:25 2016
@@ -222,36 +222,42 @@ public class RankingComparatorTest exten
}
+ @Override
public Object getProperty( String key )
{
return props.get( key );
}
+ @Override
public String[] getPropertyKeys()
{
return props.keySet().toArray( new String[props.size()] );
}
+ @Override
public Bundle getBundle()
{
return null;
}
+ @Override
public Bundle[] getUsingBundles()
{
return null;
}
+ @Override
public boolean isAssignableTo( Bundle bundle, String className )
{
return false;
}
+ @Override
public int compareTo( Object reference )
{
return 0;