Path: blob/master/src/jdk.jconsole/share/classes/com/sun/tools/jconsole/JConsoleContext.java
40948 views
/*1* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.jconsole;2627import javax.management.MBeanServerConnection;28import java.beans.PropertyChangeListener;29import javax.swing.event.SwingPropertyChangeSupport;3031/**32* {@code JConsoleContext} represents a JConsole connection to a target33* application.34* <p>35* {@code JConsoleContext} notifies any {@code PropertyChangeListeners}36* about the {@linkplain #CONNECTION_STATE_PROPERTY <i>ConnectionState</i>}37* property change to {@link ConnectionState#CONNECTED CONNECTED} and38* {@link ConnectionState#DISCONNECTED DISCONNECTED}.39* The {@code JConsoleContext} instance will be the source for40* any generated events.41*42* @since 1.643*/44public interface JConsoleContext {45/**46* The {@link ConnectionState ConnectionState} bound property name.47*/48public static String CONNECTION_STATE_PROPERTY = "connectionState";4950/**51* Values for the {@linkplain #CONNECTION_STATE_PROPERTY52* <i>ConnectionState</i>} bound property.53*/54public enum ConnectionState {55/**56* The connection has been successfully established.57*/58CONNECTED,59/**60* No connection present.61*/62DISCONNECTED,63/**64* The connection is being attempted.65*/66CONNECTING67}6869/**70* Returns the {@link MBeanServerConnection MBeanServerConnection} for the71* connection to an application. The returned72* {@code MBeanServerConnection} object becomes invalid when73* the connection state is changed to the74* {@link ConnectionState#DISCONNECTED DISCONNECTED} state.75*76* @return the {@code MBeanServerConnection} for the77* connection to an application.78*/79public MBeanServerConnection getMBeanServerConnection();8081/**82* Returns the current connection state.83* @return the current connection state.84*/85public ConnectionState getConnectionState();8687/**88* Add a {@link java.beans.PropertyChangeListener PropertyChangeListener}89* to the listener list.90* The listener is registered for all properties.91* The same listener object may be added more than once, and will be called92* as many times as it is added.93* If {@code listener} is {@code null}, no exception is thrown and94* no action is taken.95*96* @param listener The {@code PropertyChangeListener} to be added97*/98public void addPropertyChangeListener(PropertyChangeListener listener);99100/**101* Removes a {@link java.beans.PropertyChangeListener PropertyChangeListener}102* from the listener list. This103* removes a {@code PropertyChangeListener} that was registered for all104* properties. If {@code listener} was added more than once to the same105* event source, it will be notified one less time after being removed. If106* {@code listener} is {@code null}, or was never added, no exception is107* thrown and no action is taken.108*109* @param listener the {@code PropertyChangeListener} to be removed110*/111public void removePropertyChangeListener(PropertyChangeListener listener);112}113114115