001/* 002 * Copyright 2002-2013 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.messaging.simp.broker; 018 019import org.springframework.context.ApplicationEvent; 020 021/** 022 * Event raised when a broker's availabilty changes 023 * 024 * @author Andy Wilkinson 025 */ 026public class BrokerAvailabilityEvent extends ApplicationEvent { 027 028 private static final long serialVersionUID = -8156742505179181002L; 029 030 private final boolean brokerAvailable; 031 032 033 /** 034 * Creates a new {@code BrokerAvailabilityEvent}. 035 * 036 * @param brokerAvailable {@code true} if the broker is available, {@code} 037 * false otherwise 038 * @param source the component that is acting as the broker, or as a relay 039 * for an external broker, that has changed availability. Must not be {@code 040 * null}. 041 */ 042 public BrokerAvailabilityEvent(boolean brokerAvailable, Object source) { 043 super(source); 044 this.brokerAvailable = brokerAvailable; 045 } 046 047 public boolean isBrokerAvailable() { 048 return this.brokerAvailable; 049 } 050 051 @Override 052 public String toString() { 053 return "BrokerAvailabilityEvent[available=" + this.brokerAvailable + ", " + getSource() + "]"; 054 } 055 056}