ppkarwasz commented on code in PR #2148: URL: https://github.com/apache/logging-log4j2/pull/2148#discussion_r1439261370
########## log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/Log4jExtension.java: ########## @@ -0,0 +1,242 @@ +/* + * 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.core.test.junit; + +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.ConfigurationFactory; +import org.apache.logging.log4j.core.impl.Log4jContextFactory; +import org.apache.logging.log4j.core.impl.Log4jPropertyKey; +import org.apache.logging.log4j.core.selector.ContextSelector; +import org.apache.logging.log4j.core.util.NetUtils; +import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory; +import org.apache.logging.log4j.plugins.di.DI; +import org.apache.logging.log4j.spi.LoggerContextFactory; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionConfigurationException; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.platform.commons.PreconditionViolationException; +import org.junit.platform.commons.support.AnnotationSupport; +import org.junit.platform.commons.support.ReflectionSupport; + +class Log4jExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback { + private static final String FQCN = Log4jExtension.class.getName(); + private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(Log4jExtension.class); Review Comment: We could use a single `Namepace` for all our extensions. There is one in `ExtensionContextAnchor`. ########## src/site/_release-notes/_3.x.x.adoc: ########## @@ -20,6 +20,11 @@ This release contains... +[#release-notes-3-x-x-added] +=== Added + +* Add various DSLs for dependency injection. This includes: - `DI.FactoryBuilder` and related builder classes for configuring a `ConfigurableInstanceFactory`. - Repeatable `@TestBinding` test annotation for specifying simple bindings in tests. - `@LegacyLoggerContextSource` test annotation for specifying v1-style configuration files. - Test extension updates to improve compatibility of different annotations. (https://github.com/apache/logging-log4j2/pull/2147[2147]) Review Comment: As I remarked above: the formatting is terrible. ########## log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/TestBindings.java: ########## @@ -0,0 +1,33 @@ +/* + * 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.core.test.junit; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation container for multiple {@link TestBinding} annotations. + */ +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +public @interface TestBindings { Review Comment: This could be a nested class of `TestBinding`. ########## src/changelog/.3.x.x/2147_add_instance_factory_dsls.xml: ########## @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://logging.apache.org/log4j/changelog" + xsi:schemaLocation="http://logging.apache.org/log4j/changelog https://logging.apache.org/log4j/changelog-0.1.3.xsd" + type="added"> + <issue id="2147" link="https://github.com/apache/logging-log4j2/issues/2147"/> + <description format="asciidoc"> + Add various DSLs for dependency injection. This includes: + + - `DI.FactoryBuilder` and related builder classes for configuring a `ConfigurableInstanceFactory`. + - Repeatable `@TestBinding` test annotation for specifying simple bindings in tests. + - `@LegacyLoggerContextSource` test annotation for specifying v1-style configuration files. + - Test extension updates to improve compatibility of different annotations. Review Comment: This is not an Asciidoc list. Our current changelog template has problems with changelog entries that contain lists, since they should be displayed as nested lists. Maybe this should only contain what is available to end users? ########## log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/junit/Log4jExtension.java: ########## @@ -0,0 +1,242 @@ +/* + * 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.core.test.junit; + +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.List; +import java.util.concurrent.TimeUnit; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.ConfigurationFactory; +import org.apache.logging.log4j.core.impl.Log4jContextFactory; +import org.apache.logging.log4j.core.impl.Log4jPropertyKey; +import org.apache.logging.log4j.core.selector.ContextSelector; +import org.apache.logging.log4j.core.util.NetUtils; +import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory; +import org.apache.logging.log4j.plugins.di.DI; +import org.apache.logging.log4j.spi.LoggerContextFactory; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionConfigurationException; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.platform.commons.PreconditionViolationException; +import org.junit.platform.commons.support.AnnotationSupport; +import org.junit.platform.commons.support.ReflectionSupport; + +class Log4jExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback { Review Comment: I don't understand why is this called `Log4jExtension`. While `LoggerContext` is the main service provided by Log4j, there are other subsystems that need initializing (e.g. status logger, thread context, recycler factory, queue factory). Maybe we should use a more meaningful name like `Log4jContextFactory` extension? -- 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]
