List of usage examples for java.util.prefs Preferences node
public abstract Preferences node(String pathName);
From source file:org.multicore_association.measure.mem.generate.MemCodeGen.java
/** * Parsing configuration./*from ww w. ja va 2s. c o m*/ * @param prefs read configuration data * @return Flag for success judgements * @throws BackingStoreException */ private boolean parseConfigData(Preferences prefs) throws BackingStoreException { /* check of the section presence */ ArrayList<String> seclist = ConfigData.getSectionNameList(); boolean result = true; for (Iterator<String> i = seclist.iterator(); i.hasNext();) { String name = i.next(); if (!checkPrefSection(prefs, name)) { System.err.println("Error: mandatory section does not exist" + " (" + name + ")"); //$NON-NLS-3$ result = false; } } /* check of the entry presence */ ArrayList<String> mentrylist = ConfigData.getMainEntryNameList(); for (Iterator<String> i = mentrylist.iterator(); i.hasNext();) { String name = i.next(); if (!checkPrefEntry(prefs, ConfigData.SECTION_MAIN, name)) { System.err.println("Error: mandatory entry does not exist" + " (" + name + ")"); //$NON-NLS-3$ result = false; } } /* set configuration data */ confData = new ConfigData(); Preferences sec_main = prefs.node(ConfigData.SECTION_MAIN); confData.setMainInclude(sec_main.get(ConfigData.ENTRY_INCLUDE, "")); confData.setMainGlobalValiable(sec_main.get(ConfigData.ENTRY_GLOBAL_VARIABLE, "")); confData.setMainMacro(sec_main.get(ConfigData.ENTRY_MACRO, "")); return result; }
From source file:com.adito.server.Main.java
public Integer start(String[] args) { startupStarted = System.currentTimeMillis(); // Inform the wrapper the startup process may take a while if (useWrapper) { WrapperManager.signalStarting(60000); }/*from w w w. j ava 2 s. co m*/ // Parse the command line Integer returnCode = parseCommandLine(args); if (returnCode != null) { if (returnCode.intValue() == 999) { return null; } return returnCode; } // Create the boot progress monitor if (gui) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } bootProgressMonitor = new SwingBootProgressMonitor(); } else { bootProgressMonitor = new LogBootProgressMonitor(); } // resourceCaches = new HashMap<URL, ResourceCache>(); contextListeners = new ArrayList<ContextListener>(); loadSystemProperties(); initialiseLogging(); /* * Migrate preferences. */ File newPrefDir = new File(ContextHolder.getContext().getConfDirectory(), "prefs"); PREF = PropertyPreferences.SYSTEM_ROOT; try { if (!newPrefDir.exists() && Preferences.systemRoot().node("/com").nodeExists("adito")) { Preferences from = Preferences.systemRoot().node("/com/adito"); log.warn("Migrating preferences"); try { copyNode(from.node("core"), PREF.node("core")); from.node("core").removeNode(); copyNode(from.node("plugin"), PREF.node("plugin")); from.node("plugin").removeNode(); copyNode(from.node("extensions"), PREF.node("extensions")); from.node("extensions").removeNode(); copyNode(from.node("dbupgrader"), PREF.node("dbupgrader")); from.node("dbupgrader").removeNode(); } catch (Exception e) { log.error("Failed to migrate preferences.", e); } try { from.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush old preferences"); } try { PREF.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush new preferences"); } if (log.isInfoEnabled()) { log.info("Flushing preferences"); } } } catch (BackingStoreException bse) { log.error("Failed to migrate preferences.", bse); } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } try { clearTemp(); try { hostname = Inet4Address.getLocalHost().getCanonicalHostName(); hostAddress = Inet4Address.getLocalHost().getHostAddress(); } catch (Exception ex) { // This should be fatal, we now rely on the hostname being // available throw new Exception("The host name or address on which this service is running could not " + "be determined. Check you network configuration. One possible cause is " + "a misconfigured 'hosts' file (e.g. on UNIX-like systems this would be " + "/etc/hosts, on Windows XP it would be " + "C:\\Windows\\System32\\Drivers\\Etc\\Hosts)."); } PropertyClassManager.getInstance() .registerPropertyClass(contextConfiguration = new ContextConfig(getClass().getClassLoader())); // Display some information about the system we are running on displaySystemInfo(); // Load the context property definitions loadContextProperties(); // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } // Configure any HTTP / HTTPS / SOCKS proxy servers configureProxyServers(); PropertyList l = contextConfiguration.retrievePropertyList(new ContextKey("webServer.bindAddress")); getBootProgressMonitor().updateMessage("Creating server lock"); getBootProgressMonitor().updateProgress(6); serverLock = new ServerLock((String) l.get(0)); if (serverLock.isLocked()) { if (!isSetupMode()) { if (serverLock.isSetup()) { throw new Exception("The installation wizard is currently running. " + "Please shut this down by pointing your browser " + "to http://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The server is already running."); } } else { if (!serverLock.isSetup()) { throw new Exception("The server is currently already running. " + "Please shut this down by pointing your browser " + "to https://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The installation wizard is running.."); } } } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { serverLock.stop(); } }); // registerKeyStores(); // threadGroup = new ThreadGroup("MainThreadGroup"); if (install) { setupMode(); } else { normalMode(); startHttpServer(); } } catch (Throwable t) { startupException = t; log.error("Failed to start the server. " + t.getMessage(), t); return new Integer(1); } return null; }
From source file:com.sslexplorer.server.Main.java
public Integer start(String[] args) { startupStarted = System.currentTimeMillis(); // Inform the wrapper the startup process may take a while if (useWrapper) { WrapperManager.signalStarting(60000); }/*from w w w. j ava2 s . c o m*/ // Parse the command line Integer returnCode = parseCommandLine(args); if (returnCode != null) { if (returnCode.intValue() == 999) { return null; } return returnCode; } // Create the boot progress monitor if (gui) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } bootProgressMonitor = new SwingBootProgressMonitor(); } else { bootProgressMonitor = new LogBootProgressMonitor(); } // resourceCaches = new HashMap<URL, ResourceCache>(); contextListeners = new ArrayList<ContextListener>(); loadSystemProperties(); initialiseLogging(); /* * Migrate preferences. */ File newPrefDir = new File(ContextHolder.getContext().getConfDirectory(), "prefs"); PREF = PropertyPreferences.SYSTEM_ROOT; try { if (!newPrefDir.exists() && Preferences.systemRoot().node("/com").nodeExists("sslexplorer")) { Preferences from = Preferences.systemRoot().node("/com/sslexplorer"); log.warn("Migrating preferences"); try { copyNode(from.node("core"), PREF.node("core")); from.node("core").removeNode(); copyNode(from.node("plugin"), PREF.node("plugin")); from.node("plugin").removeNode(); copyNode(from.node("extensions"), PREF.node("extensions")); from.node("extensions").removeNode(); copyNode(from.node("dbupgrader"), PREF.node("dbupgrader")); from.node("dbupgrader").removeNode(); } catch (Exception e) { log.error("Failed to migrate preferences.", e); } try { from.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush old preferences"); } try { PREF.flush(); } catch (BackingStoreException bse) { log.error("Failed to flush new preferences"); } if (log.isInfoEnabled()) { log.info("Flushing preferences"); } } } catch (BackingStoreException bse) { log.error("Failed to migrate preferences.", bse); } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } try { clearTemp(); try { hostname = Inet4Address.getLocalHost().getCanonicalHostName(); hostAddress = Inet4Address.getLocalHost().getHostAddress(); } catch (Exception ex) { // This should be fatal, we now rely on the hostname being // available throw new Exception("The host name or address on which this service is running could not " + "be determined. Check you network configuration. One possible cause is " + "a misconfigured 'hosts' file (e.g. on UNIX-like systems this would be " + "/etc/hosts, on Windows XP it would be " + "C:\\Windows\\System32\\Drivers\\Etc\\Hosts)."); } PropertyClassManager.getInstance() .registerPropertyClass(contextConfiguration = new ContextConfig(getClass().getClassLoader())); // Display some information about the system we are running on displaySystemInfo(); // Load the context property definitions loadContextProperties(); // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } // Configure any HTTP / HTTPS / SOCKS proxy servers configureProxyServers(); PropertyList l = contextConfiguration.retrievePropertyList(new ContextKey("webServer.bindAddress")); getBootProgressMonitor().updateMessage("Creating server lock"); getBootProgressMonitor().updateProgress(6); serverLock = new ServerLock((String) l.get(0)); if (serverLock.isLocked()) { if (!isSetupMode()) { if (serverLock.isSetup()) { throw new Exception("The installation wizard is currently running. " + "Please shut this down by pointing your browser " + "to http://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The server is already running."); } } else { if (!serverLock.isSetup()) { throw new Exception("The server is currently already running. " + "Please shut this down by pointing your browser " + "to https://" + getHostname() + ":" + serverLock.getPort() + "/showShutdown.do before attempting to start the server again."); } else { throw new Exception("The installation wizard is running.."); } } } // Inform the wrapper the startup process is going ok if (useWrapper) { WrapperManager.signalStarting(60000); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { serverLock.stop(); } }); // registerKeyStores(); // threadGroup = new ThreadGroup("MainThreadGroup"); if (install) { setupMode(); } else { normalMode(); startHttpServer(); } } catch (Throwable t) { startupException = t; log.error("Failed to start the server. " + t.getMessage(), t); return new Integer(1); } return null; }
From source file:com.adito.server.Main.java
void copyNode(Preferences from, Preferences to) throws BackingStoreException { String[] keys = from.keys();/*from w ww .j a v a 2s . c o m*/ for (int i = 0; i < keys.length; i++) { to.put(keys[i], from.get(keys[i], "")); } String childNodes[] = from.childrenNames(); for (int i = 0; i < childNodes.length; i++) { Preferences cn = from.node(childNodes[i]); Preferences tn = to.node(childNodes[i]); copyNode(cn, tn); } }