001/* 002 * Copyright 2002-2019 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.context; 018 019import java.util.EventListener; 020 021/** 022 * Interface to be implemented by application event listeners. 023 * 024 * <p>Based on the standard {@code java.util.EventListener} interface 025 * for the Observer design pattern. 026 * 027 * <p>As of Spring 3.0, an {@code ApplicationListener} can generically declare 028 * the event type that it is interested in. When registered with a Spring 029 * {@code ApplicationContext}, events will be filtered accordingly, with the 030 * listener getting invoked for matching event objects only. 031 * 032 * @author Rod Johnson 033 * @author Juergen Hoeller 034 * @param <E> the specific {@code ApplicationEvent} subclass to listen to 035 * @see org.springframework.context.ApplicationEvent 036 * @see org.springframework.context.event.ApplicationEventMulticaster 037 * @see org.springframework.context.event.EventListener 038 */ 039@FunctionalInterface 040public interface ApplicationListener<E extends ApplicationEvent> extends EventListener { 041 042 /** 043 * Handle an application event. 044 * @param event the event to respond to 045 */ 046 void onApplicationEvent(E event); 047 048}