@Test void testSetConfigurationShouldNotCreateAndSetWriterIfNotPresent() throws ConfigurationException { SimpleLogListener simpleLogListener = new SimpleLogListener(); Element root = new Element("root"); simpleLogListener.setConfiguration(root); assertNull(simpleLogListener.writer); }
@Override public void setConfiguration(Element e) throws ConfigurationException { Element ew = e.getChild("writer"); LogEventWriter writer; if (ew != null) { String clazz = ew.getAttributeValue("class"); if (clazz != null) { try { writer = (LogEventWriter) Class.forName(clazz).newInstance(); } catch (Exception ex) { throw new ConfigurationException(ex); } if (writer != null) { if (writer instanceof Configurable) { SimpleConfigurationFactory factory = new SimpleConfigurationFactory(); ((Configurable) writer).setConfiguration(factory.getConfiguration(ew)); } if (writer instanceof XmlConfigurable) { ((XmlConfigurable) writer).setConfiguration(ew); } accept(writer); } } else { throw new ConfigurationException("The writer configuration requires a class attribute"); } } }
SimpleLogListener implements LogListener, XmlConfigurable, Consumer<LogEventWriter> { @Override public void setConfiguration(Element e) throws ConfigurationException { Element ew = e.getChild("writer"); LogEventWriter writer; if (ew != null) { String clazz = ew.getAttributeValue("class"); if (clazz != null) { try { writer = (LogEventWriter) Class.forName(clazz).newInstance(); } catch (Exception ex) { throw new ConfigurationException(ex); } if (writer != null) { if (writer instanceof Configurable) { SimpleConfigurationFactory factory = new SimpleConfigurationFactory(); ((Configurable) writer).setConfiguration(factory.getConfiguration(ew)); } if (writer instanceof XmlConfigurable) { ((XmlConfigurable) writer).setConfiguration(ew); } accept(writer); } } else { throw new ConfigurationException("The writer configuration requires a class attribute"); } } } }
SimpleLogListener implements LogListener, XmlConfigurable, Consumer<LogEventWriter> { @Override public void setConfiguration(Element e) throws ConfigurationException { Element ew = e.getChild("writer"); LogEventWriter writer; if (ew != null) { String clazz = ew.getAttributeValue("class"); if (clazz != null) { try { writer = (LogEventWriter) Class.forName(clazz).newInstance(); } catch (Exception ex) { throw new ConfigurationException(ex); } if (writer != null) { if (writer instanceof Configurable) { SimpleConfigurationFactory factory = new SimpleConfigurationFactory(); ((Configurable) writer).setConfiguration(factory.getConfiguration(ew)); } if (writer instanceof XmlConfigurable) { ((XmlConfigurable) writer).setConfiguration(ew); } accept(writer); } } else { throw new ConfigurationException("The writer configuration requires a class attribute"); } } } SimpleLogListener();  SimpleLogListener(PrintStream p); }
SimpleLogListener implements LogListener, XmlConfigurable, Consumer<LogEventWriter> { @Override public void setConfiguration(Element e) throws ConfigurationException { Element ew = e.getChild("writer"); LogEventWriter writer; if (ew != null) { String clazz = ew.getAttributeValue("class"); if (clazz != null) { try { writer = (LogEventWriter) Class.forName(clazz).newInstance(); } catch (Exception ex) { throw new ConfigurationException(ex); } if (writer != null) { if (writer instanceof Configurable) { SimpleConfigurationFactory factory = new SimpleConfigurationFactory(); ((Configurable) writer).setConfiguration(factory.getConfiguration(ew)); } if (writer instanceof XmlConfigurable) { ((XmlConfigurable) writer).setConfiguration(ew); } accept(writer); } } else { throw new ConfigurationException("The writer configuration requires a class attribute"); } } } SimpleLogListener();  SimpleLogListener(PrintStream p); synchronized void setPrintStream(PrintStream p); synchronized void close(); synchronized LogEvent log(LogEvent ev); @Override void accept(LogEventWriter writer); @Override void setConfiguration(Element e); }
SimpleLogListener implements LogListener, XmlConfigurable, Consumer<LogEventWriter> { @Override public void setConfiguration(Element e) throws ConfigurationException { Element ew = e.getChild("writer"); LogEventWriter writer; if (ew != null) { String clazz = ew.getAttributeValue("class"); if (clazz != null) { try { writer = (LogEventWriter) Class.forName(clazz).newInstance(); } catch (Exception ex) { throw new ConfigurationException(ex); } if (writer != null) { if (writer instanceof Configurable) { SimpleConfigurationFactory factory = new SimpleConfigurationFactory(); ((Configurable) writer).setConfiguration(factory.getConfiguration(ew)); } if (writer instanceof XmlConfigurable) { ((XmlConfigurable) writer).setConfiguration(ew); } accept(writer); } } else { throw new ConfigurationException("The writer configuration requires a class attribute"); } } } SimpleLogListener();  SimpleLogListener(PrintStream p); synchronized void setPrintStream(PrintStream p); synchronized void close(); synchronized LogEvent log(LogEvent ev); @Override void accept(LogEventWriter writer); @Override void setConfiguration(Element e);  }