001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.configuration2.reloading; 018 019import org.apache.commons.configuration2.event.Event; 020import org.apache.commons.configuration2.event.EventType; 021 022/** 023 * <p> 024 * An event that is fired when a reload operation is required. 025 * </p> 026 * <p> 027 * Events of this type are generated by {@link ReloadingController} if the need for a reload operation is detected. From 028 * the pay-load of the event information about the components involved is available. 029 * </p> 030 * 031 * @since 2.0 032 */ 033public class ReloadingEvent extends Event { 034 /** The common event super type for all reloading events. */ 035 public static final EventType<ReloadingEvent> ANY = new EventType<>(Event.ANY, "RELOAD"); 036 037 /** 038 * The serial version UID. 039 */ 040 private static final long serialVersionUID = 20140701L; 041 042 /** Stores additional data about this event. */ 043 private final Object data; 044 045 /** 046 * Creates a new instance of {@code ReloadingEvent} and initializes it. 047 * 048 * @param source the controller which generated this event 049 * @param addData an arbitrary data object to be evaluated by event listeners 050 */ 051 public ReloadingEvent(final ReloadingController source, final Object addData) { 052 super(source, ANY); 053 data = addData; 054 } 055 056 /** 057 * Gets the {@code ReloadingController} which caused this event. 058 * 059 * @return the responsible {@code ReloadingController} 060 */ 061 public ReloadingController getController() { 062 return (ReloadingController) getSource(); 063 } 064 065 /** 066 * Gets an object with additional data about the reload operation. This is the object that was passed to the 067 * {@link ReloadingController} when it was asked to do a reloading check. This is a generic mechanism to pass arbitrary 068 * data to reloading listeners. 069 * 070 * @return additional data about the reload operation (can be <b>null</b>) 071 */ 072 public Object getData() { 073 return data; 074 } 075}