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 028 * for a reload operation is detected. From the pay-load of the event 029 * information about the components involved is available. 030 * </p> 031 * 032 * @version $Id: ReloadingEvent.java 1842194 2018-09-27 22:24:23Z ggregory $ 033 * @since 2.0 034 */ 035public class ReloadingEvent extends Event 036{ 037 /** The common event super type for all reloading events. */ 038 public static final EventType<ReloadingEvent> ANY = 039 new EventType<>(Event.ANY, "RELOAD"); 040 041 /** 042 * The serial version UID. 043 */ 044 private static final long serialVersionUID = 20140701L; 045 046 /** Stores additional data about this event. */ 047 private final Object data; 048 049 /** 050 * Creates a new instance of {@code ReloadingEvent} and initializes it. 051 * 052 * @param source the controller which generated this event 053 * @param addData an arbitrary data object to be evaluated by event 054 * listeners 055 */ 056 public ReloadingEvent(final ReloadingController source, final Object addData) 057 { 058 super(source, ANY); 059 data = addData; 060 } 061 062 /** 063 * Returns the {@code ReloadingController} which caused this event. 064 * 065 * @return the responsible {@code ReloadingController} 066 */ 067 public ReloadingController getController() 068 { 069 return (ReloadingController) getSource(); 070 } 071 072 /** 073 * Returns an object with additional data about the reload operation. This 074 * is the object that was passed to the {@link ReloadingController} when it 075 * was asked to do a reloading check. This is a generic mechanism to pass 076 * arbitrary data to reloading listeners. 077 * 078 * @return additional data about the reload operation (can be <b>null</b>) 079 */ 080 public Object getData() 081 { 082 return data; 083 } 084}