org.osgi.service.cm.Configuration.update()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(76)

本文整理了Java中org.osgi.service.cm.Configuration.update()方法的一些代码示例,展示了Configuration.update()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.update()方法的具体详情如下:
包路径:org.osgi.service.cm.Configuration
类名称:Configuration
方法名:update

Configuration.update介绍

[英]Update the Configuration object with the current properties. Initiate the updated callback to the Managed Service or Managed Service Factory with the current properties asynchronously.

This is the only way for a bundle that uses a Configuration Plugin service to initiate a callback. For example, when that bundle detects a change that requires an update of the Managed Service or Managed Service Factory via its ConfigurationPlugin object.
[中]使用当前属性更新配置对象。使用当前属性异步启动对托管服务或托管服务工厂的更新回调。
这是使用配置插件服务启动回调的捆绑包的唯一方法。例如,当该捆绑包检测到需要通过其ConfigurationPlugin对象更新托管服务或托管服务工厂的更改时。

代码示例

代码示例来源:origin: hawtio/hawtio

@Override
  public void configAdminUpdate(String pid, Map<String, String> data) {
    ServiceReference sref = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
    if (sref == null) {
      throw new IllegalStateException("The configuration admin service cannot be found.");
    }

    try {
      ConfigurationAdmin ca = (ConfigurationAdmin) bundleContext.getService(sref);
      if (ca == null) {
        throw new IllegalStateException("The configuration admin service cannot be found.");
      }
      Configuration config = ca.getConfiguration(pid, null);
      config.update(new Hashtable<String, String>(data));
    } catch (IOException ioe) {
      throw new RuntimeException(ioe);
    } finally {
      bundleContext.ungetService(sref);
    }
  }
}

代码示例来源:origin: spring-projects/spring-roo

@Override
public void addRepository(String url) throws Exception {
 LOGGER.log(Level.INFO, "Adding repository " + url + "...");
 getRepositoryAdmin().addRepository(url);
 // Including repos into installed Repos list
 installedRepos.put(url, "");
 // Updating configuration service with installed repos
 config.update(installedRepos);
 LOGGER.log(Level.INFO, "Repository '" + url + "' added!");
}

代码示例来源:origin: spring-projects/spring-roo

@Override
public void removeRepo(String url) throws Exception {
 LOGGER.log(Level.INFO, "Removing repository " + url + "...");
 getRepositoryAdmin().removeRepository(url);
 // Removing repos from installed Repos list
 installedRepos.remove(url);
 // Updating configuration service with installed repos
 config.update(installedRepos);
 LOGGER.log(Level.INFO, "Repository '" + url + "' removed!");
}

代码示例来源:origin: apache/felix

/**
 * @see org.osgi.service.cm.Configuration#update(java.util.Dictionary)
 *hashtable is a dictionary!
 */
public void update(Hashtable properties) throws IOException {
  configuration.update(properties);
}

代码示例来源:origin: apache/felix

/**
 * @see org.osgi.service.cm.Configuration#update()
 */
public void update() throws IOException {
  configuration.update();
}

代码示例来源:origin: apache/felix

public void deleteProperty(String key) throws Exception{
        Dictionary dic = configuration.getProperties();
        Enumeration keys = dic.keys();
        while (keys.hasMoreElements()) {
          String k = (String) keys.nextElement();
          if (k.equals(key)) {
            dic.remove(k);
              configuration.update(dic);
          }
        }
      }
}

代码示例来源:origin: org.apache.clerezza/platform.logging.core

private void setProperties(Dictionary props)
    throws IOException {
  Configuration config = getServiceConfig();
  config.update(props);
}

代码示例来源:origin: com.liferay/com.liferay.captcha.api

public static void setCaptcha(Captcha captcha) throws Exception {
  Configuration configuration = _configurationAdmin.getConfiguration(
    CaptchaConfiguration.class.getName(), StringPool.QUESTION);
  Dictionary<String, Object> properties = configuration.getProperties();
  if (properties == null) {
    properties = new Hashtable<>();
  }
  Class<?> clazz = captcha.getClass();
  properties.put("captchaEngine", clazz.getName());
  configuration.update(properties);
}

代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.config

@Override
public void setExcludedProperties(String excludedProperties) throws Exception {
  Configuration nodeConfiguration = configurationAdmin.getConfiguration(Configurations.NODE, null);
  if (nodeConfiguration != null) {
    Dictionary properties = nodeConfiguration.getProperties();
    if (properties == null)
      properties = new Properties();
    properties.put("config.excluded.properties", excludedProperties);
    nodeConfiguration.update(properties);
  }
}

代码示例来源:origin: org.apache.jclouds.karaf/services

public void clear() {
  try {
    configuration.update(newDictionary());
  } catch (IOException e) {
    LOGGER.warn("Failed to clear configuration admin jclouds credentials store.", e);
  }
  credentialsMap.clear();
}

代码示例来源:origin: org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast

private void updateConfiguration(Configuration cfg, Dictionary<String, Object> properties) throws IOException {
    cfg.update(properties);
    LOGGER.debug("CELLAR HAZELCAST: updated configuration with pid: {}", cfg.getPid());
  }
}

代码示例来源:origin: apache/karaf-cellar

@Override
public void setExcludedProperties(String excludedProperties) throws Exception {
  Configuration nodeConfiguration = configurationAdmin.getConfiguration(Configurations.NODE, null);
  if (nodeConfiguration != null) {
    Dictionary properties = nodeConfiguration.getProperties();
    if (properties == null)
      properties = new Properties();
    properties.put("config.excluded.properties", excludedProperties);
    nodeConfiguration.update(properties);
  }
}

代码示例来源:origin: apache/karaf-cellar

private void updateConfiguration(Configuration cfg, Dictionary<String, Object> properties) throws IOException {
    cfg.update(properties);
    LOGGER.debug("CELLAR HAZELCAST: updated configuration with pid: {}", cfg.getPid());
  }
}

代码示例来源:origin: io.snamp/internal-services

private void serialize(final String identityName,
               final E entity,
               final Configuration output) throws IOException {
  final Dictionary<String, Object> configuration = serialize(entity);
  configuration.put(identityHolderName, identityName);
  entity.forEach((name, value) -> {
    if (!IGNORED_PROPERTIES.contains(name))
      configuration.put(name, value);
  });
  output.update(configuration);
}

代码示例来源:origin: io.snamp/internal-services

@Override
  final void saveChanges(final SerializableEntityMap<E> source, final ConfigurationAdmin dest) throws IOException {
    final Configuration config = getConfig(dest);
    Dictionary<String, Object> props = config.getProperties();
    if(props == null)
      props = new Hashtable<>();
    saveChanges(source, props);
    config.update(props);
  }
}

代码示例来源:origin: osgi/osgi.enroute.examples

/**
 * This code is the same as {@link #exampleSingleton()} but it creates a
 * Configuration Listener. A listener receives events from configuration
 * admin.
 */
@Tooltip("Create a a configuration for pid='listener', this activates the ConfigurationListenerExample component")
public void listener() throws IOException {
  Configuration configuration = cm.getConfiguration("listener", "?");
  if (configuration.getProperties() == null)
    configuration.update(new Hashtable<String, Object>());
}

代码示例来源:origin: osgi/osgi.enroute.examples

/**
 * This code shows how you can create a singleton configuration with
 * Configuration Admin. This will instantiate a
 * {@link ManagedServiceExample}
 */
@Tooltip("Create a a configuration for pid='singleton', this activates the ManagedServiceExample component")
public void singleton() throws IOException {
  Configuration configuration = cm.getConfiguration("singleton", "?");
  Hashtable<String, Object> map = new Hashtable<String, Object>();
  map.put("msg", "Hello Singleton");
  configuration.update(map);
}

代码示例来源:origin: io.fabric8.mq/mq-fabric

@Activate
void activate(Map<String, ?> configuration) throws Exception {
  boolean standalone = "true".equalsIgnoreCase((String) configuration.get("standalone"));
  String factoryPid = standalone ?
      "io.fabric8.mq.fabric.standalone.server" :
      "io.fabric8.mq.fabric.clustered.server";
  config = configurationAdmin.get().createFactoryConfiguration(factoryPid, null);
  config.update(toDictionary(configuration));
}

代码示例来源:origin: org.apache.karaf.cave.deployer/org.apache.karaf.cave.deployer.service

@Override
public void deleteConnection(String connection) throws Exception {
  Configuration configuration = configurationAdmin.getConfiguration(CONFIG_PID);
  Dictionary<String, Object> properties = configuration.getProperties();
  if (properties != null) {
    properties.remove(connection + ".jmx");
    properties.remove(connection + ".instance");
    properties.remove(connection + ".username");
    properties.remove(connection + ".password");
    configuration.update(properties);
  }
}

代码示例来源:origin: apache/jackrabbit-oak

private void addConfigurationEntry(TestConfig config, String key, Object value)
    throws IOException {
  config.put(key, value);
  org.osgi.service.cm.Configuration c = configAdmin.getConfiguration(config.servicePid);
  c.update(new Hashtable(config));
}

相关文章