@Order(0) public class SpringBootConfigurationFactory extends ConfigurationFactory {
@Override public int compare(final Class<?> lhs, final Class<?> rhs) { final Order lhsOrder = Objects.requireNonNull(lhs, "lhs").getAnnotation(Order.class); final Order rhsOrder = Objects.requireNonNull(rhs, "rhs").getAnnotation(Order.class); if (lhsOrder == null && rhsOrder == null) { // both unannotated means equal priority return 0; } // if only one class is @Order-annotated, then prefer that one if (rhsOrder == null) { return -1; } if (lhsOrder == null) { return 1; } // larger value means higher priority return Integer.signum(rhsOrder.value() - lhsOrder.value()); } }
@Order(10) public class Log4j2JavaConfigurationFactory extends ConfigurationFactory {
@Order(10) public class Log4j2XmlConfiguration extends ConfigurationFactory {
@Order(100) @Plugin(name = "MeecrowaveConfigurationFactory", category = "ConfigurationFactory") public class MeecrowaveLog4j2ConfigurationFactory extends XmlConfigurationFactory { private static final String[] TYPES = {".xml"/*override*/, ".meecrowave-logging" /*our default*/, "*"}; @Override public String[] getSupportedTypes() { return TYPES; } @Override public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) { return super.getConfiguration(loggerContext, source); } }
@Order(100) @Plugin(name = "MeecrowaveConfigurationFactory", category = "ConfigurationFactory") public class MeecrowaveLog4j2ConfigurationFactory extends XmlConfigurationFactory { private static final String[] TYPES = {".xml"/*override*/, ".meecrowave-logging" /*our default*/, "*"}; @Override public String[] getSupportedTypes() { return TYPES; } @Override public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) { return super.getConfiguration(loggerContext, source); } }
/** * Created by presidentio on 12/13/15. */ @Plugin( name = "Log4jConfigurationFactory", category = "ConfigurationFactory" ) @Order(4) public class Log4jConfigurationFactory extends XmlConfigurationFactory { public static final String[] SUFFIXES = new String[] {".prairie.xml"}; @Override public String[] getSupportedTypes() { return SUFFIXES; } }
@Order(Integer.MAX_VALUE) public class SOFAConfigurationFactory extends ConfigurationFactory {
/** * Creates a PropertiesConfiguration from a properties file. * * @since 2.4 */ @Plugin(name = "PropertiesConfigurationFactory", category = ConfigurationFactory.CATEGORY) @Order(8) public class PropertiesConfigurationFactory extends ConfigurationFactory { @Override protected String[] getSupportedTypes() { return new String[] {".properties"}; } @Override public PropertiesConfiguration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) { final Properties properties = new Properties(); try (final InputStream configStream = source.getInputStream()) { properties.load(configStream); } catch (final IOException ioe) { throw new ConfigurationException("Unable to load " + source.toString(), ioe); } return new PropertiesConfigurationBuilder() .setConfigurationSource(source) .setRootProperties(properties) .setLoggerContext(loggerContext) .build(); } }
@Order(5) public class XmlConfigurationFactory extends ConfigurationFactory {
@Plugin(name = "YamlConfigurationFactory", category = ConfigurationFactory.CATEGORY) @Order(7) public class YamlConfigurationFactory extends ConfigurationFactory {
@Plugin(name = "JsonConfigurationFactory", category = ConfigurationFactory.CATEGORY) @Order(6) public class JsonConfigurationFactory extends ConfigurationFactory {