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

Difference between revisions of "SMILA/Project Concepts/Simple configuration handler"

m (New page: == 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. ...)
 
Line 11: Line 11:
 
== 3.1 Usage ==
 
== 3.1 Usage ==
  
import package "org.eclipse.eilf.utils.config" in Manifest.mf and use helper ConfigUtils
+
import package "org.eclipse.smila.utils.config" in Manifest.mf and use helper ConfigUtils
  
 
<source lang="Java">
 
<source lang="Java">
Line 29: Line 29:
 
== 3.2 How it works ==
 
== 3.2 How it works ==
  
# Helper check system variable "org.eclipse.eilf.utils.config.root" and, if its configured, tracts it as the configurations root folder.
+
# Helper check system variable "org.eclipse.smila.utils.config.root" and, if its configured, tracts it as the configurations root folder.
 
# If not configurations folder is default: "{eclipse-path}/configuration"
 
# If not configurations folder is default: "{eclipse-path}/configuration"
 
# Its checks is configurations folder contains subfolder for bundle (bundleName) and file (configPath).
 
# Its checks is configurations folder contains subfolder for bundle (bundleName) and file (configPath).
Line 40: Line 40:
  
 
<source lang="Java">
 
<source lang="Java">
private static final String BUNDLE_ID = "org.eclipse.eilf.connectivity.queue";
+
private static final String BUNDLE_ID = "org.eclipse.smila.connectivity.queue";
 
private static final String CONFIG_JMS_NAME = "jms.properties";
 
private static final String CONFIG_JMS_NAME = "jms.properties";
 
.............................................................................................
 
.............................................................................................

Revision as of 08:34, 16 October 2008

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