001/* 002 * Copyright 2002-2012 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.jmx.export.notification; 018 019import javax.management.Notification; 020 021/** 022 * Simple interface allowing Spring-managed MBeans to publish JMX notifications 023 * without being aware of how those notifications are being transmitted to the 024 * {@link javax.management.MBeanServer}. 025 * 026 * <p>Managed resources can access a {@code NotificationPublisher} by 027 * implementing the {@link NotificationPublisherAware} interface. After a particular 028 * managed resource instance is registered with the {@link javax.management.MBeanServer}, 029 * Spring will inject a {@code NotificationPublisher} instance into it if that 030 * resource implements the {@link NotificationPublisherAware} inteface. 031 * 032 * <p>Each managed resource instance will have a distinct instance of a 033 * {@code NotificationPublisher} implementation. This instance will keep 034 * track of all the {@link javax.management.NotificationListener NotificationListeners} 035 * registered for a particular mananaged resource. 036 * 037 * <p>Any existing, user-defined MBeans should use standard JMX APIs for notification 038 * publication; this interface is intended for use only by Spring-created MBeans. 039 * 040 * @author Rob Harrop 041 * @since 2.0 042 * @see NotificationPublisherAware 043 * @see org.springframework.jmx.export.MBeanExporter 044 */ 045public interface NotificationPublisher { 046 047 /** 048 * Send the specified {@link javax.management.Notification} to all registered 049 * {@link javax.management.NotificationListener NotificationListeners}. 050 * Managed resources are <strong>not</strong> responsible for managing the list 051 * of registered {@link javax.management.NotificationListener NotificationListeners}; 052 * that is performed automatically. 053 * @param notification the JMX Notification to send 054 * @throws UnableToSendNotificationException if sending failed 055 */ 056 void sendNotification(Notification notification) throws UnableToSendNotificationException; 057 058}