⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soapmonitor.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Copyright 2001,2004 The Apache Software Foundation. * * Licensed under the Apache Liusercense, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.apache.axis.utils;import org.apache.axis.client.AdminClient;import org.apache.axis.monitor.SOAPMonitorConstants;import org.w3c.dom.Document;import org.w3c.dom.Element;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.Node;import org.w3c.dom.NodeList;import javax.swing.BoxLayout;import javax.swing.ButtonGroup;import javax.swing.DefaultListModel;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JProgressBar;import javax.swing.JRadioButton;import javax.swing.JScrollPane;import javax.swing.JSplitPane;import javax.swing.JTabbedPane;import javax.swing.JTable;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.ListSelectionModel;import javax.swing.SwingConstants;import javax.swing.SwingUtilities;import javax.swing.UIManager;import javax.swing.WindowConstants;import javax.swing.border.BevelBorder;import javax.swing.border.EmptyBorder;import javax.swing.border.EtchedBorder;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import javax.swing.table.AbstractTableModel;import javax.swing.event.ChangeListener;import javax.xml.parsers.ParserConfigurationException;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Font;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.ByteArrayInputStream;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.lang.reflect.InvocationTargetException;import java.net.Socket;import java.net.URL;import java.net.MalformedURLException;import java.text.DateFormat;import java.util.Collection;import java.util.Date;import java.util.Enumeration;import java.util.HashMap;import java.util.Iterator;import java.util.Vector;/** * This is a SOAP Monitor Application class.  This class provides * the user interface for deploying the SOAP monitor service and * displaying data from the service. *  * @author Toshiyuki Kimura (toshi@apache.org) * @author Brian Price (pricebe@us.ibm.com) */public class SOAPMonitor extends JFrame implements ActionListener, ChangeListener {    /**     * Private data     */    private JPanel main_panel = null;    /**     * Field tabbed_pane     */    private JTabbedPane tabbed_pane = null;    /**     * Field top_pane     */    private JTabbedPane top_pane = null;    /**     * Field port     */    private int port = 5001;    /**     * Field axisHost     */    private String axisHost = "localhost";    /**     * Field axisPort     */    private int axisPort = 8080;    /**     * Field axisURL     */    private String axisURL = null;    /**     * Field pages     */    private Vector pages = null;    /**     * Field titleStr     */    private final String titleStr = "SOAP Monitor Administration";    /**     * Field set_panel     */    private JPanel set_panel = null;    /**     * Field titleLabel     */    private JLabel titleLabel = null;    /**     * Field add_btn     */    private JButton add_btn = null;    /**     * Field del_btn     */    private JButton del_btn = null;    /**     * Field save_btn     */    private JButton save_btn = null;    /**     * Field login_btn     */    private JButton login_btn = null;    /**     * Field model1     */    private DefaultListModel model1 = null;    /**     * Field model2     */    private DefaultListModel model2 = null;    /**     * Field list1     */    private JList list1 = null;    /**     * Field list2     */    private JList list2 = null;    /**     * Field serviceMap     */    private HashMap serviceMap = null;    /**     * Field originalDoc     */    private Document originalDoc = null;    /**     * Field axisUser     */    private static String axisUser = null;    /**     * Field axisPass     */    private static String axisPass = null;    /**     * Field adminClient     */    private AdminClient adminClient = new AdminClient();    /**     * Main method for this class     *      * @param args      * @throws Exception      */    public static void main(String args[]) throws Exception {        SOAPMonitor soapMonitor = null;        Options opts = new Options(args);        if (opts.isFlagSet('?') > 0) {            System.out.println(                    "Usage: SOAPMonitor [-l<url>] [-u<user>] [-w<password>] [-?]");            System.exit(0);        }        // Create an instance        soapMonitor = new SOAPMonitor();        // GET Axis URL.        // The default is "http://localhost:8080/axis/servlet/AxisServlet"        soapMonitor.axisURL = opts.getURL();        URL url = new URL(soapMonitor.axisURL);        soapMonitor.axisHost = url.getHost();        // GET User name & Password        axisUser = opts.getUser();        axisPass = opts.getPassword();        // Login and start application        soapMonitor.doLogin();    }    /**     * Constructor     */    public SOAPMonitor() {        setTitle("SOAP Monitor Application");        Dimension d = getToolkit().getScreenSize();        setSize(640, 480);        setLocation((d.width - getWidth()) / 2, (d.height - getHeight()) / 2);        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);        addWindowListener(new MyWindowAdapter());        // Try to use the system look and feel        try {            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());        } catch (Exception e) {        }        // Create main panel to hold notebook        main_panel = new JPanel();        main_panel.setBackground(Color.white);        main_panel.setLayout(new BorderLayout());        top_pane = new JTabbedPane();        set_panel = new JPanel();        // label for NORTH panel to display the pain title        titleLabel = new JLabel(titleStr);        titleLabel.setFont(new Font("Serif", Font.BOLD, 18));        // list control for WEST panel to list NOT monitored services        model1 = new DefaultListModel();        list1 = new JList(model1);        list1.setFixedCellWidth(250);        JScrollPane scroll1 = new JScrollPane(list1);        // list control for EAST panel to list monitored services        model2 = new DefaultListModel();        list2 = new JList(model2);        list2.setFixedCellWidth(250);        JScrollPane scroll2 = new JScrollPane(list2);        // buttons for CENTER panel to chage the monitoring state        add_btn = new JButton("Turn On [ >> ]");        del_btn = new JButton("[ << ] Turn Off");        JPanel center_panel = new JPanel();        GridBagLayout layout = new GridBagLayout();        center_panel.setLayout(layout);        GridBagConstraints c = new GridBagConstraints();        c.gridx = 0;        c.gridy = 0;        c.insets = new Insets(10, 10, 10, 10);        layout.setConstraints(add_btn, c);        center_panel.add(add_btn);        c.gridx = 0;        c.gridy = 1;        c.insets = new Insets(10, 10, 10, 10);        layout.setConstraints(del_btn, c);        center_panel.add(del_btn);        // buttons for SOUTH panel        save_btn = new JButton("Save changes");        login_btn = new JButton("Change server");        JPanel south_panel = new JPanel();        layout = new GridBagLayout();        c.gridx = 0;        c.gridy = 0;        c.insets = new Insets(10, 10, 10, 10);        layout.setConstraints(save_btn, c);        south_panel.add(save_btn);        c.gridx = 1;        c.gridy = 0;        c.insets = new Insets(10, 10, 10, 10);        layout.setConstraints(login_btn, c);        south_panel.add(login_btn);        // set all controls to the border layout        set_panel.setLayout(new BorderLayout(5, 5));        set_panel.add(titleLabel, BorderLayout.NORTH);        set_panel.add(south_panel, BorderLayout.SOUTH);        set_panel.add(scroll1, BorderLayout.WEST);        set_panel.add(scroll2, BorderLayout.EAST);        set_panel.add(center_panel, BorderLayout.CENTER);        // register the Action Listener        add_btn.addActionListener(this);        del_btn.addActionListener(this);        save_btn.addActionListener(this);        login_btn.addActionListener(this);        // set default button state as 'false'        add_btn.setEnabled(false);        del_btn.setEnabled(false);        save_btn.setEnabled(false);        login_btn.setEnabled(false);        top_pane.add("Setting", set_panel);        top_pane.add("Monitoring", main_panel);        getContentPane().add(top_pane);        // Create the notebook        tabbed_pane = new JTabbedPane(JTabbedPane.TOP);        main_panel.add(tabbed_pane, BorderLayout.CENTER);        top_pane.addChangeListener(this);        top_pane.setEnabled(false);        setVisible(true);    }    /**     * Do login process     *      * @return      */    private boolean doLogin() {        Dimension d = null;        // Login        LoginDlg login = new LoginDlg();        login.show();        if (!login.isLogin()) {            login_btn.setEnabled(true);            return false;        }        login.dispose();        save_btn.setEnabled(false);        login_btn.setEnabled(false);        // Get the axisHost & axisPort to be used        String url_str = login.getURL();        try {            URL url = new URL(url_str);            axisHost = url.getHost();            axisPort = url.getPort();            if (axisPort == -1) {                axisPort = 8080;            }            String axisPath = url.getPath();            axisURL = "http://" + axisHost + ":" + axisPort + axisPath;        } catch (MalformedURLException e) {            JOptionPane pane = new JOptionPane();            String msg = e.toString();            pane.setMessageType(JOptionPane.WARNING_MESSAGE);            pane.setMessage(msg);            pane.setOptions(new String[]{"OK"});            JDialog dlg = pane.createDialog(null, "Login status");            dlg.setVisible(true);            login_btn.setEnabled(true);            return false;        }        titleLabel.setText(titleStr + " for [" + axisHost + ":" + axisPort                + "]");        final JProgressBar progressBar = new JProgressBar(0, 100);        BarThread stepper = new BarThread(progressBar);        stepper.start();        JFrame progress = new JFrame();        d = new Dimension(250, 50);        progress.setSize(d);        d = getToolkit().getScreenSize();        progress.getContentPane().add(progressBar);        progress.setTitle("Now loading data ...");        progress.setLocation((d.width - progress.getWidth()) / 2,                (d.height - progress.getHeight()) / 2);        progress.show();        // Add notebook page for default host connection        pages = new Vector();        addPage(new SOAPMonitorPage(axisHost));        serviceMap = new HashMap();        originalDoc = getServerWSDD();        model1.clear();        model2.clear();        if (originalDoc != null) {            String ret = null;            NodeList nl = originalDoc.getElementsByTagName("service");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -