This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch karaf-4.4.x
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/karaf-4.4.x by this push:
new 97d40487d7 KARAF-7898: Use slf4j provider in Karaf client
97d40487d7 is described below
commit 97d40487d792943d8b6180175a1b8a84c639191f
Author: JB Onofré <[email protected]>
AuthorDate: Sat Jan 11 08:10:16 2025 +0100
KARAF-7898: Use slf4j provider in Karaf client
(cherry picked from commit 5dc767b60c339c7acd4927c1a4b5249b2b5a2455)
---
client/pom.xml | 13 ++--
.../java/org/slf4j/impl/SimpleServiceProvider.java | 58 ++++++++++++++++++
.../java/org/slf4j/impl/StaticLoggerBinder.java | 71 ----------------------
.../services/org.slf4j.spi.SLF4JServiceProvider | 19 ++++++
4 files changed, 85 insertions(+), 76 deletions(-)
diff --git a/client/pom.xml b/client/pom.xml
index f8ccf9381f..a6d263bb0c 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -76,6 +76,10 @@
<build>
<resources>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
<resource>
<directory>${project.basedir}/src/main/key</directory>
<filtering>false</filtering>
@@ -92,11 +96,10 @@
<Bundle-Name>Apache Karaf Shell Client</Bundle-Name>
<Bundle-Description>Shell client bundle for Apache
Karaf.</Bundle-Description>
<Private-Package>
- org.apache.karaf.client;
- org.slf4j*;
- org.apache.felix.utils.properties;
- org.apache.karaf.util.config;
- META-INF;-split-package:=merge-first
+ org.apache.karaf.client,
+ org.slf4j*,
+ org.apache.felix.utils.properties,
+ org.apache.karaf.util.config
</Private-Package>
<Include-Resource>
{maven-resources}
diff --git a/client/src/main/java/org/slf4j/impl/SimpleServiceProvider.java
b/client/src/main/java/org/slf4j/impl/SimpleServiceProvider.java
new file mode 100644
index 0000000000..f431364cb9
--- /dev/null
+++ b/client/src/main/java/org/slf4j/impl/SimpleServiceProvider.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.IMarkerFactory;
+import org.slf4j.helpers.BasicMarkerFactory;
+import org.slf4j.helpers.NOPMDCAdapter;
+import org.slf4j.spi.MDCAdapter;
+import org.slf4j.spi.SLF4JServiceProvider;
+
+public class SimpleServiceProvider implements SLF4JServiceProvider {
+
+ private ILoggerFactory loggerFactory;
+ private IMarkerFactory markerFactory;
+ private MDCAdapter mdcAdapter;
+
+ @Override
+ public ILoggerFactory getLoggerFactory() {
+ return loggerFactory;
+ }
+
+ @Override
+ public IMarkerFactory getMarkerFactory() {
+ return markerFactory;
+ }
+
+ @Override
+ public MDCAdapter getMDCAdapter() {
+ return mdcAdapter;
+ }
+
+ @Override
+ public String getRequestedApiVersion() {
+ return "2.0.99";
+ }
+
+ @Override
+ public void initialize() {
+ loggerFactory = new SimpleLoggerFactory();
+ markerFactory = new BasicMarkerFactory();
+ mdcAdapter = new NOPMDCAdapter();
+ }
+}
diff --git a/client/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
b/client/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
deleted file mode 100644
index ab906dff56..0000000000
--- a/client/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.slf4j.impl;
-
-import org.slf4j.ILoggerFactory;
-import org.slf4j.LoggerFactory;
-import org.slf4j.spi.LoggerFactoryBinder;
-
-/**
- * The binding of {@link LoggerFactory} class with an actual instance of
- * {@link ILoggerFactory} is performed using information returned by this
class.
- */
-public class StaticLoggerBinder implements LoggerFactoryBinder {
-
- /**
- * The unique instance of this class.
- *
- */
- private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
-
- /**
- * Return the singleton of this class.
- *
- * @return the StaticLoggerBinder singleton
- */
- public static final StaticLoggerBinder getSingleton() {
- return SINGLETON;
- }
-
-
- /**
- * 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
-
- private static final String loggerFactoryClassStr =
SimpleLoggerFactory.class.getName();
-
- /**
- * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
- * method should always be the same object
- */
- private final ILoggerFactory loggerFactory;
-
- private StaticLoggerBinder() {
- loggerFactory = new SimpleLoggerFactory();
- }
-
- public ILoggerFactory getLoggerFactory() {
- return loggerFactory;
- }
-
- public String getLoggerFactoryClassStr() {
- return loggerFactoryClassStr;
- }
-}
diff --git
a/client/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
b/client/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
new file mode 100644
index 0000000000..a0a5ef6485
--- /dev/null
+++
b/client/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider
@@ -0,0 +1,19 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+org.slf4j.impl.SimpleServiceProvider
\ No newline at end of file