List of usage examples for java.util.concurrent Executors newCachedThreadPool
public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
From source file:com.ibm.og.client.ApacheClient.java
private ApacheClient(final Builder builder) { this.connectTimeout = builder.connectTimeout; this.soTimeout = builder.soTimeout; this.soReuseAddress = builder.soReuseAddress; this.soLinger = builder.soLinger; this.soKeepAlive = builder.soKeepAlive; this.tcpNoDelay = builder.tcpNoDelay; this.soSndBuf = builder.soSndBuf; this.soRcvBuf = builder.soRcvBuf; this.persistentConnections = builder.persistentConnections; this.validateAfterInactivity = builder.validateAfterInactivity; this.maxIdleTime = builder.maxIdleTime; this.chunkedEncoding = builder.chunkedEncoding; this.expectContinue = builder.expectContinue; this.waitForContinue = builder.waitForContinue; this.retryCount = builder.retryCount; this.requestSentRetry = builder.requestSentRetry; // TODO validate protocol values final List<String> protocols = builder.protocols; if (protocols != null) { this.protocols = ImmutableList.copyOf(protocols); } else {//from w w w . j a va 2 s .co m this.protocols = null; } final List<String> cipherSuites = builder.cipherSuites; if (cipherSuites != null) { this.cipherSuites = ImmutableList.copyOf(cipherSuites); } else { this.cipherSuites = null; } final String keyStore = builder.keyStore; if (keyStore != null) { this.keyStore = new File(keyStore); checkArgument(this.keyStore.exists(), "keyStore does not exist [%s]", this.keyStore); } else { this.keyStore = null; } this.keyStorePassword = builder.keyStorePassword; if (this.keyStorePassword != null) { checkArgument(this.keyStore != null, "if keyStorePassword is != null, keyStore must be != null"); } this.keyPassword = builder.keyPassword; if (this.keyPassword != null) { checkArgument(this.keyStore != null, "if keyPassword is != null, keyStore must be != null"); } final String trustStore = builder.trustStore; if (trustStore != null) { this.trustStore = new File(trustStore); checkArgument(this.trustStore.exists(), "trustStore does not exist [%s]", this.trustStore); } else { this.trustStore = null; } this.trustStorePassword = builder.trustStorePassword; if (this.trustStorePassword != null) { checkArgument(this.trustStore != null, "if trustStorePassword is != null, trustStore must be != null"); } this.trustSelfSignedCertificates = builder.trustSelfSignedCertificates; this.dnsCacheTtl = builder.dnsCacheTtl; this.dnsCacheNegativeTtl = builder.dnsCacheNegativeTtl; this.authentication = checkNotNull(builder.authentication); this.userAgent = builder.userAgent; this.writeThroughput = builder.writeThroughput; this.readThroughput = builder.readThroughput; this.responseBodyConsumers = ImmutableMap.copyOf(builder.responseBodyConsumers); this.running = true; this.abortedRequestsAtShutdown = new AtomicInteger(); final ThreadFactory fac = new ThreadFactoryBuilder().setNameFormat("client-%d").build(); this.executorService = MoreExecutors.listeningDecorator(Executors.newCachedThreadPool(fac)); this.gson = createGson(); // perform checks on instance fields rather than builder fields checkArgument(this.connectTimeout >= 0, "connectTimeout must be >= 0 [%s]", this.connectTimeout); checkArgument(this.soTimeout >= 0, "soTimeout must be >= 0 [%s]", this.soTimeout); checkArgument(this.soLinger >= -1, "soLinger must be >= -1 [%s]", this.soLinger); checkArgument(this.soSndBuf >= 0, "soSndBuf must be >= 0 [%s]", this.soSndBuf); checkArgument(this.soRcvBuf >= 0, "soRcvBuf must be >= 0 [%s]", this.soRcvBuf); checkArgument(this.validateAfterInactivity > 0, "validateAfterInactivity must be > 0 [%s]", this.validateAfterInactivity); checkArgument(this.maxIdleTime > 0, "maxIdleTime must be > 0 [%s]", this.maxIdleTime); checkArgument(this.waitForContinue > 0, "waitForContinue must be > 0 [%s]", this.waitForContinue); checkArgument(this.retryCount >= 0, "retryCount must be >= 0 [%s]", this.retryCount); checkArgument(this.dnsCacheTtl >= -1, "dnsCacheTtl must be >= -1 [%s]", this.dnsCacheTtl); checkArgument(this.dnsCacheNegativeTtl >= -1, "dnsCacheNegativeTtl must be >= -1 [%s]", this.dnsCacheNegativeTtl); checkArgument(this.writeThroughput >= 0, "writeThroughput must be >= 0 [%s]", this.writeThroughput); checkArgument(this.readThroughput >= 0, "readThroughput must be >= 0 [%s]", this.readThroughput); Security.setProperty("networkaddress.cache.ttl", String.valueOf(this.dnsCacheTtl)); Security.setProperty("networkaddress.cache.negative.ttl", String.valueOf(this.dnsCacheNegativeTtl)); this.client = createClient(); }
From source file:org.graylog2.jersey.container.netty.NettyContainerTest.java
private ServerBootstrap getServerBootstrap() { final ExecutorService bossExecutor = Executors .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("restapi-boss-%d").build()); final ExecutorService workerExecutor = Executors .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("restapi-worker-%d").build()); return new ServerBootstrap(new NioServerSocketChannelFactory(bossExecutor, workerExecutor)); }
From source file:com.linkedin.databus2.core.container.netty.ServerContainer.java
public ServerContainer(StaticConfig config, ByteOrder byteOrder) throws IOException, InvalidConfigException, DatabusException { _containerStaticConfig = config;//w ww. j a va2 s. c o m _baseDir = config.getContainerBaseDir(); //by default we have 5ms timeout precision _networkTimeoutTimer = new HashedWheelTimer(5, TimeUnit.MILLISECONDS); _processorRegistry = new RequestProcessorRegistry(); _commandsRegistry = new CommandsRegistry(); _mbeanServer = _containerStaticConfig.getOrCreateMBeanServer(); _containerStaticConfig.getRuntime().setManagedInstance(this); _dbusEventByteOrder = byteOrder; //TODO (DDSDBUS-105) HIGH we have to use the builder here instead of a read-only copy because we have a //bootstrapping circular reference RuntimeConfig -> ContainerStatisticsCollector.RuntimeConfig // -> ContainerStatisticsCollector -> RuntimeConfig RuntimeConfigBuilder runtimeConfig = _containerStaticConfig.getRuntime(); //ExecutorConfigBuilder ioThreadsConfig = runtimeConfig.getIoExecutor(); /* commented out because of deadlock problems * _ioExecutorService = new ThreadPoolExecutor( ioThreadsConfig.getCoreThreadsNum(), ioThreadsConfig.getMaxThreadsNum(), ioThreadsConfig.getKeepAliveMs(), TimeUnit.MILLISECONDS, ioThreadsConfig.getMaxQueueSize() <= 0 ? new LinkedBlockingQueue<Runnable>() : new ArrayBlockingQueue<Runnable>(ioThreadsConfig.getMaxQueueSize()));*/ _ioExecutorService = Executors .newCachedThreadPool(new NamedThreadFactory("io" + _containerStaticConfig.getId())); _bossExecutorService = Executors .newCachedThreadPool(new NamedThreadFactory("boss" + _containerStaticConfig.getId())); _defaultExecutorService = new OrderedMemoryAwareThreadPoolExecutor( runtimeConfig.getDefaultExecutor().getMaxThreadsNum(), 0, 0, runtimeConfig.getDefaultExecutor().getKeepAliveMs(), TimeUnit.MILLISECONDS, new NamedThreadFactory("worker" + _containerStaticConfig.getId())); _containerStatsCollector = _containerStaticConfig.getOrCreateContainerStatsCollector(); DbusEventsStatisticsCollector inboundEventStatisticsCollector = new AggregatedDbusEventsStatisticsCollector( getContainerStaticConfig().getId(), "eventsInbound", true, true, getMbeanServer()); DbusEventsStatisticsCollector outboundEventStatisticsCollector = new AggregatedDbusEventsStatisticsCollector( getContainerStaticConfig().getId(), "eventsOutbound", true, true, getMbeanServer()); _inBoundStatsCollectors = new StatsCollectors<DbusEventsStatisticsCollector>( inboundEventStatisticsCollector); _outBoundStatsCollectors = new StatsCollectors<DbusEventsStatisticsCollector>( outboundEventStatisticsCollector); _containerRuntimeConfigMgr = new ConfigManager<RuntimeConfig>( _containerStaticConfig.getRuntimeConfigPropertyPrefix(), _containerStaticConfig.getRuntime()); //FIXME MED using _defaultTrackingExecutorService for _nettyExecHandler seems to hang /* _defaultExecutorServiceTracker = new CallTrackerImpl(new CallTrackerImpl.Config()); _enabledTrackingExecutorServiceState = new EnabledTrackingExecutorServiceState("enabledTrackingExecutorServiceState", _defaultExecutorService, _defaultExecutorServiceTracker, false); _disabledTrackingExecutorServiceState = new DisabledTrackingExecutorServiceState(_defaultExecutorService, new SystemClock()); _defaultTrackingExecutorService = new TrackingExecutorService(_enabledTrackingExecutorServiceState, _disabledTrackingExecutorServiceState, runtimeConfig.getDefaultExecutor().isTrackerEnabled());*/ _nettyExecHandler = new ExecutionHandler(_defaultExecutorService); _componentStatus = createComponentStatus(); _componentAdmin = createComponentAdmin(); _componentAdmin.registerAsMBean(); _globalStatsMerger = new GlobalStatsCalc(GLOBAL_STATS_MERGE_INTERVAL_MS); _globalStatsThread = new Thread(_globalStatsMerger, "GlobalStatsThread"); _globalStatsThread.setDaemon(true); initializeContainerNetworking(byteOrder); initializeContainerJmx(); initializeContainerCommandProcessors(); initializeStatsMerger(); }
From source file:it.geosolutions.tools.io.file.Copy.java
/** * Copy a list of files (preserving data) to a destination (which can be on * nfs) waiting (at least) 'seconds' seconds for each file propagation. * /*www . j a v a2 s.co m*/ * @param es * The ExecutorService or null if you want to use a * CachedThreadPool. * @note potentially this is a bad executor (for log lists of big files) * NOTE: we should make some tests on this 22 Aug 2011 * @param list * @param baseDestDir * @param overwrite * if false and destination exists() do not overwrite the file * @param seconds * @return the resulting moved file list or null * */ public static List<File> parallelCopyListFileToNFS(ExecutorService es, final List<File> list, final File baseDestDir, final int seconds) { try { /* * this could be potentially a bad executor (for log lists of big * files) NOTE: we should make some tests on this 22 Aug 2011 */ if (es == null) { final ThreadFactory threadFactory = Executors.defaultThreadFactory(); es = Executors.newCachedThreadPool(threadFactory); } final List<FutureTask<File>> futureFileList = asynchCopyListFileToNFS(es, list, baseDestDir, seconds); // list if (futureFileList == null) { if (LOGGER.isErrorEnabled()) LOGGER.error("Failed to copy files."); return null; } final int size = futureFileList.size(); if (size == 0) { if (LOGGER.isErrorEnabled()) LOGGER.error("Failed to copy file list using an empty list"); return null; } final List<File> ret = new ArrayList<File>(size); for (Future<File> futureFile : futureFileList) { if (futureFile != null) { File file; try { file = futureFile.get(); if (file != null && file.exists()) { ret.add(file); } else { if (LOGGER.isWarnEnabled()) LOGGER.warn("SKIPPING file:\n\t" + file + ".\nUnable to copy a not existent file."); } } catch (InterruptedException e) { if (LOGGER.isErrorEnabled()) LOGGER.error("Unable to get the file from this future File copy. ", e); } catch (ExecutionException e) { if (LOGGER.isErrorEnabled()) LOGGER.error("Unable to get the file from this future File copy. ", e); } } } return ret; } catch (Throwable t) { if (LOGGER.isErrorEnabled()) LOGGER.error("Unrecognized error occurred. ", t); } finally { if (es != null) es.shutdownNow(); } return null; }
From source file:edu.cornell.med.icb.R.RConnectionPool.java
/** * Used to get a pool of daemon threads. * @return An service which manages daemon threads for the pool *//*from w w w.j a v a 2 s .com*/ private ExecutorService getThreadPool() { synchronized (syncObject) { if (threadPool == null || threadPool.isShutdown()) { threadPool = Executors.newCachedThreadPool(new DaemonThreadFactory()); } return threadPool; } }
From source file:com.linkedin.pinot.query.selection.SelectionOnlyQueriesTest.java
@Test public void testInterSegmentSelectionPlanMakerAndRun() throws Exception { final int numSegments = 20; setupSegmentList(numSegments);//from w w w . j av a 2 s . com final PlanMaker instancePlanMaker = new InstancePlanMakerImplV2(); final BrokerRequest brokerRequest = getSelectionNoFilterBrokerRequest(); final ExecutorService executorService = Executors .newCachedThreadPool(new NamedThreadFactory("test-plan-maker")); final Plan globalPlan = instancePlanMaker.makeInterSegmentPlan(_indexSegmentList, brokerRequest, executorService, 150000); globalPlan.print(); globalPlan.execute(); final DataTable instanceResponse = globalPlan.getInstanceResponse(); System.out.println("Test: InterSegmentSelectionPlanMakerAndRun"); System.out.println("instanceResponse : " + instanceResponse); final BrokerReduceService reduceService = new BrokerReduceService(); final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>(); instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse); final BrokerResponseNative brokerResponse = reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap); SelectionResults selectionResults = brokerResponse.getSelectionResults(); ObjectMapper mapper = new ObjectMapper(); String actualResults = mapper.writeValueAsString(selectionResults); System.out.println("Selection Result : " + actualResults); System.out.println("Time used : " + brokerResponse.getTimeUsedMs()); JsonAssert.assertEqualsIgnoreOrder(actualResults, "{\"columns\":[\"column11\",\"column12\",\"met_impressionCount\"],\"results\":[[\"i\",\"jgn\",\"4955241829510629137\"],[\"i\",\"lVH\",\"6240989492723764727\"],[\"i\",\"kWZ\",\"4955241829510629137\"],[\"i\",\"pm\",\"6240989492723764727\"],[\"i\",\"GF\",\"8637957270245933828\"],[\"i\",\"kB\",\"8637957270245933828\"],[\"i\",\"BQ\",\"8310347835142446717\"],[\"i\",\"YO\",\"4955241829510629137\"],[\"i\",\"RI\",\"8310347835142446717\"],[\"i\",\"RI\",\"6240989492723764727\"]]}"); }
From source file:com.linkedin.pinot.query.selection.SelectionQueriesTest.java
@Test public void testInterSegmentSelectionPlanMakerAndRun() throws Exception { final int numSegments = 20; setupSegmentList(numSegments);/*www . jav a 2s .c om*/ final PlanMaker instancePlanMaker = new InstancePlanMakerImplV2(); final BrokerRequest brokerRequest = getSelectionNoFilterBrokerRequest1(); final ExecutorService executorService = Executors .newCachedThreadPool(new NamedThreadFactory("test-plan-maker")); final Plan globalPlan = instancePlanMaker.makeInterSegmentPlan(_indexSegmentList, brokerRequest, executorService, 150000); globalPlan.print(); globalPlan.execute(); final DataTable instanceResponse = globalPlan.getInstanceResponse(); System.out.println("instanceResponse : " + instanceResponse); final Map<ServerInstance, DataTable> instanceResponseMap = new HashMap<ServerInstance, DataTable>(); instanceResponseMap.put(new ServerInstance("localhost:0000"), instanceResponse); final BrokerReduceService reduceService = new BrokerReduceService(); final BrokerResponseNative brokerResponse = reduceService.reduceOnDataTable(brokerRequest, instanceResponseMap); SelectionResults selectionResults = brokerResponse.getSelectionResults(); List<String> columns = selectionResults.getColumns(); Assert.assertEquals(columns.get(0), "column12"); Assert.assertEquals(columns.get(1), "met_impressionCount"); Assert.assertEquals(columns.get(2), "column11"); List<Serializable[]> rows = selectionResults.getRows(); for (int i = 0; i < rows.size(); ++i) { Serializable[] row = rows.get(i); Assert.assertEquals(row.length, 3); Assert.assertEquals(row[2], "i"); } final BrokerReduceService brokerReduceService = new BrokerReduceService(); final BrokerResponseNative brokerResponseNative = brokerReduceService.reduceOnDataTable(brokerRequest, instanceResponseMap); System.out.println("Selection Result : " + brokerResponseNative.getSelectionResults().toString()); System.out.println("Time used : " + brokerResponseNative.getTimeUsedMs()); selectionResults = brokerResponseNative.getSelectionResults(); List<String> columnArray = selectionResults.getColumns(); Assert.assertEquals(columnArray.size(), 3); Assert.assertEquals(columnArray.get(0), "column12"); Assert.assertEquals(columnArray.get(1), "met_impressionCount"); Assert.assertEquals(columnArray.get(2), "column11"); List<Serializable[]> resultRows = selectionResults.getRows(); Assert.assertEquals(resultRows.size(), 10); for (int i = 0; i < resultRows.size(); ++i) { Serializable[] resultRow = resultRows.get(i); Assert.assertEquals(resultRow.length, 3); Serializable[] expectedValues = rows.get(i); Assert.assertEquals(resultRow[0], expectedValues[0]); Assert.assertEquals(resultRow[1], expectedValues[1]); Assert.assertEquals(resultRow[2], expectedValues[2]); } }
From source file:net.rptools.tokentool.controller.TokenTool_Controller.java
@FXML void initialize() { // Note: A Pane is added to the compositeTokenPane so the ScrollPane doesn't consume the mouse events assert fileManageOverlaysMenu != null : "fx:id=\"fileManageOverlaysMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileSaveAsMenu != null : "fx:id=\"fileSaveAsMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileExitMenu != null : "fx:id=\"fileExitMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert editCaptureScreenMenu != null : "fx:id=\"editCaptureScreenMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert editCopyImageMenu != null : "fx:id=\"editCopyImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert editPasteImageMenu != null : "fx:id=\"editPasteImageMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert helpAboutMenu != null : "fx:id=\"helpAboutMenu\" was not injected: check your FXML file 'TokenTool.fxml'."; assert saveOptionsPane != null : "fx:id=\"saveOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayOptionsPane != null : "fx:id=\"overlayOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert backgroundOptionsPane != null : "fx:id=\"backgroundOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert zoomOptionsPane != null : "fx:id=\"zoomOptionsPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert compositeTokenPane != null : "fx:id=\"compositeTokenPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert tokenPreviewPane != null : "fx:id=\"tokenPreviewPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitScrollPane != null : "fx:id=\"portraitScrollPane\" was not injected: check your FXML file 'TokenTool.fxml'."; assert compositeGroup != null : "fx:id=\"compositeGroup\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayTreeView != null : "fx:id=\"overlayTreeview\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitImageView != null : "fx:id=\"portraitImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert maskImageView != null : "fx:id=\"maskImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayImageView != null : "fx:id=\"overlayImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert tokenImageView != null : "fx:id=\"tokenImageView\" was not injected: check your FXML file 'TokenTool.fxml'."; assert useFileNumberingCheckbox != null : "fx:id=\"useFileNumberingCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayUseAsBaseCheckbox != null : "fx:id=\"overlayUseAsBaseCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'."; assert clipPortraitCheckbox != null : "fx:id=\"clipPortraitCheckbox\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileNameTextField != null : "fx:id=\"fileNameTextField\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileNameSuffixLabel != null : "fx:id=\"fileNameSuffixLabel\" was not injected: check your FXML file 'TokenTool.fxml'."; assert fileNameSuffixTextField != null : "fx:id=\"fileNameSuffixTextField\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayNameLabel != null : "fx:id=\"overlayNameLabel\" was not injected: check your FXML file 'TokenTool.fxml'."; assert backgroundColorPicker != null : "fx:id=\"backgroundColorPicker\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayAspectToggleButton != null : "fx:id=\"overlayAspectToggleButton\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitTransparencySlider != null : "fx:id=\"portraitTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitBlurSlider != null : "fx:id=\"portraitBlurSlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert portraitGlowSlider != null : "fx:id=\"portraitGlowSlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayTransparencySlider != null : "fx:id=\"overlayTransparencySlider\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayWidthSpinner != null : "fx:id=\"overlayWidthSpinner\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayHeightSpinner != null : "fx:id=\"overlayHeightSpinner\" was not injected: check your FXML file 'TokenTool.fxml'."; assert overlayTreeProgressBar != null : "fx:id=\"overlayTreeProgressIndicator\" was not injected: check your FXML file 'ManageOverlays.fxml'."; executorService = Executors.newCachedThreadPool(runable -> { loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable); loadOverlaysThread.setDaemon(true); return loadOverlaysThread; });// w w w .j a va 2s .c o m overlayTreeView.setShowRoot(false); overlayTreeView.getSelectionModel().selectedItemProperty().addListener( (observable, oldValue, newValue) -> updateCompositImageView((TreeItem<Path>) newValue)); addPseudoClassToLeafs(overlayTreeView); // Bind color picker to compositeTokenPane background fill backgroundColorPicker.setValue(Color.TRANSPARENT); ObjectProperty<Background> background = compositeTokenPane.backgroundProperty(); background.bind(Bindings.createObjectBinding(() -> { BackgroundFill fill = new BackgroundFill(backgroundColorPicker.getValue(), CornerRadii.EMPTY, Insets.EMPTY); return new Background(fill); }, backgroundColorPicker.valueProperty())); // Bind transparency slider to portraitImageView opacity portraitTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { portraitImageView.setOpacity(new_val.doubleValue()); updateTokenPreviewImageView(); } }); // // Restrict text field to valid filename characters // Pattern validDoubleText = Pattern.compile("[^a-zA-Z0-9\\\\._ \\\\/`~!@#$%\\\\^&\\\\(\\\\)\\\\-\\\\=\\\\+\\\\[\\\\]\\\\{\\\\}',\\\\\\\\:]"); // Pattern validText = Pattern.compile("[^a-zA-Z0-9 ]"); // TextFormatter<> textFormatter = new TextFormatter<>( // change -> { // String newText = change.getControlNewText(); // if (validText.matcher(newText).matches()) { // return change; // } else // return null; // }); // UnaryOperator<TextFormatter.Change> filter = new UnaryOperator<TextFormatter.Change>() { // @Override // public TextFormatter.Change apply(TextFormatter.Change t) { // String validText = "[^a-zA-Z0-9]"; // // if (t.isReplaced()) // if (t.getText().matches(validText)) // t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd())); // // if (t.isAdded()) { // if (t.getText().matches(validText)) { // return null; // } // } // // return t; // } // }; UnaryOperator<Change> filter = change -> { String text = change.getText(); if (text.matches(AppConstants.VALID_FILE_NAME_PATTERN)) { return change; } else { change.setText(FileSaveUtil.cleanFileName(text)); ; return change; } // // return null; }; TextFormatter<String> textFormatter = new TextFormatter<>(filter); fileNameTextField.setTextFormatter(textFormatter); // Effects GaussianBlur gaussianBlur = new GaussianBlur(0); Glow glow = new Glow(0); gaussianBlur.setInput(glow); // Bind blur slider to portraitImageView opacity portraitBlurSlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { gaussianBlur.setRadius(new_val.doubleValue()); portraitImageView.setEffect(gaussianBlur); updateTokenPreviewImageView(); } }); // Bind glow slider to portraitImageView opacity portraitGlowSlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { glow.setLevel(new_val.doubleValue()); portraitImageView.setEffect(gaussianBlur); updateTokenPreviewImageView(); } }); // Bind transparency slider to overlayImageView opacity overlayTransparencySlider.valueProperty().addListener(new ChangeListener<Number>() { public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) { overlayImageView.setOpacity(new_val.doubleValue()); updateTokenPreviewImageView(); } }); // Bind width/height spinners to overlay width/height overlayWidthSpinner.getValueFactory().valueProperty() .bindBidirectional(overlayHeightSpinner.getValueFactory().valueProperty()); overlayWidthSpinner.valueProperty().addListener( (observable, oldValue, newValue) -> overlayWidthSpinner_onTextChanged(oldValue, newValue)); overlayHeightSpinner.valueProperty().addListener( (observable, oldValue, newValue) -> overlayHeightSpinner_onTextChanged(oldValue, newValue)); }
From source file:com.splout.db.qnode.Deployer.java
/** * The Deployer deals with deploy and switch version requests. *///from w w w.ja v a2 s . c o m public Deployer(QNodeHandlerContext context) { super(context); deployExecutor = MoreExecutors.listeningDecorator( Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("deploy-%d").build())); }