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

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

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

Configuration.getProperties介绍

[英]Return the properties of this Configuration object. The Dictionary object returned is a private copy for the caller and may be changed without influencing the stored configuration. The keys in the returned dictionary are case insensitive and are always of type String.

If called just after the configuration is created and before update has been called, this method returns null.
[中]返回此配置对象的属性。返回的Dictionary对象是调用者的私有副本,可以在不影响存储配置的情况下进行更改。返回的字典中的键不区分大小写,并且始终为String类型。
如果在创建配置之后和调用更新之前调用,此方法将返回null。

代码示例

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

protected void activate(final ComponentContext cContext) throws Exception {
 context = cContext.getBundleContext();
 repositories = new ArrayList<Repository>();
 installedSubsystems = new ArrayList<Subsystem>();
 config = getConfigurationAdmin().getConfiguration("installedRepositories");
 installedRepos = config.getProperties();
 if (installedRepos == null) {
  installedRepos = new Hashtable();
 }
 populateRepositories();
}

代码示例来源:origin: rhuss/jolokia

private String getConfigurationFromConfigAdmin(ConfigKey pkey) {
  ConfigurationAdmin configAdmin = (ConfigurationAdmin) configAdminTracker.getService();
  if (configAdmin == null) {
    return null;
  }
  try {
    Configuration config = configAdmin.getConfiguration(CONFIG_ADMIN_PID);
    if (config == null) {
      return null;
    }
    Dictionary<?, ?> props = config.getProperties();
    if (props == null) {
      return null;
    }
    return (String) props.get(CONFIG_PREFIX + "." + pkey.getKeyValue());
  } catch (IOException e) {
    return null;
  }
}

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

/**
 * @see org.apache.felix.jmood.compendium.ConfigurationDelegateMBean#getProperty(java.lang.String)
 */
public String getProperty(String key) throws Exception {
  Object result= configuration.getProperties().get(key);
  if (result==null) return null;
  if (result instanceof String) return (String) result;
  else return result.toString();
}

代码示例来源:origin: org.apache.felix/org.apache.felix.ipojo

private Hashtable<String, Object> copyConfiguration(Configuration config) {
  Hashtable<String, Object> conf = new Hashtable<String, Object>();
  // Copy configuration
  Enumeration keys = config.getProperties().keys();
  while (keys.hasMoreElements()) {
    String key = (String) keys.nextElement();
    conf.put(key, config.getProperties().get(key));
  }
  return conf;
}

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

public String getJmxServiceUrl() throws Exception {
  org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration("org.apache.karaf.management", null);
  if (configuration != null) {
    return configuration.getProperties().get("serviceUrl").toString();
  }
  return "service:jmx:rmi:///jndi/rmi://localhost:" + MIN_RMI_SERVER_PORT + "/karaf-root";
}

代码示例来源:origin: OpenNMS/opennms

private static Map<String, String> getConfigMapFromConfigAdmin(ConfigurationAdmin configAdmin, Map<String, String> sqsConfig) throws IOException {
    final Dictionary<String, Object> properties = configAdmin.getConfiguration(AmazonSQSConstants.AWS_CONFIG_PID).getProperties();
    if (properties != null) {
      final Enumeration<String> keys = properties.keys();
      while (keys.hasMoreElements()) {
        final String key = keys.nextElement();
        sqsConfig.put(key, (String)properties.get(key));
      }
    }
    return sqsConfig;
  }
}

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

public String getHttpPort() throws Exception {
  org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration("org.ops4j.pax.web", null);
  if (configuration != null) {
    return configuration.getProperties().get("org.osgi.service.http.port").toString();
  }
  return "8181";
}

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

private Dictionary<String, Object> getConfiguration() {
  try {
    Configuration configuration = configurationAdmin.getConfiguration("org.ops4j.pax.url.mvn", null);
    if (configuration != null) {
      return configuration.getProperties();
    }
  } catch (Exception e) {
    logger.error("Error retrieving maven configuration", e);
  }
  return null;
}

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

public String getSshPort() throws Exception {
  org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration("org.apache.karaf.shell", null);
  if (configuration != null) {
    return configuration.getProperties().get("sshPort").toString();
  }
  return "8101";
}

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

private static Set<String> getConfigurationKeys(ConfigurationAdmin configurationAdmin)
    throws IOException {
  Set<String> keys = new HashSet<>();
  org.osgi.service.cm.Configuration c = configurationAdmin.getConfiguration(Configuration.PID);
  for (Object k : Collections.list(c.getProperties().keys())) {
    keys.add(k.toString());
  }
  return keys;
}

代码示例来源:origin: org.apache.karaf.bundle/org.apache.karaf.bundle.core

private Dictionary<String, Object> getConfiguration() {
  try {
    Configuration configuration = configurationAdmin.getConfiguration("org.ops4j.pax.url.mvn", null);
    if (configuration != null) {
      return configuration.getProperties();
    }
  } catch (Exception e) {
    logger.error("Error retrieving maven configuration", e);
  }
  return null;
}

代码示例来源:origin: io.fabric8.fab/fab-osgi

private static Dictionary getProperties(Configuration configuration) {
  if (configuration == null) {
    return emptyDictionary();
  } else {
    return configuration.getProperties();
  }
}

代码示例来源:origin: org.fusesource.fabric.fab/fab-osgi

private static Dictionary getProperties(Configuration configuration) {
  if (configuration == null) {
    return emptyDictionary();
  } else {
    return configuration.getProperties();
  }
}

代码示例来源:origin: com.eurodyn.qlack2.fuse/qlack2-fuse-settings-impl

/**
 * Reads a .cfg file from Config Admin and returns all properties found.
 *
 * @param pid The name of the PID (i.e. .cfg file without the .cfg extension).
 * @return Returns the list of all properties in PID.
 */
private Dictionary<String, Object> getConfigAdminProps(String pid) {
 return getConfigAdminPID(pid).getProperties();
}

代码示例来源: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: 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.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: de.dentrassi.osgi/net.luminis.cmc

public static void print(final Configuration configuration) {
  System.out.println("");
  System.out.println("Configuration for service (pid) \"" + configuration.getPid() + "\"");
  System.out.println("(bundle location = " + configuration.getBundleLocation() + ")");
  print(configuration.getProperties());
}

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

public Map<String, String> getLevel(String logger) {
  Configuration cfg;
  try {
    cfg = configAdmin.getConfiguration(CONFIGURATION_PID, null);
  } catch (IOException e) {
    throw new RuntimeException("Error retrieving Log information from config admin", e);
  }
  if (logger == null) {
    logger = LogServiceInternal.ROOT_LOGGER;
  }
  return getDelegate(cfg.getProperties()).getLevel(logger);
}

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

@Override
final void populateRepository(final ConfigurationAdmin source, final EntityMap<E> dest) throws IOException {
  final Dictionary<String, ?> config = getConfig(source).getProperties();
  if (config != null)
    dest.putAll(parse(config));
}

相关文章