diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml
index e3acc684f9..2443e079bc 100644
--- a/.github/workflows/maven-ci.yml
+++ b/.github/workflows/maven-ci.yml
@@ -7,13 +7,15 @@ on:
- 'scr/**'
- 'http/**'
- 'tools/maven-bundle-plugin/**'
+ - 'log/**'
pull_request:
branches: [ "master" ]
paths:
- 'scr/**'
- 'http/**'
- 'tools/maven-bundle-plugin/**'
-
+ - 'log/**'
+
permissions: {}
jobs:
@@ -30,7 +32,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@d6af6abeda15e98926a57b5aa970a96bb37f97d1 # v5
with:
- maven-version: 3.9.7
+ maven-version: 3.9.9
- name: Check which subproject changed and build affected ones
uses: dorny/paths-filter@v3
id: changes
@@ -42,10 +44,15 @@ jobs:
- 'http/**'
maven-bundle-plugin:
- 'tools/maven-bundle-plugin/**'
+ log:
+ - 'log/**'
- name: Felix SCR
if: steps.changes.outputs.scr == 'true'
run: mvn -B -V -Dstyle.color=always --file scr/pom.xml clean verify
+ - name: Felix Log
+ if: steps.changes.outputs.log == 'true'
+ run: mvn -B -V -Dstyle.color=always --file log/pom.xml clean verify
- name: Felix HTTP
if: steps.changes.outputs.http == 'true'
run: mvn -B -V -Dstyle.color=always "-Dit.test=!MissingWebsocketDependenciesIT" --file http/pom.xml clean install verify
diff --git a/log/pom.xml b/log/pom.xml
index 70b132a877..77174b8ee0 100644
--- a/log/pom.xml
+++ b/log/pom.xml
@@ -20,7 +20,7 @@
org.apache.felix
felix-parent
- 6
+ 9
../pom/pom.xml
4.0.0
@@ -49,36 +49,52 @@
org.osgi
osgi.core
6.0.0
+ provided
+
+
+ org.osgi
+ org.osgi.service.cm
+ 1.6.0
+ provided
org.osgi
org.osgi.service.log
1.5.0
+
+ org.osgi
+ osgi.annotation
+ 8.1.0
+ provided
+
+
+ org.osgi
+ org.osgi.namespace.service
+ 1.0.0
+ provided
+
+
+ org.osgi
+ org.osgi.service.component.annotations
+ 1.5.1
+ provided
+
org.apache.felix
maven-bundle-plugin
- 3.5.0
+ 6.0.0
true
org.osgi.service.log,org.osgi.service.log.admin
- org.apache.felix.log
- ${pom.artifactId}
- ${pom.artifactId}.Activator
+ ${project.artifactId}
The Apache Software Foundation
META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES
-
- ="org.osgi.service.log.LogReaderService";uses:="org.osgi.service.log,org.osgi.service.log.admin",
- osgi.service;objectClass:List="org.osgi.service.log.LogService,org.osgi.service.log.LoggerFactory";uses:="org.osgi.service.log,org.osgi.service.log.admin",
- osgi.service;objectClass:List="org.osgi.service.log.admin.LoggerAdmin";uses:="org.osgi.service.log,org.osgi.service.log.admin"
- ]]>
+ <_reproducible>true
diff --git a/log/src/main/java/org/apache/felix/log/Activator.java b/log/src/main/java/org/apache/felix/log/Activator.java
index b1c0a50033..506971ffb4 100644
--- a/log/src/main/java/org/apache/felix/log/Activator.java
+++ b/log/src/main/java/org/apache/felix/log/Activator.java
@@ -21,10 +21,14 @@
import java.util.Dictionary;
import java.util.Hashtable;
+import org.osgi.annotation.bundle.Header;
+import org.osgi.annotation.bundle.Requirement;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.namespace.service.ServiceNamespace;
+import org.osgi.resource.Namespace;
import org.osgi.service.log.LogLevel;
import org.osgi.service.log.LogReaderService;
import org.osgi.service.log.LogService;
@@ -54,6 +58,10 @@
* the historic log information. The default value is false.
*
*/
+@Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}")
+@Requirement(namespace = ServiceNamespace.SERVICE_NAMESPACE,
+ filter = "(objectClass=org.osgi.service.cm.ConfigurationAdmin)",
+ effective = Namespace.EFFECTIVE_ACTIVE)
public final class Activator implements BundleActivator
{
/** The name of the property that defines the maximum size of the log. */
@@ -108,7 +116,7 @@ private static boolean getStoreDebug(final BundleContext context)
String storeDebugPropValue = context.getProperty(STORE_DEBUG_PROPERTY);
if (storeDebugPropValue != null)
{
- storeDebug = Boolean.valueOf(storeDebugPropValue).booleanValue();
+ storeDebug = Boolean.parseBoolean(storeDebugPropValue);
}
return storeDebug;
diff --git a/log/src/main/java/org/apache/felix/log/ConfigurationListenerImpl.java b/log/src/main/java/org/apache/felix/log/ConfigurationListenerImpl.java
index 489cc74145..729f1b389f 100644
--- a/log/src/main/java/org/apache/felix/log/ConfigurationListenerImpl.java
+++ b/log/src/main/java/org/apache/felix/log/ConfigurationListenerImpl.java
@@ -52,7 +52,7 @@ public class ConfigurationListenerImpl {
final Log m_log;
final LoggerAdminImpl m_loggerAdmin;
- public ConfigurationListenerImpl(final BundleContext context, final Log log, final LoggerAdminImpl loggerAdmin) throws Exception {
+ ConfigurationListenerImpl(final BundleContext context, final Log log, final LoggerAdminImpl loggerAdmin) throws Exception {
m_context = context;
m_log = log;
m_loggerAdmin = loggerAdmin;
diff --git a/log/src/main/java/org/apache/felix/log/FormatterLoggerImpl.java b/log/src/main/java/org/apache/felix/log/FormatterLoggerImpl.java
index dda2667733..0ff256bf9d 100644
--- a/log/src/main/java/org/apache/felix/log/FormatterLoggerImpl.java
+++ b/log/src/main/java/org/apache/felix/log/FormatterLoggerImpl.java
@@ -26,12 +26,13 @@
public class FormatterLoggerImpl extends LoggerImpl implements FormatterLogger {
- public FormatterLoggerImpl(
+ FormatterLoggerImpl(
final String name, final Bundle bundle, final Log log, final LoggerAdminImpl loggerAdmin) {
super(name, bundle, log, loggerAdmin);
}
+ @Override
String format(String format, LogParameters logParameters) {
StringBuilder sb = new StringBuilder();
diff --git a/log/src/main/java/org/apache/felix/log/Log.java b/log/src/main/java/org/apache/felix/log/Log.java
index a92f596f7c..4ab9610d05 100644
--- a/log/src/main/java/org/apache/felix/log/Log.java
+++ b/log/src/main/java/org/apache/felix/log/Log.java
@@ -206,7 +206,7 @@ synchronized Enumeration getEntries()
"FrameworkEvent STARTED",
"FrameworkEvent ERROR",
"FrameworkEvent PACKAGES REFRESHED",
- "FrameworkEvent STARTLEVEL CHANGED",
+ "FrameworkEvent STARTLEVEL CHANGED",
"FrameworkEvent WARNING",
"FrameworkEvent INFO"
};
diff --git a/log/src/main/java/org/apache/felix/log/LogEntryImpl.java b/log/src/main/java/org/apache/felix/log/LogEntryImpl.java
index 2d98b9298e..2198e97765 100644
--- a/log/src/main/java/org/apache/felix/log/LogEntryImpl.java
+++ b/log/src/main/java/org/apache/felix/log/LogEntryImpl.java
@@ -143,6 +143,7 @@ final class LogEntryImpl implements LogEntry
* @return the bundle that created this LogEntry object;null
if no
* bundle is associated with this LogEntry object
*/
+ @Override
public Bundle getBundle()
{
return m_bundle;
@@ -155,6 +156,7 @@ public Bundle getBundle()
* this LogEntry object; null
if no {@link ServiceReference} object
* was provided
*/
+ @Override
public ServiceReference> getServiceReference()
{
return m_serviceReference;
@@ -171,6 +173,7 @@ public ServiceReference> getServiceReference()
* @see org.osgi.service.LogService#LOG_INFO
* @see org.osgi.service.LogService#LOG_DEBUG
*/
+ @Override
public int getLevel()
{
if (m_legacyLevel != m_level.ordinal()) {
@@ -184,6 +187,7 @@ public int getLevel()
* Returns the human readable message associated with this LogEntry object.
* @return a string containing the message associated with this LogEntry object
*/
+ @Override
public String getMessage()
{
return m_message;
@@ -202,6 +206,7 @@ public String getMessage()
* @return throwable object of the exception associated with this LogEntry;
* null
if no exception is associated with this LogEntry object
*/
+ @Override
public Throwable getException()
{
return m_exception;
@@ -213,6 +218,7 @@ public Throwable getException()
* @return the system time in milliseconds when this LogEntry object was created
* @see System#currentTimeMillis()
*/
+ @Override
public long getTime()
{
return m_time;
diff --git a/log/src/main/java/org/apache/felix/log/LogListenerThread.java b/log/src/main/java/org/apache/felix/log/LogListenerThread.java
index 588f1e739a..34ee75ad7d 100644
--- a/log/src/main/java/org/apache/felix/log/LogListenerThread.java
+++ b/log/src/main/java/org/apache/felix/log/LogListenerThread.java
@@ -106,6 +106,7 @@ void shutdown()
* The main method of the thread: waits for new messages to be receieved
* and then delivers them to any registered log listeners.
*/
+ @Override
public void run()
{
while (!isInterrupted())
@@ -138,10 +139,10 @@ public void run()
{
// Take a snapshot of all current listeners and deliver all
// pending messages to them...
- List listeners = new ArrayList<>();
+ List listeners;
synchronized (m_listeners)
{
- listeners.addAll(m_listeners);
+ listeners = new ArrayList<>(m_listeners);
}
Iterator entriesIt = entriesToDeliver.iterator();
diff --git a/log/src/main/java/org/apache/felix/log/LogNodeEnumeration.java b/log/src/main/java/org/apache/felix/log/LogNodeEnumeration.java
index 39f067e973..8560b71e5c 100644
--- a/log/src/main/java/org/apache/felix/log/LogNodeEnumeration.java
+++ b/log/src/main/java/org/apache/felix/log/LogNodeEnumeration.java
@@ -48,6 +48,7 @@ final class LogNodeEnumeration implements Enumeration
* Determines whether there are any more elements to return.
* @return true
if there are more elements; false
otherwise
*/
+ @Override
public boolean hasMoreElements()
{
return m_next != null;
@@ -57,6 +58,7 @@ public boolean hasMoreElements()
* Returns the current element and moves onto the next element.
* @return the current element
*/
+ @Override
public LogEntry nextElement()
{
LogEntry result = null;
diff --git a/log/src/main/java/org/apache/felix/log/LogReaderServiceFactory.java b/log/src/main/java/org/apache/felix/log/LogReaderServiceFactory.java
index 12677ba35e..5193c66704 100644
--- a/log/src/main/java/org/apache/felix/log/LogReaderServiceFactory.java
+++ b/log/src/main/java/org/apache/felix/log/LogReaderServiceFactory.java
@@ -47,6 +47,7 @@ final class LogReaderServiceFactory implements ServiceFactory
* @param registration the service registration
* @return the log reader service implementation for the specified bundle
*/
+ @Override
public LogReaderService getService(final Bundle bundle,
final ServiceRegistration registration)
{
@@ -60,6 +61,7 @@ public LogReaderService getService(final Bundle bundle,
* @param registration the service registration
* @param service the service to release
*/
+ @Override
public void ungetService(final Bundle bundle,
final ServiceRegistration registration,
final LogReaderService service)
diff --git a/log/src/main/java/org/apache/felix/log/LogReaderServiceImpl.java b/log/src/main/java/org/apache/felix/log/LogReaderServiceImpl.java
index d5ce5f4823..46547df7a4 100644
--- a/log/src/main/java/org/apache/felix/log/LogReaderServiceImpl.java
+++ b/log/src/main/java/org/apache/felix/log/LogReaderServiceImpl.java
@@ -23,6 +23,8 @@
import java.util.List;
import java.util.Vector;
+import org.osgi.annotation.bundle.Capability;
+import org.osgi.namespace.service.ServiceNamespace;
import org.osgi.service.log.LogEntry;
import org.osgi.service.log.LogListener;
import org.osgi.service.log.LogReaderService;
@@ -37,6 +39,11 @@
* notifications about {@link org.osgi.service.log.LogEntry} objects when they are created
* through the {@link org.osgi.service.log.LogService}.
*/
+@Capability(
+ namespace = ServiceNamespace.SERVICE_NAMESPACE,
+ attribute = { "objectClass:List=\"org.osgi.service.log.LogReaderService\"" },
+ uses = { LogReaderServiceImpl.class, LogReaderService.class }
+)
final class LogReaderServiceImpl implements LogReaderService
{
/** The log implementation. */
diff --git a/log/src/main/java/org/apache/felix/log/LogServiceFactory.java b/log/src/main/java/org/apache/felix/log/LogServiceFactory.java
index 132f386b5d..210d1ee7ef 100644
--- a/log/src/main/java/org/apache/felix/log/LogServiceFactory.java
+++ b/log/src/main/java/org/apache/felix/log/LogServiceFactory.java
@@ -34,7 +34,7 @@ final class LogServiceFactory implements ServiceFactory
/**
* Create a new instance.
- * @param log the log to associate the service implementations with.,
+ * @param loggerAdminImpl
*/
LogServiceFactory(final LoggerAdminImpl loggerAdminImpl)
{
diff --git a/log/src/main/java/org/apache/felix/log/LogServiceImpl.java b/log/src/main/java/org/apache/felix/log/LogServiceImpl.java
index 7a9acf3282..21219a4323 100644
--- a/log/src/main/java/org/apache/felix/log/LogServiceImpl.java
+++ b/log/src/main/java/org/apache/felix/log/LogServiceImpl.java
@@ -18,14 +18,23 @@
*/
package org.apache.felix.log;
+import org.osgi.annotation.bundle.Capability;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
+import org.osgi.namespace.service.ServiceNamespace;
import org.osgi.service.log.LogService;
import org.osgi.service.log.Logger;
+import org.osgi.service.log.LoggerFactory;
+import org.osgi.service.log.admin.LoggerAdmin;
/**
* Implementation of the OSGi {@link LogService}.
*/
+@Capability(
+ namespace = ServiceNamespace.SERVICE_NAMESPACE,
+ attribute = { "objectClass:List=\"org.osgi.service.log.LogService,org.osgi.service.log.LoggerFactory\"" },
+ uses = { LogServiceImpl.class, LogService.class, LoggerFactory.class, LoggerAdmin.class }
+)
final class LogServiceImpl implements LogService
{
/** The bundle associated with this implementation. */
@@ -35,9 +44,8 @@ final class LogServiceImpl implements LogService
/**
* Create a new instance.
- * @param log the log implementation
* @param bundle the bundle associated with this implementation
- * @param serviceReference
+ * @param loggerAdminImpl
*/
LogServiceImpl(final Bundle bundle, final LoggerAdminImpl loggerAdminImpl)
{
diff --git a/log/src/main/java/org/apache/felix/log/LoggerAdminImpl.java b/log/src/main/java/org/apache/felix/log/LoggerAdminImpl.java
index aa53e37f8d..0d6bfbb3fe 100644
--- a/log/src/main/java/org/apache/felix/log/LoggerAdminImpl.java
+++ b/log/src/main/java/org/apache/felix/log/LoggerAdminImpl.java
@@ -24,12 +24,19 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import org.osgi.annotation.bundle.Capability;
import org.osgi.framework.Bundle;
+import org.osgi.namespace.service.ServiceNamespace;
import org.osgi.service.log.FormatterLogger;
import org.osgi.service.log.Logger;
import org.osgi.service.log.admin.LoggerAdmin;
import org.osgi.service.log.admin.LoggerContext;
+@Capability(
+ namespace = ServiceNamespace.SERVICE_NAMESPACE,
+ attribute = { "objectClass:List=\"org.osgi.service.log.admin.LoggerAdmin\"" },
+ uses = { LoggerAdminImpl.class, LoggerAdmin.class }
+)
public class LoggerAdminImpl implements LoggerAdmin {
private final Log m_log;
@@ -37,7 +44,7 @@ public class LoggerAdminImpl implements LoggerAdmin {
private final ConcurrentMap m_contexts = new ConcurrentHashMap<>();
private final ConcurrentMap _loggers = new ConcurrentHashMap<>();
- public LoggerAdminImpl(final String defaultLogLevelString, final Log log) {
+ LoggerAdminImpl(final String defaultLogLevelString, final Log log) {
m_rootContext = new RootLoggerContextImpl(defaultLogLevelString, this);
m_log = log;
}
diff --git a/log/src/main/java/org/apache/felix/log/LoggerContextImpl.java b/log/src/main/java/org/apache/felix/log/LoggerContextImpl.java
index d26889e95d..36a9b206ad 100644
--- a/log/src/main/java/org/apache/felix/log/LoggerContextImpl.java
+++ b/log/src/main/java/org/apache/felix/log/LoggerContextImpl.java
@@ -47,17 +47,19 @@ public LoggerContextImpl(String name, LoggerAdminImpl loggerAdminImpl, LoggerCon
_rootContext = rootLoggerContext;
}
+ @Override
public String getName() {
return _name;
}
+ @Override
public LogLevel getEffectiveLogLevel(String name) {
_lock.lock();
try {
if (_levels != null && !_levels.isEmpty()) {
String copy = name;
LogLevel level;
- while (copy.length() > 0) {
+ while (!copy.isEmpty()) {
level = _levels.get(copy);
if (level != null) {
return level;
@@ -74,6 +76,7 @@ public LogLevel getEffectiveLogLevel(String name) {
}
}
+ @Override
public Map getLogLevels() {
_lock.lock();
try {
@@ -87,6 +90,7 @@ public Map getLogLevels() {
}
}
+ @Override
public void setLogLevels(Map logLevels) {
_lock.lock();
try {
@@ -98,6 +102,7 @@ public void setLogLevels(Map logLevels) {
}
}
+ @Override
public void clear() {
_lock.lock();
try {
@@ -108,6 +113,7 @@ public void clear() {
}
}
+ @Override
public boolean isEmpty() {
_lock.lock();
try {
diff --git a/log/src/main/java/org/apache/felix/log/LoggerImpl.java b/log/src/main/java/org/apache/felix/log/LoggerImpl.java
index a9879f1603..055bc50914 100644
--- a/log/src/main/java/org/apache/felix/log/LoggerImpl.java
+++ b/log/src/main/java/org/apache/felix/log/LoggerImpl.java
@@ -36,10 +36,10 @@ public class LoggerImpl implements Logger {
protected final String m_name;
protected final Bundle m_bundle;
- protected final Log m_log;
+ final Log m_log;
protected final LoggerAdminImpl m_loggerAdmin;
- public LoggerImpl(final String name, final Bundle bundle, final Log log, final LoggerAdminImpl loggerAdmin) {
+ LoggerImpl(final String name, final Bundle bundle, final Log log, final LoggerAdminImpl loggerAdmin) {
m_name = name;
m_bundle = bundle;
m_log = log;
diff --git a/log/src/main/java/org/apache/felix/log/RootLoggerContextImpl.java b/log/src/main/java/org/apache/felix/log/RootLoggerContextImpl.java
index 3ec792b2fd..11e8f5c64c 100644
--- a/log/src/main/java/org/apache/felix/log/RootLoggerContextImpl.java
+++ b/log/src/main/java/org/apache/felix/log/RootLoggerContextImpl.java
@@ -19,9 +19,6 @@
package org.apache.felix.log;
-import java.util.Dictionary;
-import java.util.Map;
-
import org.osgi.service.log.LogLevel;
import org.osgi.service.log.Logger;
@@ -45,12 +42,13 @@ public RootLoggerContextImpl(String defaultLogLevelString, LoggerAdminImpl logge
_defaultLevel = defaultLogLevel;
}
+ @Override
public LogLevel getEffectiveLogLevel(String name) {
_lock.lock();
try {
if (_levels != null && !_levels.isEmpty()) {
LogLevel level;
- while (name.length() > 0) {
+ while (!name.isEmpty()) {
level = _levels.get(name);
if (level != null) {
return level;
@@ -67,16 +65,6 @@ public LogLevel getEffectiveLogLevel(String name) {
}
}
- @Override
- public void setLogLevels(Map logLevels) {
- super.setLogLevels(logLevels);
- }
-
- @Override
- void updateLoggerContext(Dictionary properties) {
- super.updateLoggerContext(properties);
- }
-
private LogLevel getEffectiveRootLogLevel() {
if (_levels == null) return _defaultLevel;
LogLevel logLevel = _levels.get(Logger.ROOT_LOGGER_NAME);
diff --git a/pom/pom.xml b/pom/pom.xml
index 85dd9d8620..c46888d0eb 100644
--- a/pom/pom.xml
+++ b/pom/pom.xml
@@ -22,7 +22,7 @@
org.apache
apache
- 31
+ 33
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/ComponentCommands.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentCommands.java
index 08d9184487..c7d5945277 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/ComponentCommands.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentCommands.java
@@ -462,16 +462,14 @@ else if (value instanceof byte[])
valueStr = Arrays.toString((byte[]) value);
else if (value instanceof short[])
valueStr = Arrays.toString((short[]) value);
- else if (value instanceof byte[])
- valueStr = Arrays.toString((byte[]) value);
else if (value instanceof char[])
valueStr = Arrays.toString((char[]) value);
else if (value instanceof boolean[])
valueStr = Arrays.toString((boolean[]) value);
else if (value instanceof float[])
- valueStr = Arrays.toString((boolean[]) value);
+ valueStr = Arrays.toString((float[]) value);
else if (value instanceof double[])
- valueStr = Arrays.toString((boolean[]) value);
+ valueStr = Arrays.toString((double[]) value);
else if (value instanceof Object[])
valueStr = Arrays.deepToString((Object[]) value);
else