Skip to content

Commit

Permalink
felix.log: Use OSGi annotations to produce OSGi MANIFEST.MF entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilx committed Dec 11, 2024
1 parent e3d425e commit 87aeb3d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 13 deletions.
47 changes: 34 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,6 +49,36 @@
<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.namespace.service</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
<version>8.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.5.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.cm</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>biz.aQute.bnd.annotation</artifactId>
<version>6.4.1</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
Expand All @@ -61,24 +91,15 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.5.0</version>
<version>5.1.9</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>
</instructions>
</configuration>
</plugin>
Expand Down
4 changes: 4 additions & 0 deletions 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,12 @@
import java.util.Dictionary;
import java.util.Hashtable;

import org.osgi.annotation.bundle.Header;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.annotations.RequireConfigurationAdmin;
import org.osgi.service.log.LogLevel;
import org.osgi.service.log.LogReaderService;
import org.osgi.service.log.LogService;
Expand Down Expand Up @@ -54,6 +56,8 @@
* the historic log information. The default value is false.</dd>
* </dl>
*/
@Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}")
@RequireConfigurationAdmin
public final class Activator implements BundleActivator
{
/** The name of the property that defines the maximum size of the log. */
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 = LogReaderService.class
)
final class LogReaderServiceImpl implements LogReaderService
{
/** The log implementation. */
Expand Down
8 changes: 8 additions & 0 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,22 @@
*/
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;

/**
* 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 = {LogService.class, LoggerFactory.class}
)
final class LogServiceImpl implements LogService
{
/** The bundle associated with this implementation. */
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 = LoggerAdmin.class
)
public class LoggerAdminImpl implements LoggerAdmin {

private final Log m_log;
Expand Down

0 comments on commit 87aeb3d

Please sign in to comment.