View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.tools.logging.commons;
12  
13  import java.util.ArrayList;
14  import java.util.List;
15  
16  import psiprobe.tools.logging.LogDestination;
17  import psiprobe.tools.logging.jdk.Jdk14LoggerAccessor;
18  import psiprobe.tools.logging.log4j.Log4JLoggerAccessor;
19  
20  /**
21   * The Class GetAllDestinationsVisitor.
22   */
23  public class GetAllDestinationsVisitor extends AbstractLoggerAccessorVisitor {
24  
25    /** The destinations. */
26    private final List<LogDestination> destinations = new ArrayList<>();
27  
28    /**
29     * Gets the destinations.
30     *
31     * @return the destinations
32     */
33    public List<LogDestination> getDestinations() {
34      return destinations;
35    }
36  
37    @Override
38    public void visit(Log4JLoggerAccessor accessor) {
39      destinations.addAll(accessor.getAppenders());
40    }
41  
42    @Override
43    public void visit(Jdk14LoggerAccessor accessor) {
44      destinations.addAll(accessor.getHandlers());
45    }
46  
47  }