List of usage examples for java.lang Boolean getBoolean
public static boolean getBoolean(String name)
From source file:com.tc.server.UpdateCheckAction.java
private void doUpdateCheck() throws ConnectException, IOException { updateParams();/* www.jav a2s . co m*/ URL updateUrl = buildUpdateCheckUrl(); if (Boolean.getBoolean("com.tc.debug.updatecheck")) { LOG.info("Update check url " + updateUrl); } Properties updateProps = getUpdateProperties(updateUrl); String currentVersion = productInfo.version(); String propVal = updateProps.getProperty("general.notice"); if (notBlank(propVal)) { LOG.info(propVal); } propVal = updateProps.getProperty(currentVersion + ".notices"); if (notBlank(propVal)) { LOG.info(propVal); } propVal = updateProps.getProperty(currentVersion + ".updates"); if (notBlank(propVal)) { StringBuilder sb = new StringBuilder(); String[] newVersions = propVal.split(","); for (int i = 0; i < newVersions.length; i++) { String newVersion = newVersions[i].trim(); if (i > 0) { sb.append(", "); } sb.append(newVersion); propVal = updateProps.getProperty(newVersion + ".release-notes"); if (notBlank(propVal)) { sb.append(" ["); sb.append(propVal); sb.append("]"); } } if (sb.length() > 0) { LOG.info("New update(s) found: " + sb.toString()); } } }
From source file:org.datavec.spark.transform.SparkTransformExecutor.java
/** * Returns true if the executor//w w w . ja v a 2 s . c o m * is in try catch mode. * @return */ public static boolean isTryCatch() { return Boolean.getBoolean(LOG_ERROR_PROPERTY); }
From source file:org.wso2.carbon.apimgt.rest.api.publisher.v1.impl.ApisApiServiceImpl.java
@Override public Response apisGet(Integer limit, Integer offset, String xWSO2Tenant, String query, String ifNoneMatch, Boolean expand, String accept, String tenantDomain, MessageContext messageContext) { List<API> allMatchedApis = new ArrayList<>(); APIListDTO apiListDTO;/*from ww w. ja v a 2s. c om*/ //pre-processing //setting default limit and offset values if they are not set limit = limit != null ? limit : RestApiConstants.PAGINATION_LIMIT_DEFAULT; offset = offset != null ? offset : RestApiConstants.PAGINATION_OFFSET_DEFAULT; query = query == null ? "" : query; expand = (expand != null && expand) ? true : false; try { String newSearchQuery = APIUtil.constructNewSearchQuery(query); //revert content search back to normal search by name to avoid doc result complexity and to comply with REST api practices if (newSearchQuery.startsWith(APIConstants.CONTENT_SEARCH_TYPE_PREFIX + "=")) { newSearchQuery = newSearchQuery.replace(APIConstants.CONTENT_SEARCH_TYPE_PREFIX + "=", APIConstants.NAME_TYPE_PREFIX + "="); } APIProvider apiProvider = RestApiUtil.getLoggedInUserProvider(); // We should send null as the provider, Otherwise searchAPIs will return all APIs of the provider // instead of looking at type and query String username = RestApiUtil.getLoggedInUsername(); tenantDomain = MultitenantUtils.getTenantDomain(APIUtil.replaceEmailDomainBack(username)); boolean migrationMode = Boolean.getBoolean(RestApiConstants.MIGRATION_MODE); /*if (migrationMode) { // migration flow if (!StringUtils.isEmpty(targetTenantDomain)) { tenantDomain = targetTenantDomain; } RestApiUtil.handleMigrationSpecificPermissionViolations(tenantDomain, username); }*/ Map<String, Object> result = apiProvider.searchPaginatedAPIs(newSearchQuery, tenantDomain, offset, limit, false); Set<API> apis = (Set<API>) result.get("apis"); allMatchedApis.addAll(apis); apiListDTO = APIMappingUtil.fromAPIListToDTO(allMatchedApis, expand); //Add pagination section in the response Object totalLength = result.get("length"); Integer length = 0; if (totalLength != null) { length = (Integer) totalLength; } APIMappingUtil.setPaginationParams(apiListDTO, query, offset, limit, length); if (APIConstants.APPLICATION_GZIP.equals(accept)) { try { File zippedResponse = GZIPUtils.constructZippedResponse(apiListDTO); return Response.ok().entity(zippedResponse).header("Content-Disposition", "attachment") .header("Content-Encoding", "gzip").build(); } catch (APIManagementException e) { RestApiUtil.handleInternalServerError(e.getMessage(), e, log); } } else { return Response.ok().entity(apiListDTO).build(); } } catch (APIManagementException e) { String errorMessage = "Error while retrieving APIs"; RestApiUtil.handleInternalServerError(errorMessage, e, log); } return null; }
From source file:org.carrot2.webapp.QueryProcessorServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); final ServletContext servletContext = config.getServletContext(); /*//from w w w . ja v a2 s. c om * If initialized, custom logging initializer will be here. Save its reference for * deferred initialization (for servlet APIs < 2.5). */ logInitializer = (LogInitContextListener) servletContext.getAttribute(LogInitContextListener.CONTEXT_ID); /* * Initialize global configuration and publish it. */ this.webappConfig = WebappConfig.getSingleton(servletContext); this.unknownToDefaultTransformer = new UnknownToDefaultTransformer(webappConfig, false); this.unknownToDefaultTransformerWithMaxResults = new UnknownToDefaultTransformer(webappConfig, true); /* * Initialize the controller. */ List<IResourceLocator> locators = Lists.newArrayList(); locators.add( new PrefixDecoratorLocator(new ServletContextLocator(getServletContext()), "/WEB-INF/resources/")); if (Boolean.getBoolean(ENABLE_CLASSPATH_LOCATOR)) locators.add(Location.CONTEXT_CLASS_LOADER.locator); controller = ControllerFactory.createCachingPooling(ResultsCacheModel.toClassArray(webappConfig.caches)); controller.init(ImmutableMap.<String, Object>of( AttributeUtils.getKey(DefaultLexicalDataFactory.class, "resourceLookup"), new ResourceLookup(locators)), webappConfig.components.getComponentConfigurations()); jawrUrlGenerator = new JawrUrlGenerator(servletContext); }
From source file:uk.ac.diamond.scisoft.JythonCreator.java
private void initialiseInterpreter(IProgressMonitor monitor) throws Exception { /*/* w w w . j a va 2 s. c o m*/ * The layout of plugins can vary between where a built product and * a product run from Ellipse: * * 1) Built product * . this class in plugins/a.b.c * . flat hierarchy with jars and expanded bundles (with jars in a.b.c and a.b.c/jars) * 2) Ellipse run * . flagged by RUN_IN_ECLIPSE property * . source code can be in workspace/plugins or workspace_git (this class is in workspace_git/blah.git/a.b.c) * * Jython lives in diamond-jython.git in uk.ac.diamond.jython (after being moved from uk.ac.gda.libs) */ logger.debug("Initialising the Jython interpreter setup"); boolean isRunningInEclipse = Boolean.getBoolean(RUN_IN_ECLIPSE); // Horrible Hack warning: This code is copied from parts of Pydev to set up the interpreter and save it. { File pluginsDir = JythonPath.getPluginsDirectory(isRunningInEclipse); // plugins or git workspace directory if (pluginsDir == null) { logger.error("Failed to find plugins directory!"); return; } logger.debug("Plugins directory is {}", pluginsDir); // Set cache directory to something not in the installation directory IPreferenceStore pyStore = PydevPrefs.getPreferenceStore(); String cachePath = pyStore.getString(IInterpreterManager.JYTHON_CACHE_DIR); if (cachePath == null || cachePath.length() == 0) { final String workspace = ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString(); final File cacheDir = new File(workspace, ".jython_cachedir"); if (!cacheDir.exists()) cacheDir.mkdirs(); cachePath = cacheDir.getAbsolutePath(); pyStore.setValue(IInterpreterManager.JYTHON_CACHE_DIR, cacheDir.getAbsolutePath()); } System.setProperty("python.cachedir", cachePath); // check for the existence of this standard pydev script final File script = PydevPlugin.getScriptWithinPySrc("interpreterInfo.py"); if (!script.exists()) { logger.error("The file specified does not exist: {} ", script); throw new RuntimeException("The file specified does not exist: " + script); } logger.debug("Script path = {}", script.getAbsolutePath()); File java = JavaVmLocationFinder.findDefaultJavaExecutable(); logger.debug("Using java: {}", java); String javaPath; try { javaPath = java.getCanonicalPath(); } catch (IOException e) { logger.warn("Could not resolve default Java path so resorting to PATH", e); javaPath = "java"; } //If the interpreter directory comes back unset, we don't want to go any further. File interpreterDirectory = JythonPath.getInterpreterDirectory(isRunningInEclipse); if (interpreterDirectory == null) { logger.error("Interpreter directory not set. Cannot find interpreter."); return; } String executable = new File(interpreterDirectory, JythonPath.getJythonExecutableName()) .getAbsolutePath(); if (!(new File(executable)).exists()) { logger.error("Failed to find jython jar at all"); return; } logger.debug("executable path = {}", executable); String[] cmdarray = { javaPath, "-Xmx64m", // "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000", "-Dpython.cachedir.skip=true", // this works in Windows "-jar", executable, FileUtils.getFileAbsolutePath(script) }; File workingDir = new File(System.getProperty("java.io.tmpdir")); // logger.debug("Cache and working dirs are {} and {}", cachePath, workingDir); IPythonNature nature = null; String outputString = ""; try { Tuple<Process, String> outTuple = new SimpleRunner().run(cmdarray, workingDir, nature, monitor); outputString = IOUtils.toString(outTuple.o1.getInputStream()); } catch (IOException e1) { logger.error("Could not parse output from running interpreterInfo.py in Jython", e1); } catch (Exception e2) { logger.error("Something went wrong in running interpreterInfo.py in Jython", e2); } logger.debug("Output String is {}", outputString); // this is the main info object which contains the environment data InterpreterInfo info = null; try { // HACK Otherwise Pydev shows a dialog to the user. ModulesManagerWithBuild.IN_TESTS = true; info = InterpreterInfo.fromString(outputString, false); } catch (Exception e) { logger.error("InterpreterInfo.fromString(outTup.o1) has failed in pydev setup with exception"); logger.error("{}", e); } finally { ModulesManagerWithBuild.IN_TESTS = false; } if (info == null) { logger.error("pydev info is set to null"); return; } // the executable is the jar itself info.executableOrJar = executable; final String osName = System.getProperty("os.name"); final boolean isMacOSX = osName.contains("Mac OS X"); final String pathEnv = isMacOSX ? "DYLD_LIBRARY_PATH" : (osName.contains("Windows") ? "PATH" : "LD_LIBRARY_PATH"); logPaths("Library paths:", System.getenv(pathEnv)); logPaths("Class paths:", System.getProperty("java.library.path")); // set of python paths Set<String> pyPaths = new TreeSet<String>(); // we have to find the jars before we restore the compiled libs final List<File> jars = JavaVmLocationFinder.findDefaultJavaJars(); for (File jar : jars) { if (!pyPaths.add(jar.getAbsolutePath())) { logger.warn("File {} already there!", jar.getName()); } } Set<String> extraPlugins = new HashSet<String>(7); // Find all packages that contribute to loader factory Set<String> loaderPlugins = LoaderFactoryStartup.getPlugins(); if (loaderPlugins != null) { logger.debug("Extra plugins: {}", loaderPlugins); extraPlugins.addAll(loaderPlugins); } // We add the SWT plugins so that the plotting system works in Jython mode. // The class IRemotePlottingSystem ends up referencing color so SWT plugins are // required to expose IRemotePlottingSystem to the scripting layer. createSwtEntries(extraPlugins); //Get Jython paths for DAWN libs pyPaths.addAll(JythonPath.assembleJyPaths(pluginsDir, extraPlugins, isRunningInEclipse)); //Also need allPluginsDirs for later parts final List<File> allPluginDirs = JythonPath.findDirs(pluginsDir, extraPlugins, isRunningInEclipse); Set<String> removals = new HashSet<String>(); for (String s : info.libs) { String ls = s.toLowerCase(); for (String r : removedLibEndings) { if (ls.endsWith(r)) { removals.add(s); break; } } } info.libs.removeAll(removals); info.libs.addAll(pyPaths); // now set up the dynamic library environment File libraryDir = new File(pluginsDir.getParent(), "lib"); Set<String> paths = new LinkedHashSet<String>(); if (!isRunningInEclipse && libraryDir.exists()) { paths.add(libraryDir.getAbsolutePath()); } else { // check each plugin directory's for dynamic libraries String osarch = Platform.getOS() + "-" + Platform.getOSArch(); logger.debug("Using OS and ARCH: {}", osarch); for (File dir : allPluginDirs) { File d = new File(dir, "lib"); if (d.isDirectory()) { d = new File(d, osarch); if (d.isDirectory()) { if (paths.add(d.getAbsolutePath())) logger.debug("Adding library path: {}", d); } } } } // add from environment variables String ldPath = System.getenv(pathEnv); if (ldPath != null) { for (String p : ldPath.split(File.pathSeparator)) { paths.add(p); } } StringBuilder allPaths = new StringBuilder(); for (String p : paths) { allPaths.append(p); allPaths.append(File.pathSeparatorChar); } String libraryPath = allPaths.length() > 0 ? allPaths.substring(0, allPaths.length() - 1) : null; PyDevAdditionalInterpreterSettings settings = new PyDevAdditionalInterpreterSettings(); Collection<String> envVariables = settings.getAdditionalEnvVariables(); if (libraryPath == null) { logger.warn("{} not defined as no library paths were found!" + pathEnv); } else { logPaths("Setting " + pathEnv + " for dynamic libraries", libraryPath); envVariables.add(pathEnv + "=" + libraryPath); } if (isMacOSX) { // do we also add DYLD_VERSIONED_LIBRARY_PATH and DYLD_ROOT_PATH? String fbPathEnv = "DYLD_FALLBACK_LIBRARY_PATH"; String fbPath = System.getenv(fbPathEnv); if (fbPath == null) { logger.debug("{} not defined" + fbPathEnv); } else { logPaths("For Mac OS X, setting " + fbPathEnv + " for dynamic libraries", fbPath); envVariables.add(fbPathEnv + "=" + fbPath); } } String[] envVarsAlreadyIn = info.getEnvVariables(); if (envVarsAlreadyIn != null) { envVariables.addAll(Arrays.asList(envVarsAlreadyIn)); } // add custom loader extensions to work around Jython not being OSGI Set<String> loaderExts = LoaderFactoryStartup.getExtensions(); if (loaderExts != null) { String ev = "LOADER_FACTORY_EXTENSIONS="; for (String e : loaderExts) { ev += e + "|"; } envVariables.add(ev); } info.setEnvVariables(envVariables.toArray(new String[envVariables.size()])); // java, java.lang, etc should be found now info.restoreCompiledLibs(monitor); info.setName(INTERPRETER_NAME); logger.debug("Finalising the Jython interpreter manager"); final JythonInterpreterManager man = (JythonInterpreterManager) PydevPlugin .getJythonInterpreterManager(); HashSet<String> set = new HashSet<String>(); // Note, despite argument in PyDev being called interpreterNamesToRestore // in this context that name is the exe. // Pydev doesn't allow two different interpreters to be configured for the same // executable path so in some contexts the executable is the unique identifier (as it is here) set.add(executable); // Attempt to update existing Jython configuration IInterpreterInfo[] interpreterInfos = man.getInterpreterInfos(); IInterpreterInfo existingInfo = null; try { existingInfo = man.getInterpreterInfo(executable, monitor); } catch (MisconfigurationException e) { // MisconfigurationException thrown if executable not found } if (existingInfo != null && existingInfo.toString().equals(info.toString())) { logger.debug("Jython interpreter already exists with exact settings"); } else { // prune existing interpreters with same name Map<String, IInterpreterInfo> infoMap = new LinkedHashMap<String, IInterpreterInfo>(); for (IInterpreterInfo i : interpreterInfos) { infoMap.put(i.getName(), i); } if (existingInfo == null) { if (infoMap.containsKey(INTERPRETER_NAME)) { existingInfo = infoMap.get(INTERPRETER_NAME); logger.debug("Found interpreter of same name"); } } if (existingInfo == null) { logger.debug("Adding interpreter as an additional interpreter"); } else { logger.debug("Updating interpreter which was previously created"); } infoMap.put(INTERPRETER_NAME, info); try { IInterpreterInfo[] infos = new IInterpreterInfo[infoMap.size()]; int j = 0; for (String i : infoMap.keySet()) { infos[j++] = infoMap.get(i); } try { man.setInfos(infos, set, monitor); } catch (Throwable swallowed) { // Occurs with a clean workspace. } } catch (RuntimeException e) { logger.warn("Problem with restoring info"); } } logger.debug("Finished the Jython interpreter setup"); } }
From source file:org.sonar.plugins.php.pmd.PhpmdConfiguration.java
/** * @see org.sonar.plugins.php.core.AbstractPhpPluginConfiguration #shouldAnalyzeOnlyDefault() *//* w w w . j a va 2 s . c o m*/ @Override protected boolean shouldAnalyzeOnlyDefault() { return Boolean.getBoolean(PHPMD_DEFAULT_ANALYZE_ONLY); }
From source file:com.netflix.config.ConfigurationManager.java
/** * Get the current system wide configuration. If there has not been set, it will return a default * {@link ConcurrentCompositeConfiguration} which contains a SystemConfiguration from Apache Commons * Configuration and a {@link DynamicURLConfiguration}. *//*from www. j a v a 2 s . c om*/ public static AbstractConfiguration getConfigInstance() { if (instance == null) { synchronized (ConfigurationManager.class) { if (instance == null) { instance = getConfigInstance(Boolean.getBoolean(DynamicPropertyFactory.DISABLE_DEFAULT_CONFIG)); } } } return instance; }
From source file:io.adeptj.runtime.osgi.FrameworkManager.java
private void provisionBundles(BundleContext systemBundleContext) throws IOException { // config directory will not yet be created if framework is being provisioned first time. if (!Boolean.getBoolean("provision.bundles.explicitly") && Paths.get(Configs.INSTANCE.felix().getString(CFG_KEY_FELIX_CM_DIR)).toFile().exists()) { LOGGER.info("As per configuration, bundles provisioning is skipped on server restart!!"); } else {//w ww.j a v a 2 s .c om Bundles.provisionBundles(systemBundleContext); } }
From source file:org.commonreality.mina.service.ClientService.java
protected ExecutorService createIOExecutor(ThreadFactory factory) { if (Boolean.getBoolean("participant.useSharedThreads")) return getSharedIOExecutor(factory); int max = Integer.parseInt(System.getProperty("participant.ioMaxThreads", "1")); return new OrderedThreadPoolExecutor(1, max, 10000, TimeUnit.MILLISECONDS, factory); }
From source file:org.gradle.util.DeprecationLogger.java
private static boolean isTraceLoggingEnabled() { return Boolean.getBoolean(ORG_GRADLE_DEPRECATION_TRACE_PROPERTY_NAME) || LOG_TRACE.get(); }