001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.classic.model.processor;
015
016import java.util.ArrayList;
017import java.util.List;
018
019import ch.qos.logback.classic.PatternLayout;
020import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
021import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
022import ch.qos.logback.core.AppenderBase;
023import ch.qos.logback.core.UnsynchronizedAppenderBase;
024import ch.qos.logback.core.filter.EvaluatorFilter;
025import ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry;
026import ch.qos.logback.core.joran.util.ParentTag_Tag_Class_Tuple;
027import ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules;
028import ch.qos.logback.core.net.ssl.KeyManagerFactoryFactoryBean;
029import ch.qos.logback.core.net.ssl.KeyStoreFactoryBean;
030import ch.qos.logback.core.net.ssl.SSLConfiguration;
031import ch.qos.logback.core.net.ssl.SSLParametersConfiguration;
032import ch.qos.logback.core.net.ssl.SecureRandomFactoryBean;
033import ch.qos.logback.core.net.ssl.TrustManagerFactoryFactoryBean;
034
035/**
036 * Contains mappings for the default type of nested components in
037 * logback-classic.
038 * 
039 * @author Ceki Gulcu
040 * 
041 */
042public class LogbackClassicDefaultNestedComponentRules {
043
044    static public List<ParentTag_Tag_Class_Tuple> TUPLES_LIST = createTuplesList();
045
046    static public void addDefaultNestedComponentRegistryRules(DefaultNestedComponentRegistry registry) {
047        registry.add(AppenderBase.class, "layout", PatternLayout.class);
048        registry.add(UnsynchronizedAppenderBase.class, "layout", PatternLayout.class);
049
050        registry.add(AppenderBase.class, "encoder", PatternLayoutEncoder.class);
051        registry.add(UnsynchronizedAppenderBase.class, "encoder", PatternLayoutEncoder.class);
052
053        registry.add(EvaluatorFilter.class, "evaluator", JaninoEventEvaluator.class);
054
055        SSLNestedComponentRegistryRules.addDefaultNestedComponentRegistryRules(registry);
056    }
057
058    public static List<ParentTag_Tag_Class_Tuple> createTuplesList() {
059
060        List<ParentTag_Tag_Class_Tuple> tupleList = new ArrayList<>();
061
062        tupleList.add(new ParentTag_Tag_Class_Tuple("appender", "encoder", PatternLayoutEncoder.class.getName()));
063        tupleList.add(new ParentTag_Tag_Class_Tuple("appender", "layout", PatternLayout.class.getName()));
064        tupleList.add(new ParentTag_Tag_Class_Tuple("receiver", "ssl", SSLConfiguration.class.getName()));
065        tupleList.add(new ParentTag_Tag_Class_Tuple("ssl", "parameters", SSLParametersConfiguration.class.getName()));
066        tupleList.add(new ParentTag_Tag_Class_Tuple("ssl", "keyStore", KeyStoreFactoryBean.class.getName()));
067        tupleList.add(new ParentTag_Tag_Class_Tuple("ssl", "trustStore", KeyManagerFactoryFactoryBean.class.getName()));
068        tupleList.add(new ParentTag_Tag_Class_Tuple("ssl", "keyManagerFactory", SSLParametersConfiguration.class.getName()));
069        tupleList
070                .add(new ParentTag_Tag_Class_Tuple("ssl", "trustManagerFactory", TrustManagerFactoryFactoryBean.class.getName()));
071        tupleList.add(new ParentTag_Tag_Class_Tuple("ssl", "secureRandom", SecureRandomFactoryBean.class.getName()));
072        return tupleList;
073
074    }
075
076
077
078}