Skip to content

Add BND configuration for log4j-api #1820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2023
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
1 change: 0 additions & 1 deletion log4j-api-java9/src/assembly/java9.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/classes/META-INF/versions/9</outputDirectory>
<includes>
<include>module-info.class</include>
<include>org/apache/logging/log4j/util/Base64Util.class</include>
<include>org/apache/logging/log4j/util/ProcessIdUtil.class</include>
<include>org/apache/logging/log4j/util/StackLocator.class</include>
Expand Down
37 changes: 0 additions & 37 deletions log4j-api-java9/src/main/java/module-info.java

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 12 additions & 0 deletions log4j-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
~ OSGi and JPMS options
-->
<bnd-multi-release>true</bnd-multi-release>
<!-- Differs from OSGi bundle name -->
<bnd-module-name>org.apache.logging.log4j</bnd-module-name>
<bnd-extra-package-options>
<!-- This is a Java 9 only package, so BND can not detect it as private -->
!org.apache.logging.log4j.util.internal
</bnd-extra-package-options>
<bnd-extra-module-options>
<!-- Used in StringBuilders through reflection -->
java.sql;static=true,
<!-- Used in ProcessIdUtil through reflection -->
java.management;static=true
</bnd-extra-module-options>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import java.util.HashMap;
import java.util.Map;

import aQute.bnd.annotation.Cardinality;
import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceConsumer;
import org.apache.logging.log4j.message.ThreadDumpMessage.ThreadInfoFactory;
import org.apache.logging.log4j.util.ServiceLoaderUtil;
import org.apache.logging.log4j.util.StringBuilderFormattable;
import org.apache.logging.log4j.util.Strings;
Expand All @@ -33,6 +37,7 @@
* Captures information about all running Threads.
*/
@AsynchronouslyFormattable
@ServiceConsumer(value = ThreadInfoFactory.class, resolution = Resolution.OPTIONAL, cardinality = Cardinality.SINGLE)
public class ThreadDumpMessage implements Message, StringBuilderFormattable {
private static final long serialVersionUID = -1103400781608841088L;
private static ThreadInfoFactory FACTORY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
/**
* Public Message Types used for Log4j 2. Users may implement their own Messages.
*/
@Export
package org.apache.logging.log4j.message;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@
*
* @see <a href="http://logging.apache.org/log4j/2.x/manual/api.html">Log4j 2 API manual</a>
*/
@Export
package org.apache.logging.log4j;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
* Simple logging implementation. This is a rather minimal Log4j Provider that is used by default if no other Log4j
* Providers are able to be loaded at runtime.
*/
@Export
package org.apache.logging.log4j.simple;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
* Internal interfaces and classes to be used by authors of logging implementations or for internal use by
* API classes.
*/
@Export
package org.apache.logging.log4j.spi;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
/** Status API for Log4j 2. Should not be used by typical applications performing logging but may be
* used by applications reporting on the status of the logging system
*/
@Export
package org.apache.logging.log4j.status;

import org.osgi.annotation.bundle.Export;
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import org.apache.logging.log4j.spi.LoggerContextFactory;
import org.apache.logging.log4j.spi.Provider;
import org.apache.logging.log4j.status.StatusLogger;
import org.osgi.annotation.bundle.Header;
import org.osgi.framework.AdaptPermission;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.SynchronousBundleListener;
Expand All @@ -44,6 +46,8 @@
* {@code META-INF/log4j-provider.properties} files. As with all OSGi BundleActivator classes, this class is not for
* public use and is only useful in an OSGi framework environment.
*/
@Header(name = Constants.BUNDLE_ACTIVATOR, value = "${@class}")
@Header(name = Constants.BUNDLE_ACTIVATIONPOLICY, value = Constants.ACTIVATION_LAZY)
public class Activator implements BundleActivator, SynchronousBundleListener {

private static final SecurityManager SECURITY_MANAGER = System.getSecurityManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import java.util.Collection;
import java.util.Map;

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;

/**
* PropertySource implementation that uses environment variables as a source.
* All environment variables must begin with {@code LOG4J_} so as not to
Expand All @@ -28,6 +31,7 @@
*
* @since 2.10.0
*/
@ServiceProvider(value = PropertySource.class, resolution = Resolution.OPTIONAL)
public class EnvironmentPropertySource implements PropertySource {

private static final String PREFIX = "LOG4J_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;

import aQute.bnd.annotation.Cardinality;
import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceConsumer;

/**
* <em>Consider this class private.</em>
* <p>
Expand All @@ -48,6 +52,7 @@
*
* @see PropertySource
*/
@ServiceConsumer(value = PropertySource.class, resolution = Resolution.OPTIONAL, cardinality = Cardinality.MULTIPLE)
public final class PropertiesUtil {

private static final String LOG4J_PROPERTIES_FILE_NAME = "log4j2.component.properties";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import aQute.bnd.annotation.Cardinality;
import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceConsumer;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.spi.Provider;
import org.apache.logging.log4j.status.StatusLogger;
Expand All @@ -35,6 +38,7 @@
* container framework, any Log4j Providers not accessible through standard classpath scanning should
* {@link #loadProvider(java.net.URL, ClassLoader)} a classpath accordingly.
*/
@ServiceConsumer(value = Provider.class, resolution = Resolution.OPTIONAL, cardinality = Cardinality.MULTIPLE)
public final class ProviderUtil {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
import java.util.Objects;
import java.util.Properties;

import aQute.bnd.annotation.Resolution;
import aQute.bnd.annotation.spi.ServiceProvider;

/**
* PropertySource backed by the current system properties. Other than having a
* higher priority over normal properties, this follows the same rules as
* {@link PropertiesPropertySource}.
*
* @since 2.10.0
*/
@ServiceProvider(value = PropertySource.class, resolution = Resolution.OPTIONAL)
public class SystemPropertiesPropertySource implements PropertySource {

private static final int DEFAULT_PRIORITY = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
* Internal utility classes for the Log4j 2 API. Note that the use of any classes in this package is not supported.
* There are no guarantees for binary or logical compatibility in this package.
*/
@Export
package org.apache.logging.log4j.util;

import org.osgi.annotation.bundle.Export;

This file was deleted.