001/* 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2022, 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 */ 014 015package ch.qos.logback.core.spi; 016 017/** 018 * This class configuration events which can be of various types such as 019 * CHANGE_DETECTED, CONFIGURATION_STARTED and CONFIGURATION_ENDED. 020 * 021 * Configuration events can be accompanied by supplemental data which can be null. 022 * 023 * @since 1.3.6/1.4.6 024 */ 025 026public class ConfigurationEvent { 027 028 029 public enum EventType { 030 CHANGE_DETECTOR_REGISTERED, 031 032 CHANGE_DETECTOR_RUNNING, 033 CHANGE_DETECTED, 034 CONFIGURATION_STARTED, 035 CONFIGURATION_ENDED; 036 } 037 final EventType eventType; 038 final Object data; 039 040 /** 041 * Construct a ConfigurationEvent instance. 042 * 043 * @param eventType 044 * @param data supplemental data, can be null 045 */ 046 private ConfigurationEvent(EventType eventType, Object data) { 047 this.eventType = eventType; 048 this.data = data; 049 } 050 051 static public ConfigurationEvent newConfigurationChangeDetectorRunningEvent(Object data) { 052 return new ConfigurationEvent(EventType.CHANGE_DETECTOR_RUNNING, data); 053 } 054 055 static public ConfigurationEvent newConfigurationChangeDetectorRegisteredEvent(Object data) { 056 return new ConfigurationEvent(EventType.CHANGE_DETECTOR_REGISTERED, data); 057 } 058 static public ConfigurationEvent newConfigurationChangeDetectedEvent(Object data) { 059 return new ConfigurationEvent(EventType.CHANGE_DETECTED, data); 060 } 061 static public ConfigurationEvent newConfigurationStartedEvent(Object data) { 062 return new ConfigurationEvent(EventType.CONFIGURATION_STARTED, data); 063 } 064 static public ConfigurationEvent newConfigurationEndedEvent(Object data) { 065 return new ConfigurationEvent(EventType.CONFIGURATION_ENDED, data); 066 } 067 068 public EventType getEventType() { 069 return eventType; 070 } 071 072 public Object getData() { 073 return data; 074 } 075 076 077 @Override 078 public String toString() { 079 return "ConfigurationEvent{" + "eventType=" + eventType + ", data=" + data + '}'; 080 } 081}