View Javadoc
1   /*
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2022, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  
15  package ch.qos.logback.core.spi;
16  
17  /**
18   * This class configuration events which can be of various types such as
19   *  CHANGE_DETECTED, CONFIGURATION_STARTED and CONFIGURATION_ENDED.
20   *
21   *  Configuration events can be accompanied by supplemental data which can be null.
22   *
23   * @since 1.3.6/1.4.6
24   */
25  
26  public class ConfigurationEvent {
27  
28  
29      public enum EventType {
30          CHANGE_DETECTOR_REGISTERED,
31  
32          CHANGE_DETECTOR_RUNNING,
33          CHANGE_DETECTED,
34          CONFIGURATION_STARTED,
35          CONFIGURATION_ENDED;
36      }
37      final EventType eventType;
38      final Object data;
39  
40      /**
41       * Construct a ConfigurationEvent instance.
42       *
43       * @param eventType
44       * @param data supplemental data, can be null
45       */
46      private ConfigurationEvent(EventType eventType, Object data) {
47          this.eventType = eventType;
48          this.data = data;
49      }
50  
51      static public ConfigurationEvent newConfigurationChangeDetectorRunningEvent(Object data) {
52          return new ConfigurationEvent(EventType.CHANGE_DETECTOR_RUNNING, data);
53      }
54  
55      static public ConfigurationEvent newConfigurationChangeDetectorRegisteredEvent(Object data) {
56          return new ConfigurationEvent(EventType.CHANGE_DETECTOR_REGISTERED, data);
57      }
58      static public ConfigurationEvent newConfigurationChangeDetectedEvent(Object data) {
59          return new ConfigurationEvent(EventType.CHANGE_DETECTED, data);
60      }
61      static public ConfigurationEvent newConfigurationStartedEvent(Object data) {
62          return new ConfigurationEvent(EventType.CONFIGURATION_STARTED, data);
63      }
64      static public ConfigurationEvent newConfigurationEndedEvent(Object data) {
65          return new ConfigurationEvent(EventType.CONFIGURATION_ENDED, data);
66      }
67  
68      public EventType getEventType() {
69          return eventType;
70      }
71  
72      public Object getData() {
73          return data;
74      }
75  
76  
77      @Override
78      public String toString() {
79          return "ConfigurationEvent{" + "eventType=" + eventType + ", data=" + data + '}';
80      }
81  }