List of usage examples for java.lang Boolean getBoolean
public static boolean getBoolean(String name)
From source file:com.adeptj.runtime.server.Server.java
private int handlePortAvailability(Config httpConf) { Integer port = Integer.getInteger(Constants.SYS_PROP_SERVER_PORT); if (port == null) { LOGGER.warn("No port specified via system property: [{}], using default port: [{}]", Constants.SYS_PROP_SERVER_PORT, httpConf.getInt(Constants.KEY_PORT)); port = httpConf.getInt(Constants.KEY_PORT); }// w ww . ja v a 2 s. c om // Note: Shall we do it ourselves or let server do it later? Problem may arise in OSGi Framework provisioning // as it is being started already and another server start(from same location) will again start new OSGi // Framework which may interfere with already started OSGi Framework as the bundle deployment, heap dump, // OSGi configurations directory is common, this is unknown at this moment but just to be on safer side doing this. if (Boolean.getBoolean(ServerConstants.SYS_PROP_CHECK_PORT) && !isPortAvailable(port)) { LOGGER.error("Port: [{}] already used, shutting down JVM!!", port); // Let the LOGBACK cleans up it's state. LogbackManager.getInstance().getLoggerContext().stop(); System.exit(-1); // NOSONAR } return port; }
From source file:org.talend.rcp.intro.Application.java
/** * Return <code>true</code> if the lock could be acquired. * //from w w w. j av a 2 s .c om * @param shell * @return null if lock was aquired or some exit status else * @throws IOException if lock acquisition fails somehow */ private Object acquireWorkspaceLock(Shell shell) throws IOException { // -data @none was specified but an ide requires workspace Location instanceLoc = Platform.getInstanceLocation(); if (instanceLoc == null) { MessageDialog.openError(shell, Messages.getString("Application_workspaceMandatoryTitle"), //$NON-NLS-1$ Messages.getString("Application.Application_workspaceMandatoryMessage")); //$NON-NLS-1$ return EXIT_OK; } // -data "/valid/path", workspace already set if (instanceLoc.isSet()) { // at this point its valid, so try to lock it and update the // metadata version information if successful try { if (instanceLoc.lock()) { return null; } // we failed to create the directory. // Two possibilities: // 1. directory is already in use // 2. directory could not be created File workspaceDirectory = new File(instanceLoc.getURL().getFile()); if (workspaceDirectory.exists()) { MessageDialog.openError(shell, Messages.getString("Application.WorkspaceInuseTitle"), //$NON-NLS-1$ Messages.getString("Application.WorkspaceInuseMessage", workspaceDirectory)); //$NON-NLS-1$ } else { MessageDialog.openError(shell, Messages.getString("Application.WorkspaceCannotBeSetTitle"), //$NON-NLS-1$ Messages.getString("Application.WorkspaceCannotBeSetMessage")); //$NON-NLS-1$ } } catch (IOException e) { log.error("Could not obtain lock for workspace location", //$NON-NLS-1$ e); MessageDialog.openError(shell, "internal error", e.getMessage()); } return EXIT_OK; } // -data @noDefault or -data not specified, prompt and set ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc.getDefault()); boolean force = false; while (true) { // check if it is first launch and the workspace is forced to be shown, otherwise do not display the prompt Preferences node = new ConfigurationScope().getNode(ChooseWorkspaceData.ORG_TALEND_WORKSPACE_PREF_NODE); boolean workspaceAlreadyShown = node.getBoolean(INITIAL_WORKSPACE_SHOWN, false); URL workspaceUrl = null; if (!workspaceAlreadyShown && !Boolean.getBoolean(TALEND_FORCE_INITIAL_WORKSPACE_PROMPT_SYS_PROP)) { workspaceUrl = instanceLoc.getDefault(); launchData.setShowDialog(false);// prevent the prompt to be shown next restart node.putBoolean(INITIAL_WORKSPACE_SHOWN, true); try { node.flush(); } catch (BackingStoreException e) { log.error("failed to store workspace location in preferences :", e); //$NON-NLS-1$ } // keep going to force the promp to appear } else { workspaceUrl = promptForWorkspace(shell, launchData, force); if (workspaceUrl == null) { return EXIT_OK; } } // if there is an error with the first selection, then force the // dialog to open to give the user a chance to correct force = true; try { // the operation will fail if the url is not a valid // instance data area, so other checking is unneeded if (instanceLoc.setURL(workspaceUrl, true)) { launchData.writePersistedData(); return null; } } catch (IllegalStateException e) { log.error(e); MessageDialog.openError(shell, Messages.getString("Application.WorkspaceCannotBeSetTitle"), //$NON-NLS-1$ Messages.getString("Application.WorkspaceCannotBeSetMessage", workspaceUrl.getFile())); return EXIT_OK; } // by this point it has been determined that the workspace is // already in use -- force the user to choose again MessageDialog.openError(shell, Messages.getString("Application.WorkspaceInuseTitle"), //$NON-NLS-1$ Messages.getString("Application.WorkspaceInuseMessage")); } }
From source file:org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceImpl.java
private void initDataPurging(AnalyticsDataServiceConfiguration config) { boolean dataPurgingEnable = !Boolean.getBoolean(Constants.DISABLE_ANALYTICS_DATA_PURGING_JVM_OPTION); logger.info("Data purging is " + (dataPurgingEnable ? "enabled" : "disabled") + " in this node"); if (dataPurgingEnable) { TaskService taskService = AnalyticsServiceHolder.getTaskService(); if (taskService != null) { // Registering task type for CApp based purging operations try { taskService.registerTaskType(Constants.ANALYTICS_DATA_PURGING); } catch (TaskException e) { logger.error(/*from w ww .j a v a 2s . c om*/ "Unable to registry task type for CApp based purging operations: " + e.getMessage(), e); } if (config.getAnalyticsDataPurgingConfiguration() != null) { final AnalyticsDataPurgingConfiguration analyticsDataPurgingConfiguration = config .getAnalyticsDataPurgingConfiguration(); if (analyticsDataPurgingConfiguration.isEnable()) { try { taskService.registerTaskType(ANALYTICS_DATA_PURGING_GLOBAL); TaskManager dataPurgingTaskManager = taskService .getTaskManager(ANALYTICS_DATA_PURGING_GLOBAL); if (dataPurgingTaskManager.isTaskScheduled(GLOBAL_DATA_PURGING)) { dataPurgingTaskManager.deleteTask(GLOBAL_DATA_PURGING); } dataPurgingTaskManager .registerTask(createDataPurgingTask(analyticsDataPurgingConfiguration)); dataPurgingTaskManager.scheduleTask(GLOBAL_DATA_PURGING); } catch (TaskException e) { logger.error("Unable to schedule global data purging task: " + e.getMessage(), e); } } else { Set<String> registeredTaskTypes = taskService.getRegisteredTaskTypes(); if (registeredTaskTypes != null && registeredTaskTypes.contains(ANALYTICS_DATA_PURGING_GLOBAL)) { try { TaskManager dataPurgingTaskManager = taskService .getTaskManager(ANALYTICS_DATA_PURGING_GLOBAL); if (dataPurgingTaskManager.isTaskScheduled(GLOBAL_DATA_PURGING)) { dataPurgingTaskManager.deleteTask(GLOBAL_DATA_PURGING); logger.info("Global data purging task removed."); } } catch (TaskException e) { logger.error("Unable to get purging task related information: " + e.getMessage(), e); } } } } else { logger.warn("Ignoring the data purging related operation," + " since the task service is not registered in this context."); } } } }
From source file:org.apache.qpid.client.ssl.SSLTest.java
private boolean shouldPerformTest() { // We run the SSL tests on all the Java broker profiles if (isJavaBroker()) { setTestClientSystemProperty(PROFILE_USE_SSL, "true"); }//from w ww . j ava 2 s. c o m return Boolean.getBoolean(PROFILE_USE_SSL); }
From source file:org.lockss.config.HTTPConfigFile.java
protected InputStream openHttpInputStream() throws IOException { InputStream in = null;//from w w w. j ava 2 s . c om m_IOException = null; // KLUDGE: Part of the XML config file transition. If this is // an HTTP URL and we have never loaded the file before, see if an // XML version of the file is available first. If none can be // found, try the original URL. // // This logic can and should go away when we're no longer in a // transition period, and the platform knows about XML config // files. if (!Boolean.getBoolean("org.lockss.config.noXmlHack") && m_config == null && m_fileType == PROPERTIES_FILE) { String xmlUrl = makeXmlUrl(m_fileUrl); try { log.debug2("First pass: Trying to load XML-ized URL: " + xmlUrl); in = getUrlInputStream(xmlUrl); if (in == null) { throw new FileNotFoundException("No XML file: " + xmlUrl); } // This is really an XML file, deceitfully set the URL and // file type for when we reload. m_fileType = XML_FILE; m_fileUrl = xmlUrl; } catch (Exception dontCare) { // Couldn't load it as an XML file, try to load the real URL name. log.debug2("Second pass: That didn't work, trying to " + "load original URL: " + m_fileUrl); in = getUrlInputStream(m_fileUrl); } } else { in = getUrlInputStream(m_fileUrl); } if (in != null) { m_loadedUrl = null; // we're no longer loaded from failover, if we were. File tmpCacheFile; // If so configured, save the contents of the remote file in a locally // cached copy. if (m_cfgMgr != null && (tmpCacheFile = m_cfgMgr.getRemoteConfigFailoverTempFile(m_fileUrl)) != null) { try { log.log((m_cfgMgr.haveConfig() ? Logger.LEVEL_DEBUG : Logger.LEVEL_INFO), "Copying remote config: " + m_fileUrl); OutputStream out = new BufferedOutputStream(new FileOutputStream(tmpCacheFile)); out = makeHashedOutputStream(out); out = new GZIPOutputStream(out, true); InputStream wrapped = new TeeInputStream(in, out, true); return wrapped; } catch (IOException e) { log.error("Error opening remote config failover temp file: " + tmpCacheFile, e); return in; } } } return in; }
From source file:com.ejisto.util.IOUtils.java
private static String getActualLibDirectory() { return Boolean.getBoolean(StringConstants.DEV_MODE.getValue()) ? "" : "lib"; }
From source file:org.mili.core.logging.DefaultLogger.java
private void logThrowableIfNeeded(Throwable throwable) { if (Boolean.getBoolean(PROP_LOGTHROWABLES)) { if (this.throwableLogger == null) { String name = null;/*from w w w. j a v a 2 s.co m*/ if (!System.getProperties().containsKey(PROP_LOGTHROWABLESDIR)) { name = System.getProperty("java.io.tmpdir"); } else { name = System.getProperty(PROP_LOGTHROWABLESDIR); } File dir = new File(name); this.throwableLogger = new DefaultThrowableLogger(this.cls, dir); } try { this.throwableLogger.log(throwable); } catch (IOException e) { this.root.error(e); } } }
From source file:org.openconcerto.sql.model.SQLSchema.java
/** * Set the value of a metadata.//ww w .j a v a2 s. c o m * * @param name name of the metadata, e.g. "Customer". * @param sqlExpr SQL value of the metadata, e.g. "'ACME, inc'". * @param createTable whether the metadata table should be automatically created if necessary. * @return <code>true</code> if the value was set, <code>false</code> otherwise ; the new value * (<code>null</code> if the value wasn't set, i.e. if the value cannot be * <code>null</code> the boolean isn't needed). * @throws SQLException if an error occurs while setting the value. */ Tuple2<Boolean, String> setFwkMetadata(String name, String sqlExpr, boolean createTable) throws SQLException { if (Boolean.getBoolean(NOAUTO_CREATE_METADATA)) return Tuple2.create(false, null); final SQLSystem sys = getServer().getSQLSystem(); final SQLSyntax syntax = sys.getSyntax(); final SQLDataSource ds = this.getDBSystemRoot().getDataSource(); synchronized (this.getTreeMutex()) { // don't refresh until after the insert, that way if the refresh triggers an access to // the metadata name will already be set to value. final boolean shouldRefresh; if (createTable && !this.contains(METADATA_TABLENAME)) { final SQLCreateMoveableTable create = getCreateMetadata(syntax); ds.execute(create.asString(getDBRoot().getName())); shouldRefresh = true; } else { shouldRefresh = false; } final Tuple2<Boolean, String> res; if (createTable || this.contains(METADATA_TABLENAME)) { // don't use SQLRowValues, cause it means getting the SQLTable and thus calling // fetchTables(), but setFwkMetadata() might itself be called by fetchTables() // furthermore SQLRowValues support only rowable tables final List<String> queries = new ArrayList<String>(); final SQLName tableName = new SQLName(this.getBase().getName(), this.getName(), METADATA_TABLENAME); final String where = " WHERE " + SQLBase.quoteIdentifier("NAME") + " = " + getBase().quoteString(name); queries.add("DELETE FROM " + tableName.quote() + where); final String returning = sys == SQLSystem.POSTGRESQL ? " RETURNING " + SQLBase.quoteIdentifier("VALUE") : ""; final String ins = syntax.getInsertOne(tableName, Arrays.asList("NAME", "VALUE"), getBase().quoteString(name), sqlExpr) + returning; queries.add(ins); final List<? extends ResultSetHandler> handlers; if (returning.length() == 0) { queries.add( "SELECT " + SQLBase.quoteIdentifier("VALUE") + " FROM " + tableName.quote() + where); handlers = Arrays.asList(null, null, SQLDataSource.SCALAR_HANDLER); } else { handlers = Arrays.asList(null, SQLDataSource.SCALAR_HANDLER); } final List<?> ress = SQLUtils.executeMultiple(getDBSystemRoot(), queries, handlers); res = Tuple2.create(true, (String) ress.get(ress.size() - 1)); } else { res = Tuple2.create(false, null); } if (shouldRefresh) this.fetchTable(METADATA_TABLENAME); return res; } }
From source file:org.opennms.upgrade.implementations.SnmpInterfaceRrdMigratorOnline.java
/** * Gets the node directory.// w w w . j a va 2 s . c o m * * @param nodeId the node id * @param foreignSource the foreign source * @param foreignId the foreign id * @return the node directory */ protected File getNodeDirectory(int nodeId, String foreignSource, String foreignId) { File dir = new File(DataCollectionConfigFactory.getInstance().getRrdPath(), String.valueOf(nodeId)); if (Boolean.getBoolean("org.opennms.rrd.storeByForeignSource") && !(foreignSource == null) && !(foreignId == null)) { File fsDir = new File(DataCollectionConfigFactory.getInstance().getRrdPath(), "fs" + File.separatorChar + foreignSource); dir = new File(fsDir, foreignId); } return dir; }