Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2017-01-25 01:57:41 -0500
committerFlorian Waibel2017-01-25 01:57:41 -0500
commitbbc14ebe3fe87c940953878427968ec13d0e8203 (patch)
tree88762ffa10f2f968e5ce1863c9153839eece5e3b
parenta93360db0b2f6361ee04f31f317ab094d94badb0 (diff)
downloadorg.eclipse.virgo.medic-bbc14ebe3fe87c940953878427968ec13d0e8203.tar.gz
org.eclipse.virgo.medic-bbc14ebe3fe87c940953878427968ec13d0e8203.tar.xz
org.eclipse.virgo.medic-bbc14ebe3fe87c940953878427968ec13d0e8203.zip
Revert "Remove slf4j API fragment"
-rw-r--r--build.gradle9
-rw-r--r--org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticLoggerBinder.java115
-rw-r--r--org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMDCBinder.java48
-rw-r--r--org.eclipse.virgo.medic.slf4japifragment/src/main/java/org/slf4j/impl/StaticMarkerBinder.java57
-rw-r--r--org.eclipse.virgo.medic.slf4japifragment/src/main/resources/about.html28
-rw-r--r--org.eclipse.virgo.medic.slf4japifragment/template.mf16
6 files changed, 273 insertions, 0 deletions
diff --git a/build.gradle b/build.gradle
index 986b213..ee7fc52 100644
--- a/build.gradle
+++ b/build.gradle
@@ -31,6 +31,15 @@ project(':medic:org.eclipse.virgo.medic.core') {
}
}
+project(':medic:org.eclipse.virgo.medic.slf4japifragment') {
+ dependencies {
+ compile group: "org.slf4j", name: "slf4j-api", version: slf4jVersion
+
+ compile "ch.qos.logback:logback-core:${logbackVersion}"
+ compile "ch.qos.logback:logback-classic:${logbackVersion}"
+ }
+}
+
project(':medic:org.eclipse.virgo.medic.test') {
dependencies {
compile project(':medic:org.eclipse.virgo.medic')
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&uuml;lc&uuml;</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&uuml;lc&uuml;
+ */
+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&uuml;lc&uuml;
+ */
+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/src/main/resources/about.html b/org.eclipse.virgo.medic.slf4japifragment/src/main/resources/about.html
new file mode 100644
index 0000000..c258ef5
--- /dev/null
+++ b/org.eclipse.virgo.medic.slf4japifragment/src/main/resources/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/org.eclipse.virgo.medic.slf4japifragment/template.mf b/org.eclipse.virgo.medic.slf4japifragment/template.mf
new file mode 100644
index 0000000..0316a5e
--- /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: slf4j.api;bundle-version="${slf4jVersion:[=.=.=, +1.0.0)}"
+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="${logbackVersion:[=.=.=, +1.0.0)}",ch.
+ qos.logback.classic;bundle-version="${logbackVersion:[=.=.=, +1.0.0)}"
+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="${slf4jVersion}"
+Bundle-Version: ${version}
+Bundle-ManifestVersion: 2
+Excluded-Imports: *

Back to the top