Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/tools/jconsole/JConsoleContext.java
38920 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* <p>42*43* @since 1.644*/45@jdk.Exported46public interface JConsoleContext {47/**48* The {@link ConnectionState ConnectionState} bound property name.49*/50public static String CONNECTION_STATE_PROPERTY = "connectionState";5152/**53* Values for the {@linkplain #CONNECTION_STATE_PROPERTY54* <i>ConnectionState</i>} bound property.55*/56@jdk.Exported57public enum ConnectionState {58/**59* The connection has been successfully established.60*/61CONNECTED,62/**63* No connection present.64*/65DISCONNECTED,66/**67* The connection is being attempted.68*/69CONNECTING70}7172/**73* Returns the {@link MBeanServerConnection MBeanServerConnection} for the74* connection to an application. The returned75* {@code MBeanServerConnection} object becomes invalid when76* the connection state is changed to the77* {@link ConnectionState#DISCONNECTED DISCONNECTED} state.78*79* @return the {@code MBeanServerConnection} for the80* connection to an application.81*/82public MBeanServerConnection getMBeanServerConnection();8384/**85* Returns the current connection state.86* @return the current connection state.87*/88public ConnectionState getConnectionState();8990/**91* Add a {@link java.beans.PropertyChangeListener PropertyChangeListener}92* to the listener list.93* The listener is registered for all properties.94* The same listener object may be added more than once, and will be called95* as many times as it is added.96* If {@code listener} is {@code null}, no exception is thrown and97* no action is taken.98*99* @param listener The {@code PropertyChangeListener} to be added100*/101public void addPropertyChangeListener(PropertyChangeListener listener);102103/**104* Removes a {@link java.beans.PropertyChangeListener PropertyChangeListener}105* from the listener list. This106* removes a {@code PropertyChangeListener} that was registered for all107* properties. If {@code listener} was added more than once to the same108* event source, it will be notified one less time after being removed. If109* {@code listener} is {@code null}, or was never added, no exception is110* thrown and no action is taken.111*112* @param listener the {@code PropertyChangeListener} to be removed113*/114public void removePropertyChangeListener(PropertyChangeListener listener);115}116117118