private synchronized void checkIfConfigurationNeeded(ConfigurationAdmin service) {
        try {
            if (factory) {
                if (factoryConfiguration == null) {
                    factoryConfiguration = service.createFactoryConfiguration(pid, null);
                    factoryConfiguration.update(new Hashtable<String, Object>(properties));
                    LOG.info(
                        "Created new factory configuration for factory-pid {}, generated pid is {} with properties: {}",
                        new Object[] { pid, factoryConfiguration.getPid(), properties });
                }
            }
            else {
                Configuration configuration = service.getConfiguration(pid, null);
                Dictionary<String, Object> dictionary = configuration.getProperties();
                if (dictionary != null) {
                    boolean update = false;
                    Set<Entry<String, Object>> entrySet = properties.entrySet();
                    for (Entry<String, Object> entry : entrySet) {
                        Object object = dictionary.get(entry.getKey());
                        if (object == null) {
                            if (entry.getValue() == null) {
                                // Not changed...
                                continue;
                            }
                        }
                        else {
                            if (object.equals(entry.getValue())) {
                                // Not changed...
                                continue;
                            }
                        }
                        // A change is detected...
                        update = true;
                        dictionary.put(entry.getKey(), entry.getValue());
                    }
                    if (update) {
                        LOG.info("Update existing configuration for pid {} with properties: {}",
                            pid, dictToString(dictionary));
                        configuration.update(dictionary);
                    }
                }
                else {
                    if (create) {
                        configuration.update(new Hashtable<String, Object>(properties));
                        LOG.info("Created new configuration for pid {} with properties: {}", pid,
                            properties);
                    }
                }
            }
        }
        catch (IOException e) {
            LOG.warn("can't modify configuration for PID {}", pid, e);
        }
    }
private synchronized void checkIfConfigurationNeeded ( ConfigurationAdmin service ) { try { if ( factory ) { if ( factoryConfiguration == null ) { factoryConfiguration = service . createFactoryConfiguration ( pid , null ) ; factoryConfiguration . update ( new Hashtable < String , Object > ( properties ) ) ; LOG . info ( "Created new factory configuration for factory-pid {}, generated pid is {} with properties: {}" , new Object [ ] { pid , factoryConfiguration . getPid ( ) , properties } ) ; } } else { Configuration configuration = service . getConfiguration ( pid , null ) ; Dictionary < String , Object > dictionary = configuration . getProperties ( ) ; if ( dictionary != null ) { boolean update = false ; Set < Entry < String , Object > > entrySet = properties . entrySet ( ) ; for ( Entry < String , Object > entry : entrySet ) { Object object = dictionary . get ( entry . getKey ( ) ) ; if ( object == null ) { if ( entry . getValue ( ) == null ) { continue ; } } else { if ( object . equals ( entry . getValue ( ) ) ) { continue ; } } update = true ; dictionary . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } if ( update ) { LOG . info ( "Update existing configuration for pid {} with properties: {}" , pid , dictToString ( dictionary ) ) ; configuration . update ( dictionary ) ; } } else { if ( create ) { configuration . update ( new Hashtable < String , Object > ( properties ) ) ; LOG . info ( "Created new configuration for pid {} with properties: {}" , pid , properties ) ; } } } } catch ( IOException e ) { LOG . warn ( "can't modify configuration for PID {}" , pid , e ) ; } }
Check if an override of config values is needed for the given {@link ConfigurationAdmin}
service, since events can occur asycrounous we synchronized here to handle each event one by
one since this method might trigger other async events also...

@param service
the {@link ConfigurationAdmin} to check