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 2020/03/09 00:07:45 UTC

[logging-log4j2] 01/02: Remove stereotypes

This is an automated email from the ASF dual-hosted git repository.

mattsicker pushed a commit to branch mean-bean-machine
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 03be319b3fce8b1e14fc35b0db7800e0506625c6
Author: Matt Sicker <bo...@gmail.com>
AuthorDate: Sun Mar 8 18:20:01 2020 -0500

    Remove stereotypes
    
    These are not as useful as I thought they might be
    
    Signed-off-by: Matt Sicker <bo...@gmail.com>
---
 .../logging/log4j/plugins/api/Stereotype.java      | 34 ---------------------
 .../defaults/model/DefaultElementManager.java      | 35 +---------------------
 2 files changed, 1 insertion(+), 68 deletions(-)

diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/api/Stereotype.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/api/Stereotype.java
deleted file mode 100644
index 280ebb3..0000000
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/api/Stereotype.java
+++ /dev/null
@@ -1,34 +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.api;
-
-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;
-
-/**
- * Marks an annotation type as a stereotype for combining annotations. This can combine zero or more
- * {@linkplain QualifierType qualifier types} and an optional {@linkplain ScopeType scope type}.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.ANNOTATION_TYPE)
-@Documented
-public @interface Stereotype {
-}
diff --git a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/model/DefaultElementManager.java b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/model/DefaultElementManager.java
index e60fa31..ad83d4e 100644
--- a/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/model/DefaultElementManager.java
+++ b/log4j-plugins/src/main/java/org/apache/logging/log4j/plugins/defaults/model/DefaultElementManager.java
@@ -21,7 +21,6 @@ import org.apache.logging.log4j.plugins.api.AliasFor;
 import org.apache.logging.log4j.plugins.api.Dependent;
 import org.apache.logging.log4j.plugins.api.QualifierType;
 import org.apache.logging.log4j.plugins.api.ScopeType;
-import org.apache.logging.log4j.plugins.api.Stereotype;
 import org.apache.logging.log4j.plugins.spi.bean.Bean;
 import org.apache.logging.log4j.plugins.spi.model.ElementManager;
 import org.apache.logging.log4j.plugins.spi.model.InjectionPoint;
@@ -45,7 +44,7 @@ import java.util.Objects;
 public class DefaultElementManager implements ElementManager {
 
     private enum AnnotationType {
-        QUALIFIER, SCOPE, STEREOTYPE, UNKNOWN
+        QUALIFIER, SCOPE, UNKNOWN
     }
 
     private final Cache<Class<?>, MetaClass<?>> classCache = WeakCache.newWeakRefCache(DefaultMetaClass::newMetaClass);
@@ -62,9 +61,6 @@ public class DefaultElementManager implements ElementManager {
             if (type == ScopeType.class) {
                 return AnnotationType.SCOPE;
             }
-            if (type == Stereotype.class) {
-                return AnnotationType.STEREOTYPE;
-            }
         }
         return AnnotationType.UNKNOWN;
     });
@@ -90,34 +86,11 @@ public class DefaultElementManager implements ElementManager {
             final Class<? extends Annotation> annotationType = annotation.annotationType();
             if (isQualifierType(annotationType)) {
                 qualifiers.add(annotation);
-            } else if (isStereotype(annotationType)) {
-                qualifiers.addAll(filterQualifiers(getStereotypeDefinition(annotationType)));
             }
         }
         return qualifiers;
     }
 
-    /**
-     * Returns all the annotations associated with a {@linkplain Stereotype stereotype} annotation. This contains all
-     * annotation values sans the stereotype annotation values themselves.
-     */
-    private Collection<Annotation> getStereotypeDefinition(final Class<? extends Annotation> annotationType) {
-        final Stereotype stereotype = annotationType.getAnnotation(Stereotype.class);
-        if (stereotype == null) {
-            return Collections.emptySet();
-        }
-        final Annotation[] annotations = annotationType.getAnnotations();
-        final Collection<Annotation> stereotypeDefinition = new LinkedHashSet<>(annotations.length);
-        for (final Annotation annotation : annotations) {
-            if (isStereotype(annotation.annotationType())) {
-                stereotypeDefinition.addAll(getStereotypeDefinition(annotation.annotationType()));
-            } else {
-                stereotypeDefinition.add(annotation);
-            }
-        }
-        return Collections.unmodifiableCollection(stereotypeDefinition);
-    }
-
     private Class<? extends Annotation> getScopeType(final MetaElement<?> element) {
         final Collection<Class<? extends Annotation>> scopeTypes = filterScopeTypes(element.getAnnotations());
         return scopeTypes.isEmpty() ? Dependent.class : scopeTypes.iterator().next();
@@ -130,17 +103,11 @@ public class DefaultElementManager implements ElementManager {
             final Class<? extends Annotation> annotationType = annotation.annotationType();
             if (isScopeType(annotationType)) {
                 scopeTypes.add(annotationType);
-            } else if (isStereotype(annotationType)) {
-                scopeTypes.addAll(filterScopeTypes(getStereotypeDefinition(annotationType)));
             }
         }
         return Collections.unmodifiableCollection(scopeTypes);
     }
 
-    private boolean isStereotype(final Class<? extends Annotation> annotationType) {
-        return getAnnotationType(annotationType) == AnnotationType.STEREOTYPE;
-    }
-
     private boolean isScopeType(final Class<? extends Annotation> annotationType) {
         return getAnnotationType(annotationType) == AnnotationType.SCOPE;
     }