diff --git a/archaius2-core/pom.xml b/archaius2-core/pom.xml new file mode 100644 index 000000000..74fedc054 --- /dev/null +++ b/archaius2-core/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + com.netflix.archaius + archaius2-core + 2.1.11 + + + com.netflix.archaius + archaius2-api + 2.1.11 + runtime + + + + org.apache.commons + commons-lang3 + 3.3.2 + runtime + + + junit + junit + 4.11 + test + + + org.mockito + mockito-core + 1.10.19 + + + com.google.guava + guava + 18.0 + + + com.google.code.findbugs + jsr305 + 3.0.1 + + + org.hamcrest + hamcrest-all + 1.3 + test + + + archaius2-core + archaius2-core + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + netflixgithub + Netflix Open Source Development + netflixoss@netflix.com + + + + 1.8 + 1.8 + + https://github.com/Netflix/archaius + + https://github.com/Netflix/archaius.git + + diff --git a/archaius2-core/src/main/java/com/netflix/archaius/DefaultConfigLoader.java b/archaius2-core/src/main/java/com/netflix/archaius/DefaultConfigLoader.java index f13dc7876..a22f7b8d7 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/DefaultConfigLoader.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/DefaultConfigLoader.java @@ -30,8 +30,8 @@ import com.netflix.archaius.interpolate.ConfigStrLookup; import com.netflix.archaius.readers.PropertiesConfigReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import java.io.File; import java.net.MalformedURLException; @@ -49,7 +49,7 @@ */ public class DefaultConfigLoader implements ConfigLoader { - private static final Logger LOG = LoggerFactory.getLogger(DefaultConfigLoader.class); + private static final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(DefaultConfigLoader.class); private static final NoCascadeStrategy DEFAULT_CASCADE_STRATEGY = new NoCascadeStrategy(); private static final Lookup DEFAULT_LOOKUP = new Lookup() { diff --git a/archaius2-core/src/main/java/com/netflix/archaius/config/DefaultCompositeConfig.java b/archaius2-core/src/main/java/com/netflix/archaius/config/DefaultCompositeConfig.java index 38d77c74f..cc369e88c 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/config/DefaultCompositeConfig.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/config/DefaultCompositeConfig.java @@ -25,8 +25,8 @@ import java.util.Map.Entry; import java.util.concurrent.CopyOnWriteArrayList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import com.netflix.archaius.api.Config; import com.netflix.archaius.api.ConfigListener; @@ -46,7 +46,7 @@ * TODO: Combine children and lookup into a single LinkedHashMap */ public class DefaultCompositeConfig extends AbstractConfig implements com.netflix.archaius.api.config.CompositeConfig { - private static final Logger LOG = LoggerFactory.getLogger(DefaultCompositeConfig.class); + private static final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(DefaultCompositeConfig.class); /** * The builder provides a fluent style API to create a CompositeConfig diff --git a/archaius2-core/src/main/java/com/netflix/archaius/config/PollingDynamicConfig.java b/archaius2-core/src/main/java/com/netflix/archaius/config/PollingDynamicConfig.java index f9482807e..1dc3b5eef 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/config/PollingDynamicConfig.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/config/PollingDynamicConfig.java @@ -24,8 +24,8 @@ import com.netflix.archaius.api.config.PollingStrategy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import com.netflix.archaius.config.polling.PollingResponse; @@ -38,7 +38,7 @@ * */ public class PollingDynamicConfig extends AbstractConfig { - private static final Logger LOG = LoggerFactory.getLogger(PollingDynamicConfig.class); + private static final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(PollingDynamicConfig.class); private volatile Map current = new HashMap(); private final AtomicBoolean busy = new AtomicBoolean(); diff --git a/archaius2-core/src/main/java/com/netflix/archaius/config/polling/FixedPollingStrategy.java b/archaius2-core/src/main/java/com/netflix/archaius/config/polling/FixedPollingStrategy.java index d6fe7c1ae..47bc23fd3 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/config/polling/FixedPollingStrategy.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/config/polling/FixedPollingStrategy.java @@ -20,15 +20,15 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import com.netflix.archaius.api.config.PollingStrategy; import com.netflix.archaius.util.Futures; import com.netflix.archaius.util.ThreadFactories; public class FixedPollingStrategy implements PollingStrategy { - private static final Logger LOG = LoggerFactory.getLogger(FixedPollingStrategy.class); + private static final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(FixedPollingStrategy.class); private final ScheduledExecutorService executor; private final long interval; private final TimeUnit units; diff --git a/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLogger.java b/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLogger.java new file mode 100644 index 000000000..e14d88d4a --- /dev/null +++ b/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLogger.java @@ -0,0 +1,41 @@ +package com.netflix.archaius.log; + +public interface ArchaiusLogger { + + public abstract boolean isTraceEnabled(); + + public abstract void trace(String message); + + public abstract void trace(String message, Object... params); + + public abstract void trace(String message, Throwable error); + + public abstract boolean isDebugEnabled(); + + public abstract void debug(String message); + + public abstract void debug(String message, Object... params); + + public abstract void debug(String message, Throwable error); + + public abstract void info(String message); + + public abstract void info(String message, Object... params); + + public abstract void info(String message, Throwable error); + + public abstract boolean isWarnEnabled(); + + public abstract void warn(String message); + + public abstract void warn(String message, Object... params); + + public abstract void warn(String message, Throwable error); + + public abstract void error(String message); + + public abstract void error(String message, Object... params); + + public abstract void error(String message, Throwable error); + +} diff --git a/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLoggerFactory.java b/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLoggerFactory.java new file mode 100644 index 000000000..566659c39 --- /dev/null +++ b/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLoggerFactory.java @@ -0,0 +1,17 @@ +package com.netflix.archaius.log; + + +public class ArchaiusLoggerFactory { + + private static volatile ArchaiusLoggerService service = new NoOpLoggerFactory(); + + public static ArchaiusLogger getLogger( + Class clazz) { + return service.getLogger(clazz); + } + + public static void setLoggerService(final ArchaiusLoggerService s) { + service = s; + } + +} diff --git a/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLoggerService.java b/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLoggerService.java new file mode 100644 index 000000000..b96da093a --- /dev/null +++ b/archaius2-core/src/main/java/com/netflix/archaius/log/ArchaiusLoggerService.java @@ -0,0 +1,7 @@ +package com.netflix.archaius.log; + +public interface ArchaiusLoggerService { + + public ArchaiusLogger getLogger( + Class clazz); +} diff --git a/archaius2-core/src/main/java/com/netflix/archaius/log/NoOpLoggerFactory.java b/archaius2-core/src/main/java/com/netflix/archaius/log/NoOpLoggerFactory.java new file mode 100644 index 000000000..e37209b62 --- /dev/null +++ b/archaius2-core/src/main/java/com/netflix/archaius/log/NoOpLoggerFactory.java @@ -0,0 +1,117 @@ +package com.netflix.archaius.log; + +public class NoOpLoggerFactory implements ArchaiusLoggerService { + + @Override + public ArchaiusLogger getLogger( + Class clazz) { + return logger; + } + + private static ArchaiusLogger logger = new NoOpLogger(); + + private static class NoOpLogger implements ArchaiusLogger { + + @Override + public boolean isTraceEnabled() { + return false; + } + + @Override + public void trace( + String message) { + } + + @Override + public void trace( + String message, + Object... params) { + } + + @Override + public void trace( + String message, + Throwable error) { + } + + @Override + public boolean isDebugEnabled() { + return false; + } + + @Override + public void debug( + String message) { + } + + @Override + public void debug( + String message, + Object... params) { + } + + @Override + public void debug( + String message, + Throwable error) { + } + + @Override + public void info( + String message) { + } + + @Override + public void info( + String message, + Object... params) { + } + + @Override + public void info( + String message, + Throwable error) { + } + + @Override + public boolean isWarnEnabled() { + return false; + } + + @Override + public void warn( + String message) { + } + + @Override + public void warn( + String message, + Object... params) { + } + + @Override + public void warn( + String message, + Throwable error) { + } + + @Override + public void error( + String message) { + } + + @Override + public void error( + String message, + Object... params) { + } + + @Override + public void error( + String message, + Throwable error) { + } + + } + +} diff --git a/archaius2-core/src/main/java/com/netflix/archaius/property/DefaultPropertyContainer.java b/archaius2-core/src/main/java/com/netflix/archaius/property/DefaultPropertyContainer.java index 73d3146ea..699ad9601 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/property/DefaultPropertyContainer.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/property/DefaultPropertyContainer.java @@ -21,8 +21,8 @@ import com.netflix.archaius.api.PropertyListener; import com.netflix.archaius.property.ListenerManager.ListenerUpdater; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import java.math.BigDecimal; import java.math.BigInteger; @@ -47,7 +47,7 @@ * */ public class DefaultPropertyContainer implements PropertyContainer { - private final Logger LOG = LoggerFactory.getLogger(DefaultPropertyContainer.class); + private final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(DefaultPropertyContainer.class); enum Type { INTEGER (int.class, Integer.class), diff --git a/archaius2-core/src/main/java/com/netflix/archaius/readers/JDCConfigReader.java b/archaius2-core/src/main/java/com/netflix/archaius/readers/JDCConfigReader.java index 2f149a465..87dc0047b 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/readers/JDCConfigReader.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/readers/JDCConfigReader.java @@ -26,12 +26,12 @@ import javax.sql.DataSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; public class JDCConfigReader implements Callable> { - private static Logger log = LoggerFactory.getLogger(JDCConfigReader.class); + private static ArchaiusLogger log = ArchaiusLoggerFactory.getLogger(JDCConfigReader.class); // The datasource to connect to the database. private DataSource datasource; diff --git a/archaius2-core/src/main/java/com/netflix/archaius/readers/PropertiesConfigReader.java b/archaius2-core/src/main/java/com/netflix/archaius/readers/PropertiesConfigReader.java index 535c3398d..d4de5a2b0 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/readers/PropertiesConfigReader.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/readers/PropertiesConfigReader.java @@ -24,8 +24,8 @@ import com.netflix.archaius.config.DefaultCompositeConfig.Builder; import com.netflix.archaius.config.MapConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import java.io.File; import java.io.IOException; @@ -40,7 +40,7 @@ import java.util.Set; public class PropertiesConfigReader implements ConfigReader { - private static final Logger LOG = LoggerFactory.getLogger(PropertiesConfigReader.class); + private static final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(PropertiesConfigReader.class); private static final String INCLUDE_KEY = "@next"; private static final String SUFFIX = ".properties"; diff --git a/archaius2-core/src/main/java/com/netflix/archaius/visitor/SLF4JConfigVisitor.java b/archaius2-core/src/main/java/com/netflix/archaius/visitor/SLF4JConfigVisitor.java index 2c0d89262..71e7f660a 100644 --- a/archaius2-core/src/main/java/com/netflix/archaius/visitor/SLF4JConfigVisitor.java +++ b/archaius2-core/src/main/java/com/netflix/archaius/visitor/SLF4JConfigVisitor.java @@ -1,13 +1,13 @@ package com.netflix.archaius.visitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import com.netflix.archaius.log.ArchaiusLogger; +import com.netflix.archaius.log.ArchaiusLoggerFactory; import com.netflix.archaius.api.Config; import com.netflix.archaius.api.config.CompositeConfig; public class SLF4JConfigVisitor implements CompositeConfig.CompositeVisitor { - private static final Logger LOG = LoggerFactory.getLogger(SLF4JConfigVisitor.class); + private static final ArchaiusLogger LOG = ArchaiusLoggerFactory.getLogger(SLF4JConfigVisitor.class); private final String INDENT_STR = " "; private String currentIndent = "";