@Override public boolean offer(Runnable runnable) { if (defaultExecutor.getPoolSize() < DataFXConfiguration.getInstance().getDefaultThreadMaxSize()) { return false; } return super.offer(runnable); } };
public static synchronized DataFXConfiguration getInstance() { if(instance == null) { instance = new DataFXConfiguration(); } return instance; } }
public Document getConfigurationDocument() { if(configurationDocument == null) { configurationDocument = readDataFXConfiguration(); } return configurationDocument; }
DataFXConfiguration.getInstance().getDefaultThreadPoolStartSize(), DataFXConfiguration.getInstance().getDefaultThreadMaxSize(), DataFXConfiguration.getInstance().getDefaultThreadTimeout(), TimeUnit.MILLISECONDS, queue, threadFactory, new ThreadPoolExecutor.AbortPolicy()); defaultExecutor.allowCoreThreadTimeOut(true);
public static synchronized ExceptionHandler getDefaultInstance() { if (defaultInstance == null) { defaultInstance = new ExceptionHandler(); setExceptionLogging(DataFXConfiguration.getInstance().isExceptionLoggingActive()); } return defaultInstance; }
private ObservableToggleManager createManagerFromConfig() { try { List<Element> elements = DataFXConfiguration.getInstance().getElements("features"); if (elements == null) { throw new RuntimeException("Can't load config. Features section not specified!"); } if (elements.isEmpty()) { throw new RuntimeException("Can't load config. Features section not specified!"); } if (elements.size() > 1) { throw new RuntimeException("Can't load config. Features section must only be specified once!"); } Class<? extends Feature> featureClass = (Class<? extends Feature>) Class.forName(elements.get(0).getElementsByTagName("featureEnum").item(0).getTextContent()); return new ObservableToggleManager(featureClass); } catch (Exception e) { throw new RuntimeException("Can't generate Feature Manager", e); } }
public List<Element> getElements(String tagName) { NodeList nodes = getConfigurationDocument().getElementsByTagName(tagName); List<Element> ret = new ArrayList<>(); for (int temp = 0; temp < nodes.getLength(); temp++) { Node node = nodes.item(temp); ret.add((Element) node); } return ret; }