List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration
BaseConfiguration
From source file:org.xwiki.configuration.internal.CloudConfigurationSourceTest.java
/** * Setup the cloud configuration source for tests. * /*from w w w .j a v a 2s. c o m*/ * @throws Exception If the cloud configuration source cannot be looked up. */ @Before public void setUp() throws Exception { super.setUp(); final ConverterManager converterManager = getComponentManager().lookup(ConverterManager.class); environment = getMockery().mock(Environment.class); /* Build a fake remapping file containing a remap entry */ final ByteArrayInputStream remappingFileContent = new ByteArrayInputStream( String.format("remap.%s=%s", FOO, BAR).getBytes()); getMockery().checking(new Expectations() { { allowing(environment).getResourceAsStream(REMAPPING_FILE); will(returnValue(remappingFileContent)); } }); final Logger logger = getMockery().mock(Logger.class); CommonsConfigurationSource dummySource = new CommonsConfigurationSource(); ReflectionUtils.setFieldValue(dummySource, "converterManager", converterManager); configuration = new BaseConfiguration(); dummySource.setConfiguration(configuration); SystemPropertiesConfigurationSource systemPropertiesConfigurationSource = new SystemPropertiesConfigurationSource(); systemPropertiesConfigurationSource.initialize(); SystemEnvironmentConfigurationSource systemEnvironmentConfigurationSource = new SystemEnvironmentConfigurationSource(); systemEnvironmentConfigurationSource.initialize(); source = new CloudConfigurationSource(); ReflectionUtils.setFieldValue(source, "environment", environment); ReflectionUtils.setFieldValue(source, "logger", logger); ReflectionUtils.setFieldValue(source, "xwikiPropertiesSource", dummySource); ReflectionUtils.setFieldValue(source, "wikiPreferencesSource", dummySource); ReflectionUtils.setFieldValue(source, "spacePreferencesSource", dummySource); ReflectionUtils.setFieldValue(source, "systemPropertiesConfigurationSource", systemPropertiesConfigurationSource); ReflectionUtils.setFieldValue(source, "systemEnvironmentConfigurationSource", systemEnvironmentConfigurationSource); source.initialize(); }
From source file:org.xwiki.configuration.internal.CommonsConfigurationSourceTest.java
@Before public void setUp() throws Exception { super.setUp(); this.source = new CommonsConfigurationSource(); ConverterManager converterManager = getComponentManager().lookup(ConverterManager.class); ReflectionUtils.setFieldValue(source, "converterManager", converterManager); this.configuration = new BaseConfiguration(); this.source.setConfiguration(this.configuration); }
From source file:org.xwiki.configuration.internal.CompositeConfigurationSourceTest.java
@Before public void setUp() throws Exception { super.setUp(); this.composite = new CompositeConfigurationSource(); ConverterManager converterManager = getComponentManager().lookup(ConverterManager.class); CommonsConfigurationSource source1 = new CommonsConfigurationSource(); ReflectionUtils.setFieldValue(source1, "converterManager", converterManager); this.config1 = new BaseConfiguration(); source1.setConfiguration(this.config1); this.composite.addConfigurationSource(source1); CommonsConfigurationSource source2 = new CommonsConfigurationSource(); ReflectionUtils.setFieldValue(source2, "converterManager", converterManager); this.config2 = new BaseConfiguration(); source2.setConfiguration(this.config2); this.composite.addConfigurationSource(source2); }
From source file:org.xwiki.configuration.internal.SystemEnvironmentConfigurationSource.java
@Override public void initialize() throws InitializationException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setDelimiterParsingDisabled(true); Map<String, String> environment = System.getenv(); for (String key : environment.keySet()) { configuration.setProperty(key, environment.get(key)); }/*from ww w . java 2 s . c o m*/ setConfiguration(configuration); }
From source file:org.xwiki.configuration.internal.SystemPropertiesConfigurationSource.java
@Override public void initialize() throws InitializationException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setDelimiterParsingDisabled(true); Properties properties = System.getProperties(); for (String key : properties.stringPropertyNames()) { configuration.setProperty(key, properties.get(key)); }//from www .ja v a 2 s. c om setConfiguration(configuration); }
From source file:org.xwiki.configuration.internal.XWikiPropertiesConfigurationSource.java
@Override public void initialize() throws InitializationException { // Register the Commons Properties Configuration, looking for a xwiki.properties file // in the XWiki path somewhere. URL xwikiPropertiesUrl;/*from w w w . j a va 2 s .c o m*/ try { xwikiPropertiesUrl = this.container.getApplicationContext().getResource(XWIKI_PROPERTIES_FILE); if (xwikiPropertiesUrl != null) { setConfiguration(new PropertiesConfiguration(xwikiPropertiesUrl)); } else if (this.logger.isDebugEnabled()) { // We use a debug logging level here since we consider it's ok that there's no XWIKI_PROPERTIES_FILE // available, in which case default values are used. this.logger.debug("No configuration file [" + XWIKI_PROPERTIES_FILE + "] found. " + "Using default configuration values."); // Use a default Commons Configuration implementation since we couldn't use a Properties configuration. setConfiguration(new BaseConfiguration()); } } catch (Exception e) { // Note: if we cannot read the configuration file for any reasonwe log a warning but continue since XWiki // will use default values for all configurable elements. this.logger.warn("Failed to load configuration file [" + XWIKI_PROPERTIES_FILE + "]. Using default configuration values. " + " Internal error [" + e.getMessage() + "]"); // Use a default Commons Configuration implementation since we couldn't use a Properties configuration. setConfiguration(new BaseConfiguration()); } }
From source file:pl.otros.logview.api.batch.BatchProcessingContext.java
public BatchProcessingContext() { configuration = new DataConfiguration(new BaseConfiguration()); }
From source file:pl.otros.logview.api.gui.LogViewPanelWrapper.java
public LogViewPanelWrapper(String name, Stoppable stoppable, TableColumns[] visibleColumns, LogDataTableModel logDataTableModel, OtrosApplication otrosApplication) { this(name, stoppable, visibleColumns, logDataTableModel, new DataConfiguration(new BaseConfiguration()), otrosApplication);/* w ww . ja va 2 s .co m*/ }
From source file:pl.otros.logview.BufferingLogDataCollectorProxyTest.java
@BeforeMethod public void initTest() throws InterruptedException, InvocationTargetException { configuration = new BaseConfiguration(); configuration.setProperty(ConfKeys.TAILING_PANEL_PLAY, true); delegate = new ProxyLogDataCollector(); bufferingLogDataCollectorProxy = new BufferingLogDataCollectorProxy(delegate, sleepTime, configuration); // Initialize swing thread SwingUtilities.invokeAndWait(new Runnable() { @Override/*from w w w .j a v a 2 s. co m*/ public void run() { } }); }
From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderAction.java
@Override public void actionPerformed(ActionEvent arg0) { boolean accepted = chooseLogImporter(); if (!accepted) { return;//from www. j ava 2 s . c o m } logViewPanelWrapper = new LogViewPanelWrapper("Socket", null, TableColumns.values(), getOtrosApplication()); logViewPanelWrapper.goToLiveMode(); BaseConfiguration configuration = new BaseConfiguration(); configuration.addProperty(ConfKeys.TAILING_PANEL_PLAY, true); configuration.addProperty(ConfKeys.TAILING_PANEL_FOLLOW, true); logDataCollector = new BufferingLogDataCollectorProxy(logViewPanelWrapper.getDataTableModel(), 4000, configuration); // JTabbedPane jTabbedPane = getOtrosApplication().getJTabbedPane(); // int tabCount = jTabbedPane.getTabCount(); String hostPort = "Log4j SocketHub " + host + ":" + port; try { final LogImporter logImporter = new Log4jSerilizedLogImporter(); logImporter.init(new Properties()); final ParsingContext parsingContext = new ParsingContext(hostPort, hostPort); logImporter.initParsingContext(parsingContext); TailLogActionListener.ParsingContextStopperForClosingTab contextStopperForClosingTab = new ParsingContextStopperForClosingTab( parsingContext); TailLogActionListener.ReadingStopperForRemove readingStopperForRemove = new TailLogActionListener.ReadingStopperForRemove( contextStopperForClosingTab, logDataCollector); logViewPanelWrapper.addHierarchyListener(readingStopperForRemove); getOtrosApplication().addClosableTab(hostPort, hostPort, Icons.PLUGIN_CONNECT, logViewPanelWrapper, true); Runnable r = new Runnable() { @Override public void run() { InetAddress inetAddress = socket.getInetAddress(); int port2 = socket.getPort(); InputStream inputStream = null; Socket s = socket; while (parsingContext.isParsingInProgress()) { try { inputStream = s.getInputStream(); BufferedInputStream bin = new BufferedInputStream(inputStream); LOGGER.info(String.format("Connect to SocketHubAppender to %s:%d", inetAddress.getHostAddress(), port2)); logImporter.importLogs(bin, logDataCollector, parsingContext); getOtrosApplication().getStatusObserver().updateStatus( "Loading logs from Log4j SocketHubAppender finished", StatusObserver.LEVEL_WARNING); } catch (IOException e1) { LOGGER.warning(String.format("Problem with connecting to %s:%d: %s", inetAddress.getHostAddress(), port2, e1.getMessage())); } try { LOGGER.fine("Reconnecting in " + RECONNECT_TIME + "ms"); Thread.sleep(RECONNECT_TIME); } catch (InterruptedException e) { LOGGER.warning("Waiting thread interrupted" + e.getMessage()); } if (parsingContext.isParsingInProgress()) { try { LOGGER.fine(String.format("Connecting to Log4j SocketHubAppender at %s:%d", inetAddress.getHostName(), port2)); s = new Socket(inetAddress, port2); } catch (IOException e) { LOGGER.warning(String.format("Problem with connecting to %s:%d: %s", inetAddress.getHostAddress(), port2, e.getMessage())); } } } LOGGER.info( String.format("Importing from %s:%d is finished", inetAddress.getHostName(), port2)); } }; new Thread(r, hostPort).start(); } catch (Exception e) { JOptionPane.showMessageDialog((Component) arg0.getSource(), "Error importing logs from " + hostPort, "Error importing logs", JOptionPane.ERROR_MESSAGE); } }