Github user bostko commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/492#discussion_r93605416
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/persist/DeserializingClassRenamesProvider.java
 ---
    @@ -20,65 +20,217 @@
     
     import java.io.IOException;
     import java.io.InputStream;
    +import java.util.Dictionary;
     import java.util.Enumeration;
    +import java.util.List;
     import java.util.Map;
     import java.util.Properties;
     
    +import org.apache.brooklyn.util.collections.MutableMap;
     import org.apache.brooklyn.util.core.ResourceUtils;
     import org.apache.brooklyn.util.exceptions.Exceptions;
     import org.apache.brooklyn.util.javalang.Reflections;
     import org.apache.brooklyn.util.stream.Streams;
    +import org.osgi.framework.Constants;
    +import org.osgi.framework.InvalidSyntaxException;
    +import org.osgi.service.cm.Configuration;
    +import org.osgi.service.cm.ConfigurationAdmin;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
     
     import com.google.common.annotations.Beta;
    +import com.google.common.collect.ImmutableList;
     import com.google.common.collect.ImmutableMap;
    +import com.google.common.collect.Lists;
     import com.google.common.collect.Maps;
     
     @Beta
     public class DeserializingClassRenamesProvider {
     
    +    /*
    +     * This provider keeps a cache of the class-renames, which is lazily 
populated (see {@link #cache}. 
    +     * Calling {@link #reset()} will set this cache to null, causing it to 
be reloaded next time 
    +     * it is requested.
    +     * 
    +     * Loading the cache involves iterating over the {@link #loaders}, 
returning the union of 
    +     * the results from {@link Loader#load()}.
    +     * 
    +     * Initially, the only loader is the basic {@link 
ClasspathConfigLoader}.
    +     * 
    +     * However, when running in karaf the {@link OsgiConfigLoader} will be 
instantiated and added.
    +     * See karaf/init/src/main/resources/OSGI-INF/blueprint/blueprint.xml
    +     */
    +    
    +    private static final Logger LOG = 
LoggerFactory.getLogger(DeserializingClassRenamesProvider.class);
    +    private static final List<String> EXCLUDED_KEYS = 
ImmutableList.of("service.pid", "felix.fileinstall.filename");
    +
         public static final String DESERIALIZING_CLASS_RENAMES_PROPERTIES_PATH 
= 
"classpath://org/apache/brooklyn/core/mgmt/persist/deserializingClassRenames.properties";
    +    public static final String 
KARAF_DESERIALIZING_CLASS_RENAMES_PROPERTIES = 
"org.apache.brooklyn.classrename";
    +
    +    private static final List<Loader> loaders = 
Lists.newCopyOnWriteArrayList();
    +    static {
    +        loaders.add(new ClasspathConfigLoader());
    +    }
         
         private static volatile Map<String, String> cache;
    -    
    +
         @Beta
         public static Map<String, String> loadDeserializingClassRenames() {
    -        // Double-checked locking - got to use volatile or some such!
    -        if (cache == null) {
    -            synchronized (DeserializingClassRenamesProvider.class) {
    -                if (cache == null) {
    -                    cache = loadDeserializingClassRenamesCache();
    +        synchronized (DeserializingClassRenamesProvider.class) {
    +            if (cache == null) {
    +                ImmutableMap.Builder<String, String> builder = 
ImmutableMap.<String, String>builder();
    +                for (Loader loader : loaders) {
    +                    builder.putAll(loader.load());
    --- End diff --
    
    I am not sure whether the case is the same, but still I do not see a 
guarantee for uniqueness of loaders loaded items.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to