You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/04/18 12:05:30 UTC
(logging-log4j2) branch feature/2.x/mongodb-next updated: Work around `PluginProcessor` restrictions
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch feature/2.x/mongodb-next
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/feature/2.x/mongodb-next by this push:
new aff576b979 Work around `PluginProcessor` restrictions
aff576b979 is described below
commit aff576b979dfee3af32793cc1fca975f9e197532
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Thu Apr 18 14:03:10 2024 +0200
Work around `PluginProcessor` restrictions
The `PluginProcessor` assumes that the factory method of a
`@Plugin`-annotated class returns an instance of the class itself.
We workaround the problem adding an `implements NoSqlProvider` clause to
the `MongoDbProvider` class.
---
.../org/apache/logging/log4j/mongodb/MongoDbProvider.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/log4j-mongodb/src/main/java/org/apache/logging/log4j/mongodb/MongoDbProvider.java b/log4j-mongodb/src/main/java/org/apache/logging/log4j/mongodb/MongoDbProvider.java
index 12e1cd4ec9..0828b16648 100644
--- a/log4j-mongodb/src/main/java/org/apache/logging/log4j/mongodb/MongoDbProvider.java
+++ b/log4j-mongodb/src/main/java/org/apache/logging/log4j/mongodb/MongoDbProvider.java
@@ -17,16 +17,27 @@
package org.apache.logging.log4j.mongodb;
import org.apache.logging.log4j.core.Core;
+import org.apache.logging.log4j.core.appender.nosql.NoSqlProvider;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.mongodb4.MongoDb4Connection;
import org.apache.logging.log4j.mongodb4.MongoDb4Provider;
import org.apache.logging.log4j.mongodb4.MongoDb4Provider.Builder;
/**
* Delegates to {@link MongoDb4Provider} under the name {@code MongoDb}.
*/
+/*
+ * TODO: Currently the
+ * {@link org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor}
+ * assumes that the class generated by the plugin is the same as the annotated class.
+ * To work around this we declare this class abstract and let it implement
+ * {@link NoSqlProvider}.
+ */
@Plugin(name = "MongoDb", category = Core.CATEGORY_NAME, printObject = true)
-public final class MongoDbProvider {
+public abstract class MongoDbProvider implements NoSqlProvider<MongoDb4Connection> {
+
+ private MongoDbProvider() {}
@PluginBuilderFactory
public static <B extends Builder<B>> B newBuilder() {