Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions .github/workflows/maven-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- 'http/**'
- 'tools/maven-bundle-plugin/**'
- 'tools/osgicheck-maven-plugin/**'
- 'log/**'
- 'webconsole/**'
pull_request:
branches: [ "master" ]
Expand All @@ -17,7 +18,8 @@ on:
- 'tools/maven-bundle-plugin/**'
- 'tools/osgicheck-maven-plugin/**'
- 'webconsole/**'

- 'log/**'

permissions: {}

jobs:
Expand All @@ -34,7 +36,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
Expand All @@ -50,10 +52,16 @@ jobs:
- 'tools/osgicheck-maven-plugin/**'
webconsole:
- 'webconsole/**'
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 HTTP
- 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
- name: Felix Maven bundle plugin
Expand Down
49 changes: 36 additions & 13 deletions log/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.felix</groupId>
<artifactId>felix-parent</artifactId>
<version>6</version>
<version>9</version>
<relativePath>../pom/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -49,36 +49,59 @@
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.cm</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.log</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.namespace.service</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.5.1</version>
<scope>provided</scope>
</dependency>
Comment thread
wilx marked this conversation as resolved.
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.5.0</version>
<version>6.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>org.osgi.service.log,org.osgi.service.log.admin</Export-Package>
<Private-Package>org.apache.felix.log</Private-Package>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Activator>${pom.artifactId}.Activator</Bundle-Activator>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
<Include-Resource>META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES</Include-Resource>
<Require-Capability><![CDATA[
osgi.service;filter:="(objectClass=org.osgi.service.cm.ConfigurationAdmin)";effective:=active
]]></Require-Capability>
<Provide-Capability><![CDATA[
osgi.service;objectClass:List<String>="org.osgi.service.log.LogReaderService";uses:="org.osgi.service.log,org.osgi.service.log.admin",
osgi.service;objectClass:List<String>="org.osgi.service.log.LogService,org.osgi.service.log.LoggerFactory";uses:="org.osgi.service.log,org.osgi.service.log.admin",
osgi.service;objectClass:List<String>="org.osgi.service.log.admin.LoggerAdmin";uses:="org.osgi.service.log,org.osgi.service.log.admin"
]]></Provide-Capability>
<_reproducible>true</_reproducible>
Comment thread
wilx marked this conversation as resolved.
<niceManifest>true</niceManifest>
</instructions>
</configuration>
</plugin>
Expand Down
10 changes: 9 additions & 1 deletion log/src/main/java/org/apache/felix/log/Activator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,6 +58,10 @@
* the historic log information. The default value is false.</dd>
* </dl>
*/
@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. */
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public FormatterLoggerImpl(
super(name, bundle, log, loggerAdmin);
}

@Override
String format(String format, LogParameters logParameters) {
StringBuilder sb = new StringBuilder();

Expand Down
2 changes: 1 addition & 1 deletion log/src/main/java/org/apache/felix/log/Log.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ synchronized Enumeration<LogEntry> getEntries()
"FrameworkEvent STARTED",
"FrameworkEvent ERROR",
"FrameworkEvent PACKAGES REFRESHED",
"FrameworkEvent STARTLEVEL CHANGED",
"FrameworkEvent STARTLEVEL CHANGED",
"FrameworkEvent WARNING",
"FrameworkEvent INFO"
};
Expand Down
6 changes: 6 additions & 0 deletions log/src/main/java/org/apache/felix/log/LogEntryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ final class LogEntryImpl implements LogEntry
* @return the bundle that created this LogEntry object;<code>null</code> if no
* bundle is associated with this LogEntry object
*/
@Override
public Bundle getBundle()
{
return m_bundle;
Expand All @@ -155,6 +156,7 @@ public Bundle getBundle()
* this LogEntry object; <code>null</code> if no {@link ServiceReference} object
* was provided
*/
@Override
public ServiceReference<?> getServiceReference()
{
return m_serviceReference;
Expand All @@ -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()) {
Expand All @@ -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;
Expand All @@ -202,6 +206,7 @@ public String getMessage()
* @return throwable object of the exception associated with this LogEntry;
* <code>null</code> if no exception is associated with this LogEntry object
*/
@Override
public Throwable getException()
{
return m_exception;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions log/src/main/java/org/apache/felix/log/LogListenerThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -138,10 +139,10 @@ public void run()
{
// Take a snapshot of all current listeners and deliver all
// pending messages to them...
List<LogListener> listeners = new ArrayList<>();
List<LogListener> listeners;
synchronized (m_listeners)
{
listeners.addAll(m_listeners);
listeners = new ArrayList<>(m_listeners);
}

Iterator<LogEntry> entriesIt = entriesToDeliver.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ final class LogNodeEnumeration implements Enumeration<LogEntry>
* Determines whether there are any more elements to return.
* @return <code>true</code> if there are more elements; <code>false</code> otherwise
*/
@Override
public boolean hasMoreElements()
{
return m_next != null;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ final class LogReaderServiceFactory implements ServiceFactory<LogReaderService>
* @param registration the service registration
* @return the log reader service implementation for the specified bundle
*/
@Override
public LogReaderService getService(final Bundle bundle,
final ServiceRegistration<LogReaderService> registration)
{
Expand All @@ -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<LogReaderService> registration,
final LogReaderService service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String>=\"org.osgi.service.log.LogReaderService\"" },
uses = { LogReaderServiceImpl.class, LogReaderService.class }
)
final class LogReaderServiceImpl implements LogReaderService
{
/** The log implementation. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class LogServiceFactory implements ServiceFactory<LogService>

/**
* Create a new instance.
* @param log the log to associate the service implementations with.,
* @param loggerAdminImpl
*/
LogServiceFactory(final LoggerAdminImpl loggerAdminImpl)
{
Expand Down
12 changes: 10 additions & 2 deletions log/src/main/java/org/apache/felix/log/LogServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>=\"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. */
Expand All @@ -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)
{
Expand Down
7 changes: 7 additions & 0 deletions log/src/main/java/org/apache/felix/log/LoggerAdminImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>=\"org.osgi.service.log.admin.LoggerAdmin\"" },
uses = { LoggerAdminImpl.class, LoggerAdmin.class }
)
public class LoggerAdminImpl implements LoggerAdmin {

private final Log m_log;
Expand Down
Loading