Author: ceki Date: Thu Oct 2 20:39:00 2008 New Revision: 1166 Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/ext/XLoggerFactory.java slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java slf4j/trunk/slf4j-site/src/site/pages/news.html
Log: - Adding version check support in each slf4j-binding Each copy of StaticLoggerBinder.java found in each binding now contains a field called VERSION. LoggerFactory checks that the version value found in the binding matches the expected version number as declared in LoggerFactory Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java ============================================================================== --- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java (original) +++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/LoggerFactory.java Thu Oct 2 20:39:00 2008 @@ -49,7 +49,10 @@ static final String NO_STATICLOGGERBINDER_URL = "http://www.slf4j.org/codes.html#StaticLoggerBinder"; static final String NULL_LF_URL = "http://www.slf4j.org/codes.html#null_LF"; - + static final String VERSION_MISMATCH = "http://www.slf4j.org/codes.html#version_mismatch"; + + static private final String EXPECTED_VERSION = ""; + // private constructor prevents instantiation private LoggerFactory() { } @@ -57,6 +60,16 @@ static { try { + String actualVer = StaticLoggerBinder.VERSION; + if(EXPECTED_VERSION.equals(actualVer)) { + Util.reportFailure("Actual version "+actualVer+" differs from expected version "+EXPECTED_VERSION); + Util.reportFailure("See "+VERSION_MISMATCH+" for further details."); + } + } catch(Exception e) { + e.printStackTrace(); + } + + try { loggerFactory = StaticLoggerBinder.SINGLETON.getLoggerFactory(); } catch(NoClassDefFoundError ncde) { String msg = ncde.getMessage(); Modified: slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java ============================================================================== --- slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original) +++ slf4j/trunk/slf4j-api/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Thu Oct 2 20:39:00 2008 @@ -42,7 +42,13 @@ * The unique instance of this class. */ public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - + + /** + * Version tag used to check compatibility. The value of this field is + * modified in each release. + */ + public static final String VERSION = "1.5.4-SNAPSHOT"; + private StaticLoggerBinder() { throw new UnsupportedOperationException("This code should have never made it into the jar"); } Modified: slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/ext/XLoggerFactory.java ============================================================================== --- slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/ext/XLoggerFactory.java (original) +++ slf4j/trunk/slf4j-ext/src/main/java/org/slf4j/ext/XLoggerFactory.java Thu Oct 2 20:39:00 2008 @@ -19,10 +19,23 @@ */ public class XLoggerFactory { + /** + * Get an XLogger instance by name. + * + * @param name + * @return + */ public static XLogger getXLogger(String name) { return new XLogger(LoggerFactory.getLogger(name)); } + /** + * Get a new XLogger instance by class. The returned XLogger + * will be named after the class. + * + * @param clazz + * @return + */ @SuppressWarnings("unchecked") public static Logger getXLogger(Class clazz) { return getXLogger(clazz.getName()); Modified: slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java ============================================================================== --- slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original) +++ slf4j/trunk/slf4j-jcl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Thu Oct 2 20:39:00 2008 @@ -38,8 +38,8 @@ import org.slf4j.spi.LoggerFactoryBinder; /** - * The binding of [EMAIL PROTECTED] LoggerFactory} class with an actual instance of - * [EMAIL PROTECTED] ILoggerFactory} is performed using information returned by this class. + * The binding of [EMAIL PROTECTED] LoggerFactory} class with an actual instance of + * [EMAIL PROTECTED] ILoggerFactory} is performed using information returned by this class. * * @author Ceki Gülcü */ @@ -50,24 +50,32 @@ */ public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); + /** + * Version tag used to check compatibility. The value of this field is + * modified in each release. + */ + public static final String VERSION = "1.5.4-SNAPSHOT"; + // Binding specific code: - private static final String loggerFactoryClassStr = JCLLoggerFactory.class.getName(); + private static final String loggerFactoryClassStr = JCLLoggerFactory.class + .getName(); - /** The ILoggerFactory instance returned by the [EMAIL PROTECTED] #getLoggerFactory} method - * should always be the same object + /** + * The ILoggerFactory instance returned by the [EMAIL PROTECTED] #getLoggerFactory} + * method should always be the same object */ private final ILoggerFactory loggerFactory; - + private StaticLoggerBinder() { - // Binding specific code: + // Binding specific code: loggerFactory = new JCLLoggerFactory(); } - + public ILoggerFactory getLoggerFactory() { return loggerFactory; } - + public String getLoggerFactoryClassStr() { return loggerFactoryClassStr; - } + } } Modified: slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java ============================================================================== --- slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original) +++ slf4j/trunk/slf4j-jdk14/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Thu Oct 2 20:39:00 2008 @@ -49,7 +49,12 @@ * The unique instance of this class. */ public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task + /** + * Version tag used to check compatibility. The value of this field is + * modified in each release. + */ + public static final String VERSION = "1.5.4-SNAPSHOT"; + private static final String loggerFactoryClassStr = org.slf4j.impl.JDK14LoggerFactory.class.getName(); /** The ILoggerFactory instance returned by the [EMAIL PROTECTED] #getLoggerFactory} method Modified: slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java ============================================================================== --- slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original) +++ slf4j/trunk/slf4j-log4j12/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Thu Oct 2 20:39:00 2008 @@ -50,7 +50,13 @@ * The unique instance of this class. */ public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task + + /** + * Version tag used to check compatibility. The value of this field is + * modified in each release. + */ + public static final String VERSION = "1.5.4-SNAPSHOT"; + private static final String loggerFactoryClassStr = Log4jLoggerFactory.class.getName(); /** The ILoggerFactory instance returned by the [EMAIL PROTECTED] #getLoggerFactory} method Modified: slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java ============================================================================== --- slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original) +++ slf4j/trunk/slf4j-nop/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Thu Oct 2 20:39:00 2008 @@ -43,13 +43,19 @@ * * @author Ceki Gülcü */ -public class StaticLoggerBinder implements LoggerFactoryBinder { +public class StaticLoggerBinder implements LoggerFactoryBinder { /** * The unique instance of this class. */ public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task + + /** + * Version tag used to check compatibility. The value of this field is + * modified in each release. + */ + public static final String VERSION = "1.5.4-SNAPSHOT"; + private static final String loggerFactoryClassStr = NOPLoggerFactory.class.getName(); /** The ILoggerFactory instance returned by the [EMAIL PROTECTED] #getLoggerFactory} method Modified: slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java ============================================================================== --- slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java (original) +++ slf4j/trunk/slf4j-simple/src/main/java/org/slf4j/impl/StaticLoggerBinder.java Thu Oct 2 20:39:00 2008 @@ -41,7 +41,12 @@ * The unique instance of this class. */ public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - // Note: JCL gets substituted at build time by an appropriate Ant task + /** + * Version tag used to check compatibility. The value of this field is + * modified in each release. + */ + public static final String VERSION = "1.5.4-SNAPSHOT"; + private static final String loggerFactoryClassStr = SimpleLoggerFactory.class.getName(); /** The ILoggerFactory instance returned by the [EMAIL PROTECTED] #getLoggerFactory} method Modified: slf4j/trunk/slf4j-site/src/site/pages/news.html ============================================================================== --- slf4j/trunk/slf4j-site/src/site/pages/news.html (original) +++ slf4j/trunk/slf4j-site/src/site/pages/news.html Thu Oct 2 20:39:00 2008 @@ -27,7 +27,7 @@ <hr noshade="noshade" size="1"/> - <h3>September xxth, 2008 - Release of SLF4J 1.5.4</h3> + <h3>October xxth, 2008 - Release of SLF4J 1.5.4</h3> <p>See also the <a href="compatibility.html#1_5_3">compatibility report for this version</a>. _______________________________________________ dev mailing list dev@slf4j.org http://www.slf4j.org/mailman/listinfo/dev