You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2022/07/23 21:41:17 UTC
[logging-log4j2] 04/04: Remove ConditionalOnMissingBinding
This is an automated email from the ASF dual-hosted git repository.
mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 5fff1a51d70e71583f0e5cfb6100d1f55915a8a8
Author: Matt Sicker <ma...@apache.org>
AuthorDate: Sat Jul 23 16:40:57 2022 -0500
Remove ConditionalOnMissingBinding
This is now redundant due to binding merges based on the Ordered annotation.
Signed-off-by: Matt Sicker <ma...@apache.org>
---
.../condition/OnMissingBindingConditionTest.java | 1 -
.../plugins/condition/OnPropertyConditionTest.java | 2 +-
.../condition/ConditionalOnMissingBinding.java | 37 -------------------
.../condition/OnMissingBindingCondition.java | 43 ----------------------
4 files changed, 1 insertion(+), 82 deletions(-)
diff --git a/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingConditionTest.java b/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingConditionTest.java
index 73caa8347a..6378750df3 100644
--- a/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingConditionTest.java
+++ b/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingConditionTest.java
@@ -38,7 +38,6 @@ class OnMissingBindingConditionTest {
}
static class ConditionalFactory {
- @ConditionalOnMissingBinding
@Namespace("foo")
@Named("bar")
@Factory
diff --git a/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnPropertyConditionTest.java b/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnPropertyConditionTest.java
index da949c945e..2c9c0caf39 100644
--- a/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnPropertyConditionTest.java
+++ b/log4j-plugins-test/src/test/java/org/apache/logging/log4j/plugins/condition/OnPropertyConditionTest.java
@@ -45,7 +45,7 @@ class OnPropertyConditionTest {
return "hello";
}
- @ConditionalOnMissingBinding
+ @Ordered(10)
@Factory
String backup() {
return "goodbye";
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/ConditionalOnMissingBinding.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/ConditionalOnMissingBinding.java
deleted file mode 100644
index 048ca67eb9..0000000000
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/ConditionalOnMissingBinding.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.condition;
-
-import org.apache.logging.log4j.plugins.di.Injector;
-import org.apache.logging.log4j.plugins.di.Key;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Checks if a {@linkplain Injector#hasBinding(Key) binding exists} for the annotated element.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE, ElementType.METHOD })
-@Documented
-@Conditional(OnMissingBindingCondition.class)
-public @interface ConditionalOnMissingBinding {
-}
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingCondition.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingCondition.java
deleted file mode 100644
index f6ff78571e..0000000000
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/condition/OnMissingBindingCondition.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.condition;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.plugins.Inject;
-import org.apache.logging.log4j.plugins.di.Injector;
-import org.apache.logging.log4j.plugins.di.Key;
-import org.apache.logging.log4j.status.StatusLogger;
-
-import java.lang.reflect.AnnotatedElement;
-
-public class OnMissingBindingCondition implements Condition {
- private static final Logger LOGGER = StatusLogger.getLogger();
- private final Injector injector;
-
- @Inject
- public OnMissingBindingCondition(final Injector injector) {
- this.injector = injector;
- }
-
- @Override
- public boolean matches(final Key<?> key, final AnnotatedElement element) {
- final boolean result = !injector.hasBinding(key);
- LOGGER.debug("ConditionalOnMissingBinding {} for {} on {}", result, key, element);
- return result;
- }
-}