@@ -0,0 +1,3453 @@
+/*%0A * Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements. See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License. You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.logging.log4j.core.config.plugins.visitors;%0A%0Aimport java.lang.annotation.Annotation;%0Aimport java.util.Map;%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0Aimport org.apache.logging.log4j.Logger;%0Aimport org.apache.logging.log4j.core.config.plugins.PluginAttribute;%0Aimport org.apache.logging.log4j.status.StatusLogger;%0A%0A/**%0A * Registry for associating Plugin annotations with PluginVisitor implementations.%0A */%0Apublic final class PluginVisitors %7B%0A%0A    private static final Logger LOGGER = StatusLogger.getLogger();%0A%0A    // map of annotation classes to their corresponding PluginVisitor classes%0A    // generics are fun!%0A    private static final Map%3CClass%3C? extends Annotation%3E, Class%3C? extends PluginVisitor%3C? extends Annotation%3E%3E%3E REGISTRY;%0A%0A    static %7B%0A        // register the default PluginVisitor classes%0A        REGISTRY = new ConcurrentHashMap%3CClass%3C? extends Annotation%3E, Class%3C? extends PluginVisitor%3C? extends Annotation%3E%3E%3E();%0A        registerVisitor(PluginAttribute.class, PluginAttributeVisitor.class);%0A    %7D%0A%0A    private PluginVisitors() %7B%0A    %7D%0A%0A    /**%0A     * Registers a PluginVisitor class associated to a specific annotation.%0A     *%0A     * @param annotation the Plugin annotation to associate with.%0A     * @param helper     the PluginVisitor class to use for the annotation.%0A     * @param %3CA%3E        the Plugin annotation type.%0A     */%0A    public static %3CA extends Annotation%3E void registerVisitor(final Class%3CA%3E annotation,%0A                                                              final Class%3C? extends PluginVisitor%3CA%3E%3E helper) %7B%0A        REGISTRY.put(annotation, helper);%0A    %7D%0A%0A    /**%0A     * Creates a PluginVisitor instance for the given annotation class. This instance must be further populated with%0A     * data to be useful. Such data is passed through both the setters and the visit method.%0A     *%0A     * @param annotation the Plugin annotation class to find a PluginVisitor for.%0A     * @param %3CA%3E        the Plugin annotation type.%0A     * @return a PluginVisitor instance if one could be created, or %7B@code null%7D otherwise.%0A     */%0A    @SuppressWarnings(%22unchecked%22) // we're keeping track of types, thanks%0A    public static %3CA extends Annotation%3E PluginVisitor%3CA%3E findVisitor(final Class%3CA%3E annotation) %7B%0A        try %7B%0A            final Class%3CPluginVisitor%3CA%3E%3E clazz = (Class%3CPluginVisitor%3CA%3E%3E) REGISTRY.get(annotation);%0A            if (clazz == null) %7B%0A                return null;%0A            %7D%0A            return clazz.newInstance();%0A        %7D catch (final Exception e) %7B%0A            LOGGER.debug(%22No PluginVisitor found for annotation: %7B%7D.%22, annotation);%0A            return null;%0A        %7D%0A    %7D%0A%7D%0A

Add PluginVisitors registry class.