Menu

Sample3

scf

Abstract

This sample show us how to use the PropertyManager


Este ejemplo nos muestra como utilizar el PropertyManager

config.properties

finders=switch,environment,system

finder.switch.class= ar.com.scf.impl.PropertyFinder
finder.switch.params= sample03/switch.properties

finder.environment.class= ar.com.scf.impl.PropertyFinder
finder.environment.params= sample03/${environment}.properties

finder.system.class= ar.com.scf.impl.SystemPropertyFinder
finder.system.params

switch.properties

environment=linux

linux.properties

config.os.name=Linux

windows.properties

config.os.name=Windows

Sample.java

package ar.com.scf.sample03;

import java.io.File;

import ar.com.scf.impl.PropertyManager;

public class Sample {

  public static void main(String[] args) {
    PropertyManager manager = new PropertyManager(new File("sample03/config.properties"));
    System.out.println(manager.getReplacer().expand("Current S.O. config: ${config.os.name}"));
    System.out.println(manager.getReplacer().expand("Current S.O.: ${os.name}"));
  }

}

output

Current S.O. config: Linux
Current S.O.: Windows XP

Related

Wiki: Samples

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.