Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

SMILA/Project Concepts/Simple configuration handler

1 Description

Many of bundles requires now configuration handling but its still in the discussion process. Its suggested to use now simple config loader instead of manual loading. It will be easier in the future replace it in normal config manager.

2 Discussion

3 Technical Proposal

3.1 Usage

import package "org.eclipse.smila.utils.config" in Manifest.mf and use helper ConfigUtils

public static InputStream getConfigStream(final String bundleName, final String configPath,
    final String defaultConfigPath);

There is also sortcut method

public static InputStream getConfigStream(final String bundleName, final String configPath) {
    return getConfigStream(bundleName, configPath, configPath);
}


3.2 How it works

  1. Helper check system variable "org.eclipse.smila.utils.config.root" and, if its configured, tracts it as the configurations root folder.
  2. If not configurations folder is default: "{eclipse-path}/configuration"
  3. Its checks is configurations folder contains subfolder for bundle (bundleName) and file (configPath).
  4. If file is not found it loads default configuration (defaultConfigPath) directly from the bundle.
  5. If default resource not found - runtime error ConfigurationLoadException thrown


3.3 Samples

private static final String BUNDLE_ID = "org.eclipse.smila.connectivity.queue";
private static final String CONFIG_JMS_NAME = "jms.properties";
.............................................................................................
 
    InputStream inputStream = ConfigUtils.getConfigStream(BUNDLE_ID, CONFIG_JMS_NAME);
    final Properties properties = new Properties();
    try {
      properties.load(inputStream);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }

Back to the top