481708 - replaces ch.qos.logback.slf4j with org.eclipse.virgo.medig.slf4japifragment
diff --git a/build.gradle b/build.gradle index 457da90..3df5d3a 100644 --- a/build.gradle +++ b/build.gradle
@@ -13,7 +13,7 @@ testCompile group: 'org.easymock', name: 'easymock', version: easymockVersion testCompile project(':test:org.eclipse.virgo.test.stubs') - testRuntime group: "org.eclipse.virgo.mirrored", name: "ch.qos.logback.slf4j", version: logbackVersion, configuration: "compile", ext: "jar" + // testRuntime group: "org.eclipse.virgo.mirrored", name: "ch.qos.logback.slf4j", version: logbackVersion, configuration: "compile", ext: "jar" testRuntime "org.aspectj:aspectjrt:${project.aspectjVersion}" compile project(':medic:org.eclipse.virgo.medic') @@ -27,8 +27,19 @@ compile 'org.fusesource.jansi:jansi:1.11' - compile group: "org.eclipse.virgo.mirrored", name: "ch.qos.logback.core", version: logbackVersion, configuration: "compile", ext: "jar" - compile group: "org.eclipse.virgo.mirrored", name: "ch.qos.logback.classic", version: logbackVersion, configuration: "compile", ext: "jar" +// compile group: "org.eclipse.virgo.mirrored", name: "ch.qos.logback.core", version: logbackVersion, configuration: "compile", ext: "jar" +// compile group: "org.eclipse.virgo.mirrored", name: "ch.qos.logback.classic", version: logbackVersion, configuration: "compile", ext: "jar" + compile 'ch.qos.logback:logback-core:1.1.3' + compile 'ch.qos.logback:logback-classic:1.1.3' + } +} + +project(':medic:org.eclipse.virgo.medic.slf4japifragment') { + dependencies { + compile group: "org.eclipse.virgo.mirrored", name: "org.slf4j.api", version: slf4jVersion, configuration: "compile", ext: "jar" + + compile 'ch.qos.logback:logback-core:1.1.3' + compile 'ch.qos.logback:logback-classic:1.1.3' } }
diff --git a/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticLoggerBinder.java new file mode 100644 index 0000000..fe80bb7 --- /dev/null +++ b/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -0,0 +1,115 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2009, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package org.slf4j.impl; + +import org.slf4j.ILoggerFactory; +import org.slf4j.LoggerFactory; +import org.slf4j.helpers.Util; +import org.slf4j.spi.LoggerFactoryBinder; + +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.classic.util.ContextInitializer; +import ch.qos.logback.classic.util.ContextSelectorStaticBinder; +import ch.qos.logback.core.CoreConstants; +import ch.qos.logback.core.joran.spi.JoranException; +import ch.qos.logback.core.util.StatusPrinter; + +/** + * + * The binding of {@link LoggerFactory} class with an actual instance of + * {@link ILoggerFactory} is performed using information returned by this class. + * + * @author <a href="http://www.qos.ch/shop/products/log4jManual">Ceki + * Gülcü</a> + */ +public class StaticLoggerBinder implements LoggerFactoryBinder { + + /** + * Declare the version of the SLF4J API this implementation is compiled + * against. The value of this field is usually modified with each release. + */ + // to avoid constant folding by the compiler, this field must *not* be final + public static String REQUESTED_API_VERSION = "1.6"; // !final + + final static String NULL_CS_URL = CoreConstants.CODES_URL + "#null_CS"; + + /** + * The unique instance of this class. + */ + private static StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); + + private static Object KEY = new Object(); + + static { + SINGLETON.init(); + } + + private boolean initialized = false; + private LoggerContext defaultLoggerContext = new LoggerContext(); + private final ContextSelectorStaticBinder contextSelectorBinder = ContextSelectorStaticBinder + .getSingleton(); + + private StaticLoggerBinder() { + defaultLoggerContext.setName(CoreConstants.DEFAULT_CONTEXT_NAME); + } + + public static StaticLoggerBinder getSingleton() { + return SINGLETON; + } + + /** + * Package access for testing purposes. + */ + static void reset() { + SINGLETON = new StaticLoggerBinder(); + SINGLETON.init(); + } + + /** + * Package access for testing purposes. + */ + void init() { + try { + try { + new ContextInitializer(defaultLoggerContext).autoConfig(); + } catch (JoranException je) { + Util.report("Failed to auto configure default logger context", je); + } + StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext); + contextSelectorBinder.init(defaultLoggerContext, KEY); + initialized = true; + } catch (Throwable t) { + // we should never get here + Util.report("Failed to instantiate [" + LoggerContext.class.getName() + + "]", t); + } + } + + public ILoggerFactory getLoggerFactory() { + if (!initialized) { + return defaultLoggerContext; + } + + if (contextSelectorBinder.getContextSelector() == null) { + throw new IllegalStateException( + "contextSelector cannot be null. See also " + NULL_CS_URL); + } + return contextSelectorBinder.getContextSelector().getLoggerContext(); + } + + public String getLoggerFactoryClassStr() { + return contextSelectorBinder.getContextSelector().getClass().getName(); + } + +}
diff --git a/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMDCBinder.java new file mode 100644 index 0000000..70c13b0 --- /dev/null +++ b/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMDCBinder.java
@@ -0,0 +1,48 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2009, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package org.slf4j.impl; + +import org.slf4j.spi.MDCAdapter; + +import ch.qos.logback.classic.util.LogbackMDCAdapter; + + +/** + * This implementation is bound to {@link LogbackMDCAdapter}. + * + * @author Ceki Gülcü + */ +public class StaticMDCBinder { + + + /** + * The unique instance of this class. + */ + public static final StaticMDCBinder SINGLETON = new StaticMDCBinder(); + + private StaticMDCBinder() { + } + + /** + * Currently this method always returns an instance of + * {@link StaticMDCBinder}. + */ + public MDCAdapter getMDCA() { + return new LogbackMDCAdapter(); + } + + public String getMDCAdapterClassStr() { + return LogbackMDCAdapter.class.getName(); + } +}
diff --git a/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMarkerBinder.java new file mode 100644 index 0000000..8be32ee --- /dev/null +++ b/org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
@@ -0,0 +1,57 @@ +/** + * Logback: the reliable, generic, fast and flexible logging framework. + * Copyright (C) 1999-2009, QOS.ch. All rights reserved. + * + * This program and the accompanying materials are dual-licensed under + * either the terms of the Eclipse Public License v1.0 as published by + * the Eclipse Foundation + * + * or (per the licensee's choosing) + * + * under the terms of the GNU Lesser General Public License version 2.1 + * as published by the Free Software Foundation. + */ +package org.slf4j.impl; + +import org.slf4j.IMarkerFactory; +import org.slf4j.MarkerFactory; +import org.slf4j.helpers.BasicMarkerFactory; +import org.slf4j.spi.MarkerFactoryBinder; + +/** + * + * The binding of {@link MarkerFactory} class with an actual instance of + * {@link IMarkerFactory} is performed using information returned by this class. + * + * @author Ceki Gülcü + */ +public class StaticMarkerBinder implements MarkerFactoryBinder { + + /** + * The unique instance of this class. + */ + public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder(); + + final IMarkerFactory markerFactory = new BasicMarkerFactory(); + + private StaticMarkerBinder() { + } + + /** + * Currently this method always returns an instance of + * {@link BasicMarkerFactory}. + */ + public IMarkerFactory getMarkerFactory() { + return markerFactory; + } + + /** + * Currently, this method returns the class name of + * {@link BasicMarkerFactory}. + */ + public String getMarkerFactoryClassStr() { + return BasicMarkerFactory.class.getName(); + } + + +}
diff --git a/org.eclipse.virgo.medic.slf4japifragment/template.mf b/org.eclipse.virgo.medic.slf4japifragment/template.mf new file mode 100644 index 0000000..93ce5b1 --- /dev/null +++ b/org.eclipse.virgo.medic.slf4japifragment/template.mf
@@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-Vendor: fake +Bundle-Localization: fragment +Fragment-Host: org.slf4j.api;bundle-version="[1.7.2,1.7.3)" +Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6,JavaSE-1.7 +Bundle-Name: fake +Bundle-SymbolicName: org.eclipse.virgo.medic.slf4japifragment +Require-Bundle: ch.qos.logback.core;bundle-version="[1.0.7,1.0.8)",ch. + qos.logback.classic;bundle-version="[1.0.7,1.0.8)" +Export-Package: org.slf4j.impl; uses:="org.slf4j.spi,ch.qos.logback.cl + assic.util,org.slf4j.helpers,ch.qos.logback.classic,ch.qos.logback.co + re,ch.qos.logback.classic.selector,ch.qos.logback.core.joran.spi,org. + slf4j,ch.qos.logback.core.util";version="1.7.2" +Bundle-Version: ${version} +Bundle-ManifestVersion: 2 +Excluded-Imports: *