001/*
002 * Copyright 2002-2015 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
019/**
020 * Interface that encapsulates event publication functionality.
021 * Serves as super-interface for {@link ApplicationContext}.
022 *
023 * @author Juergen Hoeller
024 * @author Stephane Nicoll
025 * @since 1.1.1
026 * @see ApplicationContext
027 * @see ApplicationEventPublisherAware
028 * @see org.springframework.context.ApplicationEvent
029 * @see org.springframework.context.event.EventPublicationInterceptor
030 */
031public interface ApplicationEventPublisher {
032
033        /**
034         * Notify all <strong>matching</strong> listeners registered with this
035         * application of an application event. Events may be framework events
036         * (such as RequestHandledEvent) or application-specific events.
037         * @param event the event to publish
038         * @see org.springframework.web.context.support.RequestHandledEvent
039         */
040        void publishEvent(ApplicationEvent event);
041
042        /**
043         * Notify all <strong>matching</strong> listeners registered with this
044         * application of an event.
045         * <p>If the specified {@code event} is not an {@link ApplicationEvent},
046         * it is wrapped in a {@link PayloadApplicationEvent}.
047         * @param event the event to publish
048         * @since 4.2
049         * @see PayloadApplicationEvent
050         */
051        void publishEvent(Object event);
052
053}