ppkarwasz commented on code in PR #1752:
URL: https://github.com/apache/logging-log4j2/pull/1752#discussion_r1329123058


##########
log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/di/spi/FactoryResolver.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.plugins.di.spi;
+
+import java.util.function.Supplier;
+
+import org.apache.logging.log4j.plugins.di.InstanceFactory;
+import org.apache.logging.log4j.plugins.di.Key;
+
+/**
+ * Strategy for resolving factories from existing factories. This is useful 
for supporting plugin system
+ * dependency injection such as configuration attributes, trees of plugin 
objects, and other conveniences.
+ */
+public interface FactoryResolver {
+    /**
+     * Checks if this resolver supports the provided key. If this returns 
{@code true}, then the factory
+     * returned by {@link #getFactory(ResolvableKey, InstanceFactory)} will be 
used to create a binding
+     * for the key.
+     *
+     * @param key the key to check for support
+     * @return true if this resolver supports the key
+     */
+    boolean supportsKey(final Key<?> key);
+
+    /**
+     * Gets a factory for the given resolvable key using existing bindings 
from the given instance factory.
+     * A resolvable key in this context is a {@link Key} combined with alias 
names and the annotated element
+     * this factory is for.
+     *
+     * @param resolvableKey   the resolvable key to create a binding for
+     * @param instanceFactory the existing instance factory to use for 
composing bindings
+     * @return a factory for instances described by the provided key
+     */
+    Supplier<?> getFactory(final ResolvableKey<?> resolvableKey, final 
InstanceFactory instanceFactory);

Review Comment:
   Shouldn't this method be parameterized?



##########
log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/Configurable.java:
##########
@@ -22,34 +22,40 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+import org.apache.logging.log4j.plugins.convert.TypeConverter;
 import org.apache.logging.log4j.util.Strings;
 
 /**
- * Annotates a plugin as being a configurable plugin. Configurable plugins are 
instantiated from a tree of
- * {@link Node} objects.
+ * Annotates a plugin as being a configurable plugin. A configurable plugin 
corresponds to a {@code Node} element
+ * of a configuration tree. Each configuration element may have zero or more 
{@linkplain PluginAttribute attributes}
+ * where attribute values are converted from strings into other types via 
{@link TypeConverter}, an optional
+ * {@linkplain PluginValue value} (another type of plugin attribute which may 
have dedicated syntax in some configuration
+ * formats such as XML), and zero or more child elements.

Review Comment:
   Maybe we should add something like "only configurable plugins can appear as 
elements in a configuration file". In some sense a pattern converter is also 
"configurable".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to