src/jdk.jconsole/share/classes/sun/tools/jconsole/inspector/XOperations.java
author vlivanov
Thu, 18 Jan 2018 02:25:18 +0300
changeset 48596 860326263d1f
parent 47216 71c04702a3d5
permissions -rw-r--r--
8194963: SystemDictionary::link_method_handle_constant() can't link MethodHandle.invoke()/invokeExact() Reviewed-by: kvn, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23711
95fb268275e3 8039022: Fix serial lint warnings in sun.tools.java
darcy
parents: 14342
diff changeset
     2
 * Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 715
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.tools.jconsole.inspector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.BorderLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GridLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.FlowLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.tools.jconsole.MBeansTab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.tools.jconsole.JConsole;
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
    40
import sun.tools.jconsole.Messages;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
23711
95fb268275e3 8039022: Fix serial lint warnings in sun.tools.java
darcy
parents: 14342
diff changeset
    42
@SuppressWarnings("serial") // JDK implementation class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
public abstract class XOperations extends JPanel implements ActionListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    public final static String OPERATION_INVOCATION_EVENT =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    46
            "jam.xoperations.invoke.result";
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private java.util.List<NotificationListener> notificationListenersList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private Hashtable<JButton, OperationEntry> operationEntryTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private XMBean mbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    private MBeanInfo mbeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private MBeansTab mbeansTab;
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    52
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    public XOperations(MBeansTab mbeansTab) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    54
        super(new GridLayout(1, 1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        this.mbeansTab = mbeansTab;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        operationEntryTable = new Hashtable<JButton, OperationEntry>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        ArrayList<NotificationListener> l =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    58
                new ArrayList<NotificationListener>(1);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        notificationListenersList =
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    60
                Collections.synchronizedList(l);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    63
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public void removeOperations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    68
    // Call on EDT
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    69
    public void loadOperations(XMBean mbean, MBeanInfo mbeanInfo) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        this.mbean = mbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        this.mbeanInfo = mbeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        // add operations information
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        MBeanOperationInfo operations[] = mbeanInfo.getOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        invalidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        // remove listeners, if any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        Component listeners[] = getComponents();
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    78
        for (int i = 0; i < listeners.length; i++) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    79
            if (listeners[i] instanceof JButton) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    80
                ((JButton) listeners[i]).removeActionListener(this);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    81
            }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    82
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        removeAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        setLayout(new BorderLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        JButton methodButton;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        JLabel methodLabel;
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    89
        JPanel innerPanelLeft, innerPanelRight;
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    90
        JPanel outerPanelLeft, outerPanelRight;
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    91
        outerPanelLeft = new JPanel(new GridLayout(operations.length, 1));
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    92
        outerPanelRight = new JPanel(new GridLayout(operations.length, 1));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    94
        for (int i = 0; i < operations.length; i++) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    95
            innerPanelLeft = new JPanel(new FlowLayout(FlowLayout.RIGHT));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            innerPanelRight = new JPanel(new FlowLayout(FlowLayout.LEFT));
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    97
            String returnType = operations[i].getReturnType();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    98
            if (returnType == null) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
    99
                methodLabel = new JLabel("null", JLabel.RIGHT);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   100
                if (JConsole.isDebug()) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   101
                    System.err.println(
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   102
                            "WARNING: The operation's return type " +
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   103
                            "shouldn't be \"null\". Check how the " +
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   104
                            "MBeanOperationInfo for the \"" +
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   105
                            operations[i].getName() + "\" operation has " +
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   106
                            "been defined in the MBean's implementation code.");
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   107
                }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   108
            } else {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   109
                methodLabel = new JLabel(
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   110
                        Utils.getReadableClassName(returnType), JLabel.RIGHT);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   111
            }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   112
            innerPanelLeft.add(methodLabel);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   113
            if (methodLabel.getText().length() > 20) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                methodLabel.setText(methodLabel.getText().
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   115
                        substring(methodLabel.getText().
24685
215fa91e1b4c 8044461: Cleanup new Boolean and single character strings
rriggs
parents: 23711
diff changeset
   116
                        lastIndexOf('.') + 1,
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   117
                        methodLabel.getText().length()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            methodButton = new JButton(operations[i].getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            methodButton.setToolTipText(operations[i].getDescription());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            boolean callable = isCallable(operations[i].getSignature());
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   123
            if (callable) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                methodButton.addActionListener(this);
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   125
            } else {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                methodButton.setEnabled(false);
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   127
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            MBeanParameterInfo[] signature = operations[i].getSignature();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            OperationEntry paramEntry = new OperationEntry(operations[i],
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   131
                    callable,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   132
                    methodButton,
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   133
                    this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            operationEntryTable.put(methodButton, paramEntry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            innerPanelRight.add(methodButton);
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   136
            if (signature.length == 0) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   137
                innerPanelRight.add(new JLabel("( )", JLabel.CENTER));
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   138
            } else {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   139
                innerPanelRight.add(paramEntry);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   140
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   142
            outerPanelLeft.add(innerPanelLeft, BorderLayout.WEST);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   143
            outerPanelRight.add(innerPanelRight, BorderLayout.CENTER);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   145
        add(outerPanelLeft, BorderLayout.WEST);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   146
        add(outerPanelRight, BorderLayout.CENTER);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private boolean isCallable(MBeanParameterInfo[] signature) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   151
        for (int i = 0; i < signature.length; i++) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   152
            if (!Utils.isEditableType(signature[i].getType())) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                return false;
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   154
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   159
    // Call on EDT
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public void actionPerformed(final ActionEvent e) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   161
        performInvokeRequest((JButton) e.getSource());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    void performInvokeRequest(final JButton button) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   165
        final OperationEntry entryIf = operationEntryTable.get(button);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   166
        new SwingWorker<Object, Void>() {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   167
            @Override
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   168
            public Object doInBackground() throws Exception {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   169
                return mbean.invoke(button.getText(),
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   170
                        entryIf.getParameters(), entryIf.getSignature());
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   171
            }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   172
            @Override
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   173
            protected void done() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                try {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   175
                    Object result = get();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                    // sends result notification to upper level if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    // there is a return value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    if (entryIf.getReturnType() != null &&
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   179
                            !entryIf.getReturnType().equals(Void.TYPE.getName()) &&
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   180
                            !entryIf.getReturnType().equals(Void.class.getName())) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   181
                        fireChangedNotification(OPERATION_INVOCATION_EVENT, button, result);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   182
                    } else {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   183
                        new ThreadDialog(
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   184
                                button,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   185
                                Messages.METHOD_SUCCESSFULLY_INVOKED,
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   186
                                Messages.INFO,
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   187
                                JOptionPane.INFORMATION_MESSAGE).run();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   188
                    }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   189
                } catch (Throwable t) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   190
                    t = Utils.getActualException(t);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   191
                    if (JConsole.isDebug()) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   192
                        t.printStackTrace();
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   193
                    }
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   194
                    new ThreadDialog(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                            button,
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   196
                            Messages.PROBLEM_INVOKING + " " +
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   197
                            button.getText() + " : " + t.toString(),
12851
3334e1c781d0 7017818: NLS: JConsoleResources.java cannot be handled by translation team
egahlin
parents: 5506
diff changeset
   198
                            Messages.ERROR,
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   199
                            JOptionPane.ERROR_MESSAGE).run();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            }
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   202
        }.execute();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    public void addOperationsListener(NotificationListener nl) {
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   206
        notificationListenersList.add(nl);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   207
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public void removeOperationsListener(NotificationListener nl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        notificationListenersList.remove(nl);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   213
    // Call on EDT
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   214
    private void fireChangedNotification(
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   215
            String type, Object source, Object handback) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   216
        Notification n = new Notification(type, source, 0);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   217
        for (NotificationListener nl : notificationListenersList) {
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   218
            nl.handleNotification(n, handback);
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   219
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
55
5ecee29e98d8 6655515: MBeans tab: operation return values of type Component displayed as String
lmalvent
parents: 2
diff changeset
   222
    protected abstract MBeanOperationInfo[] updateOperations(MBeanOperationInfo[] operations);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
}