Example usage for org.apache.commons.configuration DataConfiguration DataConfiguration

List of usage examples for org.apache.commons.configuration DataConfiguration DataConfiguration

Introduction

In this page you can find the example usage for org.apache.commons.configuration DataConfiguration DataConfiguration.

Prototype

public DataConfiguration(Configuration configuration) 

Source Link

Document

Creates a new instance of DataConfiguration and sets the wrapped configuration.

Usage

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);//ww  w .j  a v  a  2s.  c  o m
}

From source file:pl.otros.logview.BufferingLogDataCollectorProxy.java

public BufferingLogDataCollectorProxy(LogDataCollector delegate, final long sleepTime,
        Configuration configuration) {
    super();/*from  www.ja  v  a  2 s  .co  m*/
    this.delegate = delegate;
    this.configuration = new DataConfiguration(configuration);
    proxyLogDataCollector = new ProxyLogDataCollector();
    Runnable r = new Runnable() {

        @Override
        public void run() {
            while (!stop) {
                if (BufferingLogDataCollectorProxy.this.configuration.getBoolean(ConfKeys.TAILING_PANEL_PLAY)) {
                    synchronized (BufferingLogDataCollectorProxy.this) {
                        LogData[] logData = proxyLogDataCollector.getLogData();
                        if (logData.length > 0) {
                            proxyLogDataCollector = new ProxyLogDataCollector();
                            addToDelegateInEDT(logData);
                        }
                    }
                }

                try {
                    Thread.sleep(sleepTime);
                } catch (InterruptedException ignore) {
                }

            }

        }
    };
    Thread t = new Thread(r, "BufferingLogDataCollectorProxy");
    t.setDaemon(true);
    t.start();
}

From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderActionTest.java

@Test
public void tryToConnect() throws IOException {
    OtrosApplication otrosApplication = new OtrosApplication();
    ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication);
    DataConfiguration dc = new DataConfiguration(new BaseConfiguration());
    String hostAndPort = "abc:50";
    SocketFactory socketFactory = mock(SocketFactory.class);
    Socket mockSocket = mock(Socket.class);
    when(socketFactory.createSocket("abc", 50)).thenReturn(mockSocket);

    Socket socket = action.tryToConnectToSocket(dc, hostAndPort, socketFactory);

    assertEquals(mockSocket, socket);//from w  w w . j a v a  2 s. c om
    assertEquals(1, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size());
    assertEquals("abc:50", dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).get(0));
}

From source file:pl.otros.logview.gui.actions.ConnectToSocketHubAppenderActionTest.java

@Test
public void tryToConnectFail() throws IOException {
    OtrosApplication otrosApplication = new OtrosApplication();
    ConnectToSocketHubAppenderAction action = new ConnectToSocketHubAppenderAction(otrosApplication);
    DataConfiguration dc = new DataConfiguration(new BaseConfiguration());
    String hostAndPort = "abc:50";
    SocketFactory socketFactory = mock(SocketFactory.class);
    Socket mockSocket = mock(Socket.class);
    when(socketFactory.createSocket("abc", 50)).thenThrow(new UnknownHostException());

    try {//from w w  w.j a va2  s. c om
        action.tryToConnectToSocket(dc, hostAndPort, socketFactory);
        Assert.fail();
    } catch (UnknownHostException e) {
        //success
    }

    assertEquals(0, dc.getList(ConfKeys.SOCKET_HUB_APPENDER_ADDRESSES).size());
}

From source file:pl.otros.logview.gui.message.pattern.PropertyPatternMessageColorizer.java

public void init(InputStream in) throws ConfigurationException {
    propertiesConfiguration = new PropertiesConfiguration();
    propertiesConfiguration.setDelimiterParsingDisabled(true);
    propertiesConfiguration.load(in, "UTF-8");
    configuration = new DataConfiguration(propertiesConfiguration);
    configuration.setDelimiterParsingDisabled(true);
    String pa = configuration.getString(PROP_PATTERN);
    int flags = 0;
    flags = flags | (configuration.getBoolean(PROP_PATTERN_CANON_EQ, false) ? Pattern.CANON_EQ : 0);
    flags = flags// w w w  .  j  a v  a  2  s.co m
            | (configuration.getBoolean(PROP_PATTERN_CASE_INSENSITIVE, false) ? Pattern.CASE_INSENSITIVE : 0);
    flags = flags | (configuration.getBoolean(PROP_PATTERN_COMMENTS, false) ? Pattern.COMMENTS : 0);
    flags = flags | (configuration.getBoolean(PROP_PATTERN_DOTALL, false) ? Pattern.DOTALL : 0);
    flags = flags | (configuration.getBoolean(PROP_PATTERN_LITERAL, false) ? Pattern.LITERAL : 0);
    flags = flags | (configuration.getBoolean(PROP_PATTERN_MULTILINE, false) ? Pattern.MULTILINE : 0);
    flags = flags | (configuration.getBoolean(PROP_PATTERN_UNICODE_CASE, false) ? Pattern.UNICODE_CASE : 0);
    flags = flags | (configuration.getBoolean(PROP_PATTERN_UNIX_LINES, false) ? Pattern.UNIX_LINES : 0);

    pattern = Pattern.compile(pa, flags);
    groupCount = countGroups(pattern);
    name = configuration.getString(PROP_NAME, "NAME NOT SET!");
    description = configuration.getString(PROP_DESCRIPTION, "DESCRIPTION NOT SET!");
    testMessage = configuration.getString(PROP_TEST_MESSAGE, "");
    version = configuration.getInt(PROP_VERSION, 1);
}

From source file:pl.otros.vfs.browser.demo.TestBrowser.java

public static void main(final String[] args)
        throws InterruptedException, InvocationTargetException, SecurityException, IOException {
    if (args.length > 1)
        throw new IllegalArgumentException(
                "SYNTAX:  java... " + TestBrowser.class.getName() + " [initialPath]");

    SwingUtilities.invokeAndWait(new Runnable() {

        @Override/*  w ww.  j a va  2  s  . c om*/
        public void run() {
            tryLoadSubstanceLookAndFeel();
            final JFrame f = new JFrame("OtrosVfsBrowser demo");
            Container contentPane = f.getContentPane();
            contentPane.setLayout(new BorderLayout());
            DataConfiguration dc = null;
            final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
            File favoritesFile = new File("favorites.properties");
            propertiesConfiguration.setFile(favoritesFile);
            if (favoritesFile.exists()) {
                try {
                    propertiesConfiguration.load();
                } catch (ConfigurationException e) {
                    e.printStackTrace();
                }
            }
            dc = new DataConfiguration(propertiesConfiguration);
            propertiesConfiguration.setAutoSave(true);
            final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null);
            comp.setSelectionMode(SelectionMode.FILES_ONLY);
            comp.setMultiSelectionEnabled(true);
            comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    FileObject[] selectedFiles = comp.getSelectedFiles();
                    System.out.println("Selected files count=" + selectedFiles.length);
                    for (FileObject selectedFile : selectedFiles) {
                        try {
                            FileSize fileSize = new FileSize(selectedFile.getContent().getSize());
                            System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString());
                            byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l);
                            JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes)));
                            JDialog d = new JDialog(f);
                            d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI());
                            d.getContentPane().add(sp);
                            d.setSize(600, 400);
                            d.setVisible(true);
                        } catch (Exception e1) {
                            LOGGER.error("Failed to read file", e1);
                            JOptionPane.showMessageDialog(f,
                                    (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error",
                                    JOptionPane.ERROR_MESSAGE);
                        }
                    }
                }
            });

            comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) {
                @Override
                public void actionPerformed(ActionEvent e) {
                    f.dispose();
                    try {
                        propertiesConfiguration.save();
                    } catch (ConfigurationException e1) {
                        e1.printStackTrace();
                    }
                    System.exit(0);
                }
            });
            contentPane.add(comp);

            f.pack();
            f.setVisible(true);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        }
    });
}

From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java

public JOtrosVfsBrowserDialog(final String initialPath) {
    this(new DataConfiguration(new BaseConfiguration()), initialPath);
}

From source file:pl.otros.vfs.browser.JOtrosVfsBrowserDialog.java

public JOtrosVfsBrowserDialog() {
    this(new DataConfiguration(new BaseConfiguration()));
}

From source file:pl.otros.vfs.browser.VfsBrowser.java

License:asdf

public VfsBrowser(Configuration configuration, final String initialPath) {
    super();/*from  ww w . j a v a  2s  .  c o m*/
    this.configuration = new DataConfiguration(configuration);
    initGui(initialPath);
    VFSUtils.loadAuthStore();
}