List of usage examples for java.lang Integer getInteger
public static Integer getInteger(String nm, Integer val)
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Access the http://{host}/jbosstest/restricted/SecureServlet *///from ww w .j a v a2 s .co m public void testSecureServletAndUnsecureAccess() throws Exception { getLog().info("+++ testSecureServletAndUnsecureAccess"); URL url = new URL(baseURL + "jbosstest/restricted/SecureServlet"); getLog().info("Accessing SecureServlet with valid login"); HttpUtils.accessURL(url); String baseURL2 = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url2 = new URL(baseURL2 + "jbosstest/restricted/UnsecureEJBServlet"); getLog().info("Accessing SecureServlet with no login"); HttpUtils.accessURL(url2, REALM, HttpURLConnection.HTTP_UNAUTHORIZED); }
From source file:Utilities.java
/** * Returns the usable area of the screen where applications can place its * windows. The method subtracts from the screen the area of taskbars, * system menus and the like./*from www . j a v a2s . c o m*/ * * @param gconf the GraphicsConfiguration of the monitor * @return the rectangle of the screen where one can place windows * * @since 2.5 */ public static Rectangle getUsableScreenBounds(GraphicsConfiguration gconf) { if (gconf == null) { gconf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration(); } Rectangle bounds = new Rectangle(gconf.getBounds()); String str; str = System.getProperty("netbeans.screen.insets"); // NOI18N if (str != null) { StringTokenizer st = new StringTokenizer(str, ", "); // NOI18N if (st.countTokens() == 4) { try { bounds.y = Integer.parseInt(st.nextToken()); bounds.x = Integer.parseInt(st.nextToken()); bounds.height -= (bounds.y + Integer.parseInt(st.nextToken())); bounds.width -= (bounds.x + Integer.parseInt(st.nextToken())); } catch (NumberFormatException ex) { Logger.getAnonymousLogger().log(Level.WARNING, null, ex); } } return bounds; } str = System.getProperty("netbeans.taskbar.height"); // NOI18N if (str != null) { bounds.height -= Integer.getInteger(str, 0).intValue(); return bounds; } try { Toolkit toolkit = Toolkit.getDefaultToolkit(); Insets insets = toolkit.getScreenInsets(gconf); bounds.y += insets.top; bounds.x += insets.left; bounds.height -= (insets.top + insets.bottom); bounds.width -= (insets.left + insets.right); } catch (Exception ex) { Logger.getAnonymousLogger().log(Level.WARNING, null, ex); } return bounds; }
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Access the http://{host}/jbosstest/restricted/SecureServlet *///w ww. j a v a 2 s.com public void testSecureServletWithBadPass() throws Exception { String baseURL = "http://jduke:badpass@" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "jbosstest/restricted/SecureServlet"); HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_UNAUTHORIZED); }
From source file:org.eclipse.mdht.uml.cda.core.util.CDACommonUtils.java
/** * @param element/*from w w w . j av a 2 s . co m*/ * @param fullSection * whether to return the full section number or only the last digit * @return */ static public String getPDFSection(Element element, boolean fullSection, boolean level2) { int incr = Integer.getInteger("MDHT_SECTION_INCREMENT", 0); if (incr == 0 && element.eResource() != null && element.eResource().getResourceSet() != null) { Resource resource = element.eResource().getResourceSet().getResources().get(0); String uri = resource.getURI().toString(); int index = uri.indexOf(".model/"); if (index != -1) { try { uri = uri.substring(0, index) + ".doc/dita/spec-book.ditamap"; InputStream inputStream = new URL(uri).openConnection().getInputStream(); String specBook = CDACommonUtils.toString(inputStream); index = specBook.indexOf("<chapter format=\"ditamap\" href=\"content/content.ditamap\"/>"); if (index != -1) { incr = StringUtils.countMatches(specBook.substring(0, index), "<chapter") - 1; } } catch (Exception e) { System.err.println(e.getMessage()); } } } String result = ""; EObject eObject = element; while (eObject != null && !(eObject instanceof Package)) { String step = "?"; if (eObject instanceof Class) { Class class1 = (Class) eObject; int mainSection = getMainSection(class1); if (mainSection != -1) { step = (mainSection + incr) + "." + (getCDAContents(class1).indexOf(class1) + 1); if (!fullSection || level2) { return step + " " + CDACommonUtils.getBusinessName(class1); } else if (fullSection) { result = step + "." + result; break; } } else { Property property = getOverallPropertyReference(class1); if (property != null) { step = getPropertyStep(getClassReference(property), property); } } } else if (eObject instanceof Constraint && CDACommonUtils.getParentingProperty((Constraint) eObject) != null) { Property prop = CDACommonUtils.getParentingProperty((Constraint) eObject); if (prop.getType() instanceof Class && getMainSection((Class) prop.getType()) == -1) { Class class1 = (Class) prop.getType(); step = getPropertyStep(class1, class1); } else { step = getCustomizedBulletItem(prop, 0); } eObject = prop; result = step + "." + result; continue; } else if (eObject instanceof NamedElement && getContainerReference(eObject) instanceof Class) { NamedElement property = (NamedElement) eObject; Class parentClass = (Class) getContainerReference(eObject); step = getPropertyStep(parentClass, property); } else if (eObject instanceof Enumeration && getContainerReference(eObject) instanceof Package) { Package package1 = (Package) getContainerReference(eObject); Enumeration enumeration = (Enumeration) eObject; return "6." + (package1.getPackagedElements().indexOf(eObject) + 1) + " " + enumeration.getName(); } else if (eObject instanceof EnumerationLiteral) { EnumerationLiteral enumerationLiteral = (EnumerationLiteral) eObject; return enumerationLiteral.getName(); } if (!fullSection) { return step + "."; } result = step + "." + result; if (!fullSection) { return step; } eObject = getContainerReference(eObject); } return result.endsWith(".") ? result.substring(0, result.length() - 1) : result; }
From source file:com.microsoft.tfs.core.config.httpclient.DefaultHTTPClientFactory.java
/** * {@inheritDoc}/*w w w .j a va 2 s. com*/ */ @Override public HttpConnectionManager createConnectionManager(final ConnectionInstanceData connectionInstanceData) { final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); final HttpConnectionManagerParams params = connectionManager.getParams(); /* * The max total connection limit is higher than the per-host limit to * account for multiple connections (to different TFS servers) that * share an HttpClient. */ params.setMaxTotalConnections( Integer.getInteger(MAX_TOTAL_CONNECTIONS_PROPERTY, MAX_TOTAL_CONNECTIONS_DEFAULT)); params.setMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION, Integer.getInteger(MAX_CONNECTIONS_PER_HOST_PROPERTY, MAX_CONNECTIONS_PER_HOST_DEFAULT)); /* * Set the connection timeout. */ params.setConnectionTimeout( Integer.getInteger(CONNECT_TIMEOUT_SECONDS_PROPERTY, CONNECT_TIMEOUT_SECONDS_DEFAULT) * 1000); return connectionManager; }
From source file:org.elasticsearch.hadoop.rest.commonshttp.CommonsHttpTransport.java
private Object[] setupHttpProxy(Settings settings, HostConfiguration hostConfig) { // return HostConfiguration + HttpState Object[] results = new Object[2]; results[0] = hostConfig;/*from w w w. j a v a 2 s. c o m*/ // set proxy settings String proxyHost = null; int proxyPort = -1; if (settings.getNetworkHttpUseSystemProperties()) { proxyHost = System.getProperty("http.proxyHost"); proxyPort = Integer.getInteger("http.proxyPort", -1); } if (StringUtils.hasText(settings.getNetworkProxyHttpHost())) { proxyHost = settings.getNetworkProxyHttpHost(); } if (settings.getNetworkProxyHttpPort() > 0) { proxyPort = settings.getNetworkProxyHttpPort(); } if (StringUtils.hasText(proxyHost)) { hostConfig.setProxy(proxyHost, proxyPort); proxyInfo = proxyInfo.concat(String.format("[HTTP proxy %s:%s]", proxyHost, proxyPort)); // client is not yet initialized so postpone state if (StringUtils.hasText(settings.getNetworkProxyHttpUser())) { if (!StringUtils.hasText(settings.getNetworkProxyHttpPass())) { log.warn(String.format( "HTTP proxy user specified but no/empty password defined - double check the [%s] property", ConfigurationOptions.ES_NET_PROXY_HTTP_PASS)); } HttpState state = new HttpState(); state.setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials( settings.getNetworkProxyHttpUser(), settings.getNetworkProxyHttpPass())); // client is not yet initialized so simply save the object for later results[1] = state; } if (log.isDebugEnabled()) { if (StringUtils.hasText(settings.getNetworkProxyHttpUser())) { log.debug(String.format("Using authenticated HTTP proxy [%s:%s]", proxyHost, proxyPort)); } else { log.debug(String.format("Using HTTP proxy [%s:%s]", proxyHost, proxyPort)); } } } return results; }
From source file:org.jboss.test.web.test.WebIntegrationUnitTestCase.java
/** Access the http://{host}/jbosstest/restricted/SecureServlet *//*from w w w . j a v a 2 s .co m*/ public void testSecureServletWithNoLogin() throws Exception { String baseURL = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + '/'; URL url = new URL(baseURL + "jbosstest/restricted/SecureServlet"); HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_UNAUTHORIZED); }
From source file:com.adeptj.runtime.server.Server.java
private Builder workerOptions(Builder builder) { if (Environment.isProd()) { // Note : For a 16 core system, number of worker task core and max threads will be. // 1. core task thread: 128 (16[cores] * 8) // 2. max task thread: 128 * 2 = 256 // Default settings would have set the following. // 1. core task thread: 128 (16[cores] * 8) // 2. max task thread: 128 (Same as core task thread) Config workerOptions = Objects.requireNonNull(this.cfgReference.get()) .getConfig(ServerConstants.KEY_WORKER_OPTIONS); // defaults to 64 int cfgCoreTaskThreads = workerOptions.getInt(ServerConstants.KEY_WORKER_TASK_CORE_THREADS); LOGGER.info("Configured worker task core threads: [{}]", cfgCoreTaskThreads); int availableProcessors = Runtime.getRuntime().availableProcessors(); LOGGER.info("No. of CPU available: [{}]", availableProcessors); int calcCoreTaskThreads = availableProcessors * Integer.getInteger(ServerConstants.SYS_PROP_WORKER_TASK_THREAD_MULTIPLIER, ServerConstants.WORKER_TASK_THREAD_MULTIPLIER); LOGGER.info("Calculated worker task core threads: [{}]", calcCoreTaskThreads); builder.setWorkerOption(Options.WORKER_TASK_CORE_THREADS, calcCoreTaskThreads > cfgCoreTaskThreads ? calcCoreTaskThreads : cfgCoreTaskThreads); // defaults to double of [worker-task-core-threads] i.e 128 int cfgMaxTaskThreads = workerOptions.getInt(ServerConstants.KEY_WORKER_TASK_MAX_THREADS); LOGGER.info("Configured worker task max threads: [{}]", cfgCoreTaskThreads); int calcMaxTaskThreads = calcCoreTaskThreads * Integer.getInteger(ServerConstants.SYS_PROP_SYS_TASK_THREAD_MULTIPLIER, ServerConstants.SYS_TASK_THREAD_MULTIPLIER); LOGGER.info("Calculated worker task max threads: [{}]", cfgCoreTaskThreads); builder.setWorkerOption(Options.WORKER_TASK_MAX_THREADS, calcMaxTaskThreads > cfgMaxTaskThreads ? calcMaxTaskThreads : cfgMaxTaskThreads); LOGGER.info("Undertow Worker Options optimized for AdeptJ Runtime [PROD] mode."); }/* w w w .j av a2 s . c o m*/ return builder; }
From source file:org.apache.archiva.metadata.repository.jcr.RepositoryFactory.java
public Repository createRepository() throws IOException, InvalidFileStoreVersionException { createExecutor();/*from w ww .j a v a 2s. co m*/ if (SEGMENT_FILE_TYPE == storeType) { fileStore = FileStoreBuilder.fileStoreBuilder(repositoryPath.toFile()).build(); nodeStore = SegmentNodeStoreBuilders.builder(fileStore) // .withStatisticsProvider(StatisticsProvider.NOOP) // .build(); } else if (IN_MEMORY_TYPE == storeType) { nodeStore = null; } else { throw new IllegalArgumentException("Store type " + storeType + " not recognized"); } Oak oak = nodeStore == null ? new Oak() : new Oak(nodeStore); oak.with(new RepositoryInitializer() { @Override public void initialize(@Nonnull NodeBuilder root) { log.info("Creating index "); NodeBuilder lucene = IndexUtils.getOrCreateOakIndex(root).child("lucene"); lucene.setProperty(JcrConstants.JCR_PRIMARYTYPE, "oak:QueryIndexDefinition", Type.NAME); lucene.setProperty("compatVersion", 2); lucene.setProperty("type", "lucene"); // lucene.setProperty("async", "async"); lucene.setProperty(INCLUDE_PROPERTY_TYPES, ImmutableSet.of("String"), Type.STRINGS); // lucene.setProperty("refresh",true); lucene.setProperty("async", ImmutableSet.of("async", "sync"), Type.STRINGS); NodeBuilder rules = lucene.child("indexRules").setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); rules.setProperty(":childOrder", ImmutableSet.of("archiva:projectVersion", // "archiva:artifact", // "archiva:facet", // "archiva:namespace", // "archiva:project"), // Type.STRINGS); NodeBuilder allProps = rules.child("archiva:projectVersion") // .child("properties") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME) // .setProperty(":childOrder", ImmutableSet.of("allProps"), Type.STRINGS) // .setProperty("indexNodeName", true) // .child("allProps") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); allProps.setProperty("name", ".*"); allProps.setProperty("isRegexp", true); allProps.setProperty("nodeScopeIndex", true); allProps.setProperty("index", true); allProps.setProperty("analyzed", true); // allProps.setProperty("propertyIndex",true); allProps = rules.child("archiva:artifact") // .child("properties") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME) // .setProperty(":childOrder", ImmutableSet.of("allProps"), Type.STRINGS) // .setProperty("indexNodeName", true).child("allProps") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); allProps.setProperty("name", ".*"); allProps.setProperty("isRegexp", true); allProps.setProperty("nodeScopeIndex", true); allProps.setProperty("index", true); allProps.setProperty("analyzed", true); allProps = rules.child("archiva:facet") // .child("properties") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME) // .setProperty(":childOrder", ImmutableSet.of("allProps"), Type.STRINGS) // .setProperty("indexNodeName", true) // .child("allProps") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); allProps.setProperty("name", ".*"); allProps.setProperty("isRegexp", true); allProps.setProperty("nodeScopeIndex", true); allProps.setProperty("index", true); allProps.setProperty("analyzed", true); allProps = rules.child("archiva:namespace") // .child("properties") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME) // .setProperty(":childOrder", ImmutableSet.of("allProps"), Type.STRINGS) // .setProperty("indexNodeName", true) // .child("allProps") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); allProps.setProperty("name", ".*"); allProps.setProperty("isRegexp", true); allProps.setProperty("nodeScopeIndex", true); allProps.setProperty("index", true); allProps.setProperty("analyzed", true); allProps = rules.child("archiva:project") // .child("properties") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:unstructured", Type.NAME) // .setProperty(":childOrder", ImmutableSet.of("allProps"), Type.STRINGS) // .setProperty("indexNodeName", true) // .child("allProps") // .setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME); allProps.setProperty("name", ".*"); allProps.setProperty("isRegexp", true); allProps.setProperty("nodeScopeIndex", true); allProps.setProperty("index", true); allProps.setProperty("analyzed", true); log.info("Index: {} myIndex {}", lucene, lucene.getChildNode("myIndex")); log.info("myIndex {}", lucene.getChildNode("myIndex").getProperties()); // IndexUtils.createIndexDefinition( ) } }); StatisticsProvider statsProvider = StatisticsProvider.NOOP; int queueSize = Integer.getInteger("queueSize", 10000); Path indexDir = Files.createTempDirectory("archiva_index"); log.info("Queue Index {}", indexDir.toString()); IndexCopier indexCopier = new IndexCopier(executorService, indexDir.toFile(), true); NRTIndexFactory nrtIndexFactory = new NRTIndexFactory(indexCopier, statsProvider); MountInfoProvider mountInfoProvider = Mounts.defaultMountInfoProvider(); IndexTracker tracker = new IndexTracker(new DefaultIndexReaderFactory(mountInfoProvider, indexCopier), nrtIndexFactory); DocumentQueue queue = new DocumentQueue(queueSize, tracker, executorService, statsProvider); LocalIndexObserver localIndexObserver = new LocalIndexObserver(queue, statsProvider); LuceneIndexProvider provider = new LuceneIndexProvider(tracker); // ExternalObserverBuilder builder = new ExternalObserverBuilder(queue, tracker, statsProvider, // executorService, queueSize); // Observer observer = builder.build(); // builder.getBackgroundObserver(); LuceneIndexEditorProvider editorProvider = // new LuceneIndexEditorProvider(null, tracker, // new ExtractedTextCache(0, 0), // null, mountInfoProvider); editorProvider.setIndexingQueue(queue); log.info("Oak: {} with nodeStore {}", oak, nodeStore); Jcr jcr = new Jcr(oak).with(editorProvider) // .with((Observer) provider) // .with(localIndexObserver) // .with(observer) .with((QueryIndexProvider) provider); // //.withAsyncIndexing( "async", 5 ); StopWatch stopWatch = new StopWatch(); stopWatch.start(); Repository r = jcr.createRepository(); stopWatch.stop(); log.info("time to create jcr repository: {} ms", stopWatch.getTime()); // try // { // Thread.currentThread().sleep( 1000 ); // } // catch ( InterruptedException e ) // { // log.error( e.getMessage(), e ); // } return r; }
From source file:org.apache.geode.distributed.LocatorLauncher.java
private static Integer getDefaultLocatorPort() { return Integer.getInteger(DistributionLocator.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, DistributionLocator.DEFAULT_LOCATOR_PORT); }