1 /*
2 * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.tools.jconsole;
27
28 import javax.management.MBeanServerConnection;
29 import java.beans.PropertyChangeListener;
30 import javax.swing.event.SwingPropertyChangeSupport;
31
32 /**
33 * {@code JConsoleContext} represents a JConsole connection to a target
34 * application.
35 * <p>
36 * {@code JConsoleContext} notifies any {@code PropertyChangeListeners}
37 * about the {@linkplain #CONNECTION_STATE_PROPERTY <i>ConnectionState</i>}
38 * property change to {@link ConnectionState#CONNECTED CONNECTED} and
39 * {@link ConnectionState#DISCONNECTED DISCONNECTED}.
40 * The {@code JConsoleContext} instance will be the source for
41 * any generated events.
42 * <p>
43 *
44 * @since 1.6
45 */
46 @jdk.Exported
47 public interface JConsoleContext {
48 /**
49 * The {@link ConnectionState ConnectionState} bound property name.
50 */
51 public static String CONNECTION_STATE_PROPERTY = "connectionState";
52
53 /**
54 * Values for the {@linkplain #CONNECTION_STATE_PROPERTY
55 * <i>ConnectionState</i>} bound property.
56 */
57 @jdk.Exported
58 public enum ConnectionState {
59 /**
60 * The connection has been successfully established.
61 */
62 CONNECTED,
63 /**
64 * No connection present.
65 */
66 DISCONNECTED,
67 /**
68 * The connection is being attempted.
69 */
70 CONNECTING
71 }
72
73 /**
74 * Returns the {@link MBeanServerConnection MBeanServerConnection} for the
75 * connection to an application. The returned
76 * {@code MBeanServerConnection} object becomes invalid when
77 * the connection state is changed to the
78 * {@link ConnectionState#DISCONNECTED DISCONNECTED} state.
79 *
80 * @return the {@code MBeanServerConnection} for the
81 * connection to an application.
82 */
83 public MBeanServerConnection getMBeanServerConnection();
84
85 /**
86 * Returns the current connection state.
87 * @return the current connection state.
88 */
89 public ConnectionState getConnectionState();
90
91 /**
92 * Add a {@link java.beans.PropertyChangeListener PropertyChangeListener}
93 * to the listener list.
94 * The listener is registered for all properties.
95 * The same listener object may be added more than once, and will be called
96 * as many times as it is added.
97 * If {@code listener} is {@code null}, no exception is thrown and
98 * no action is taken.
99 *
100 * @param listener The {@code PropertyChangeListener} to be added
101 */
102 public void addPropertyChangeListener(PropertyChangeListener listener);
103
104 /**
105 * Removes a {@link java.beans.PropertyChangeListener PropertyChangeListener}
106 * from the listener list. This
107 * removes a {@code PropertyChangeListener} that was registered for all
108 * properties. If {@code listener} was added more than once to the same
109 * event source, it will be notified one less time after being removed. If
110 * {@code listener} is {@code null}, or was never added, no exception is
111 * thrown and no action is taken.
112 *
113 * @param listener the {@code PropertyChangeListener} to be removed
114 */
115 public void removePropertyChangeListener(PropertyChangeListener listener);
116 }
--- EOF ---