use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class BaseJDBCLockTest method setUp.
@Before
public void setUp() throws Exception {
connection = EasyMock.createNiceMock(Connection.class);
metaData = EasyMock.createMock(DatabaseMetaData.class);
resultSet = EasyMock.createMock(ResultSet.class);
preparedStatement = EasyMock.createMock(PreparedStatement.class);
statement = EasyMock.createMock(Statement.class);
props = new Properties();
props.put("karaf.lock.jdbc.url", url);
props.put("karaf.lock.jdbc.driver", driver);
props.put("karaf.lock.jdbc.user", user);
props.put("karaf.lock.jdbc.password", password);
props.put("karaf.lock.jdbc.table", tableName);
props.put("karaf.lock.jdbc.clustername", clustername);
props.put("karaf.lock.jdbc.timeout", Integer.toString(timeout));
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class AutoEncryptionSupport method run.
@Override
public void run() {
WatchService watchService = null;
try {
watchService = FileSystems.getDefault().newWatchService();
Path dir = Paths.get(System.getProperty("karaf.etc"));
dir.register(watchService, ENTRY_MODIFY);
Path file = dir.resolve("users.properties");
encryptedPassword(new Properties(file.toFile()));
while (running) {
try {
WatchKey key = watchService.poll(1, TimeUnit.SECONDS);
if (key == null) {
continue;
}
for (WatchEvent<?> event : key.pollEvents()) {
@SuppressWarnings("unchecked") WatchEvent<Path> ev = (WatchEvent<Path>) event;
// Context for directory entry event is the file name of entry
Path name = dir.resolve(ev.context());
if (file.equals(name)) {
encryptedPassword(new Properties(file.toFile()));
}
}
key.reset();
} catch (IOException e) {
LOGGER.warn(e.getMessage(), e);
} catch (InterruptedException e) {
// Ignore as this happens on shutdown
}
}
} catch (IOException e) {
LOGGER.warn(e.getMessage(), e);
} finally {
StreamUtils.close(watchService);
}
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class PropertiesLoader method loadIncludes.
private static void loadIncludes(String propertyName, boolean mandatory, URL configPropURL, Properties configProps) throws Exception {
String includes = configProps.get(propertyName);
if (includes != null) {
StringTokenizer st = new StringTokenizer(includes, "\" ", true);
if (st.countTokens() > 0) {
String location;
do {
location = nextLocation(st);
if (location != null) {
URL url = new URL(configPropURL, location);
Properties props = loadPropertiesFile(url, mandatory);
configProps.putAll(props);
}
} while (location != null);
}
}
configProps.remove(propertyName);
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class PropertiesLoader method loadSystemProperties.
/**
* <p>
* Loads the properties in the system property file associated with the
* framework installation into <tt>System.setProperty()</tt>. These properties
* are not directly used by the framework in anyway. By default, the system
* property file is located in the <tt>conf/</tt> directory of the Felix
* installation directory and is called "<tt>system.properties</tt>". The
* installation directory of Felix is assumed to be the parent directory of
* the <tt>felix.jar</tt> file as found on the system class path property.
* The precise file from which to load system properties can be set by
* initializing the "<tt>felix.system.properties</tt>" system property to an
* arbitrary URL.
* </p>
*
* @param file the Karaf base folder.
* @throws IOException if the system file can't be loaded.
*/
public static void loadSystemProperties(File file) throws IOException {
Properties props = new Properties(false);
try {
props.load(file);
} catch (Exception e1) {
// Ignore
}
for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements(); ) {
String name = (String) e.nextElement();
if (name.startsWith(OVERRIDE_PREFIX)) {
String overrideName = name.substring(OVERRIDE_PREFIX.length());
String value = props.getProperty(name);
System.setProperty(overrideName, substVars(value, name, null, props));
} else {
String value = System.getProperty(name, props.getProperty(name));
System.setProperty(name, substVars(value, name, null, props));
}
}
}
use of org.apache.felix.utils.properties.Properties in project karaf by apache.
the class PropertiesLoader method loadConfigProperties.
/**
* <p>
* Loads the configuration properties in the configuration property file
* associated with the framework installation; these properties
* are accessible to the framework and to bundles and are intended
* for configuration purposes. By default, the configuration property
* file is located in the <tt>conf/</tt> directory of the Felix
* installation directory and is called "<tt>config.properties</tt>".
* The installation directory of Felix is assumed to be the parent
* directory of the <tt>felix.jar</tt> file as found on the system class
* path property. The precise file from which to load configuration
* properties can be set by initializing the "<code>felix.config.properties</code>"
* system property to an arbitrary URL.
* </p>
*
* @param file the config file where to load the properties.
* @return A <code>Properties</code> instance or <code>null</code> if there was an error.
* @throws Exception if something wrong occurs.
*/
public static Properties loadConfigProperties(File file) throws Exception {
// See if the property URL was specified as a property.
URL configPropURL;
try {
configPropURL = file.toURI().toURL();
} catch (MalformedURLException ex) {
System.err.print("Main: " + ex);
return null;
}
Properties configProps = loadPropertiesFile(configPropURL, false);
copySystemProperties(configProps);
configProps.substitute();
return configProps;
}
Aggregations