use of org.osgi.service.prefs.Preferences in project tdi-studio-se by Talend.
the class Log4jPrefsSettingManager method saveLog4jNodeIntoPref.
public void saveLog4jNodeIntoPref(final String prefNode, final String value) {
try {
Preferences log4jSettings = null;
if (!isLog4jPrefsExist()) {
// if not exist,create it
log4jSettings = getLog4jPreferences(prefNode, true);
} else {
log4jSettings = getLog4jPreferences(prefNode, false);
}
if (log4jSettings != null) {
log4jSettings.put(prefNode, value);
// save log4j activate to prefs
log4jSettings.flush();
}
} catch (BackingStoreException e) {
ExceptionHandler.process(e);
}
}
use of org.osgi.service.prefs.Preferences in project tdi-studio-se by Talend.
the class Log4jPrefsSettingManager method getValueOfPreNode.
public String getValueOfPreNode(String nodeName) {
Preferences nodePre = null;
nodePre = getLog4jPreferences(nodeName, false);
if (nodePre == null) {
return Boolean.FALSE.toString();
}
return nodePre.get(nodeName, null);
}
use of org.osgi.service.prefs.Preferences in project felix by apache.
the class PreferencesImpl method nodeExists.
/**
* We do not synchronize this method to avoid dead locks as this
* method might call another preferences object in the hierarchy.
* @see org.osgi.service.prefs.Preferences#nodeExists(java.lang.String)
*/
public boolean nodeExists(String pathName) throws BackingStoreException {
if (pathName == null) {
throw new NullPointerException("Path must not be null.");
}
if (pathName.length() == 0) {
return this.valid;
}
PreferencesImpl node = this;
synchronized (this) {
this.checkValidity();
if (pathName.startsWith("/") && this.parent != null) {
node = this.getRoot();
}
if (pathName.startsWith("/")) {
pathName = pathName.substring(1);
}
}
final Preferences searchNode = node.getNode(pathName, false, false);
return searchNode != null;
}
use of org.osgi.service.prefs.Preferences in project felix by apache.
the class PreferencesImplTest method testAddRemoveAdd.
@Test
public void testAddRemoveAdd() throws Exception {
final BackingStore store = new DataFileBackingStoreImpl(null, Files.createTempDirectory("prefs").toFile());
final PreferencesImpl prefs = new PreferencesImpl(new PreferencesDescription(5L, null), new BackingStoreManager() {
public BackingStore getStore() throws BackingStoreException {
return store;
}
});
Preferences firstA = prefs.node("A");
firstA.node("1");
firstA.node("2");
assertEquals(1, prefs.childrenNames().length);
assertEquals(2, firstA.childrenNames().length);
firstA.removeNode();
prefs.flush();
assertEquals(0, prefs.childrenNames().length);
firstA = prefs.node("A");
assertEquals(1, prefs.childrenNames().length);
assertEquals(0, firstA.childrenNames().length);
firstA.node("1");
firstA.node("2");
assertEquals(2, firstA.childrenNames().length);
}
use of org.osgi.service.prefs.Preferences in project knime-core by knime.
the class KNIMEApplicationWorkbenchAdvisor method changeDefaultPreferences.
@SuppressWarnings("restriction")
private void changeDefaultPreferences() {
// enable automatic check for updates every day at 11:00
Preferences node = DefaultScope.INSTANCE.getNode(AutomaticUpdatePlugin.PLUGIN_ID);
node.putBoolean(org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceConstants.PREF_AUTO_UPDATE_ENABLED, true);
node.put(org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE, org.eclipse.equinox.internal.p2.ui.sdk.scheduler.PreferenceConstants.PREF_UPDATE_ON_SCHEDULE);
node.put(AutomaticUpdateScheduler.P_DAY, AutomaticUpdateMessages.SchedulerStartup_day);
node.put(AutomaticUpdateScheduler.P_HOUR, AutomaticUpdateMessages.SchedulerStartup_11AM);
}
Aggregations