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

📄 soapmonitor.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    SwingConstants.RIGHT);            details_status = new JLabel("Status: ", SwingConstants.RIGHT);            details_time_value = new JLabel();            details_target_value = new JLabel();            details_status_value = new JLabel();            Dimension preferred_size = details_time.getPreferredSize();            preferred_size.width = 1;            details_time.setPreferredSize(preferred_size);            details_target.setPreferredSize(preferred_size);            details_status.setPreferredSize(preferred_size);            details_time_value.setPreferredSize(preferred_size);            details_target_value.setPreferredSize(preferred_size);            details_status_value.setPreferredSize(preferred_size);            details_header = new JPanel();            details_header_layout = new GridBagLayout();            details_header.setLayout(details_header_layout);            details_header_constraints = new GridBagConstraints();            details_header_constraints.fill = GridBagConstraints.BOTH;            details_header_constraints.weightx = 0.5;            details_header_layout.setConstraints(details_time,                    details_header_constraints);            details_header.add(details_time);            details_header_layout.setConstraints(details_time_value,                    details_header_constraints);            details_header.add(details_time_value);            details_header_layout.setConstraints(details_target,                    details_header_constraints);            details_header.add(details_target);            details_header_constraints.weightx = 1.0;            details_header_layout.setConstraints(details_target_value,                    details_header_constraints);            details_header.add(details_target_value);            details_header_constraints.weightx = .5;            details_header_layout.setConstraints(details_status,                    details_header_constraints);            details_header.add(details_status);            details_header_layout.setConstraints(details_status_value,                    details_header_constraints);            details_header.add(details_status_value);            details_header.setBorder(etched_border);            request_label = new JLabel("SOAP Request", SwingConstants.CENTER);            request_text = new SOAPMonitorTextArea();            request_text.setEditable(false);            request_scroll = new JScrollPane(request_text);            request_panel = new JPanel();            request_panel.setLayout(new BorderLayout());            request_panel.add(request_label, BorderLayout.NORTH);            request_panel.add(request_scroll, BorderLayout.CENTER);            response_label =                    new JLabel("SOAP Response", SwingConstants.CENTER);            response_text = new SOAPMonitorTextArea();            response_text.setEditable(false);            response_scroll = new JScrollPane(response_text);            response_panel = new JPanel();            response_panel.setLayout(new BorderLayout());            response_panel.add(response_label, BorderLayout.NORTH);            response_panel.add(response_scroll, BorderLayout.CENTER);            details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);            details_soap.setTopComponent(request_panel);            details_soap.setRightComponent(response_panel);            details_soap.setResizeWeight(.5);            details_panel = new JPanel();            layout_button = new JButton("Switch Layout");            layout_button.addActionListener(this);            reflow_xml = new JCheckBox("Reflow XML text");            reflow_xml.addActionListener(this);            details_buttons = new JPanel();            details_buttons.setLayout(new FlowLayout());            details_buttons.add(reflow_xml);            details_buttons.add(layout_button);            details_panel.setLayout(new BorderLayout());            details_panel.add(details_header, BorderLayout.NORTH);            details_panel.add(details_soap, BorderLayout.CENTER);            details_panel.add(details_buttons, BorderLayout.SOUTH);            details_panel.setBorder(empty_border);            // Add the two parts to the age split pane            split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);            split.setTopComponent(list_panel);            split.setRightComponent(details_panel);            // Build status area            start_button = new JButton("Start");            start_button.addActionListener(this);            stop_button = new JButton("Stop");            stop_button.addActionListener(this);            status_buttons = new JPanel();            status_buttons.setLayout(new FlowLayout());            status_buttons.add(start_button);            status_buttons.add(stop_button);            status_text = new JLabel();            status_text.setBorder(new BevelBorder(BevelBorder.LOWERED));            status_text_panel = new JPanel();            status_text_panel.setLayout(new BorderLayout());            status_text_panel.add(status_text, BorderLayout.CENTER);            status_text_panel.setBorder(empty_border);            status_area = new JPanel();            status_area.setLayout(new BorderLayout());            status_area.add(status_buttons, BorderLayout.WEST);            status_area.add(status_text_panel, BorderLayout.CENTER);            status_area.setBorder(etched_border);            // Add the split and status area to page            setLayout(new BorderLayout());            add(split, BorderLayout.CENTER);            add(status_area, BorderLayout.SOUTH);        }        /**         * Get the name of the host we are displaying         *          * @return          */        public String getHost() {            return host;        }        /**         * Set the status text         *          * @param txt          */        public void setStatus(String txt) {            status_text.setForeground(Color.black);            status_text.setText("  " + txt);        }        /**         * Set the status text to an error         *          * @param txt          */        public void setErrorStatus(String txt) {            status_text.setForeground(Color.red);            status_text.setText("  " + txt);        }        /**         * Start talking to the server         */        public void start() {            String codehost = axisHost;            if (socket == null) {                try {                    // Open the socket to the server                    socket = new Socket(codehost, port);                    // Create output stream                    out = new ObjectOutputStream(socket.getOutputStream());                    out.flush();                    // Create input stream and start background                    // thread to read data from the server                    in = new ObjectInputStream(socket.getInputStream());                    new Thread(this).start();                } catch (Exception e) {                    // Exceptions here are unexpected, but we can't                    // really do anything (so just write it to stdout                    // in case someone cares and then ignore it)                    e.printStackTrace();                    setErrorStatus(STATUS_NOCONNECT);                    socket = null;                }            } else {                // Already started            }            if (socket != null) {                // Make sure the right buttons are enabled                start_button.setEnabled(false);                stop_button.setEnabled(true);                setStatus(STATUS_ACTIVE);            }        }        /**         * Stop talking to the server         */        public void stop() {            if (socket != null) {                // Close all the streams and socket                if (out != null) {                    try {                        out.close();                    } catch (IOException ioe) {                    }                    out = null;                }                if (in != null) {                    try {                        in.close();                    } catch (IOException ioe) {                    }                    in = null;                }                if (socket != null) {                    try {                        socket.close();                    } catch (IOException ioe) {                    }                    socket = null;                }            } else {                // Already stopped            }            // Make sure the right buttons are enabled            start_button.setEnabled(true);            stop_button.setEnabled(false);            setStatus(STATUS_STOPPED);        }        /**         * Background thread used to receive data from         * the server.         */        public void run() {            Long id;            Integer message_type;            String target;            String soap;            SOAPMonitorData data;            int selected;            int row;            boolean update_needed;            while (socket != null) {                try {                    // Get the data from the server                    message_type = (Integer) in.readObject();                    // Process the data depending on its type                    switch (message_type.intValue()) {                        case SOAPMonitorConstants.SOAP_MONITOR_REQUEST:                            // Get the id, target and soap info                            id = (Long) in.readObject();                            target = (String) in.readObject();                            soap = (String) in.readObject();                            // Add new request data to the table                            data = new SOAPMonitorData(id, target, soap);                            model.addData(data);                            // If "most recent" selected then update                            // the details area if needed                            selected = table.getSelectedRow();                            if ((selected == 0) && model.filterMatch(data)) {                                valueChanged(null);                            }                            break;                        case SOAPMonitorConstants.SOAP_MONITOR_RESPONSE:                            // Get the id and soap info                            id = (Long) in.readObject();                            soap = (String) in.readObject();                            data = model.findData(id);                            if (data != null) {                                update_needed = false;                                // Get the selected row                                selected = table.getSelectedRow();                                // If "most recent", then always                                // update details area                                if (selected == 0) {                                    update_needed = true;                                }                                // If the data being updated is                                // selected then update details                                row = model.findRow(data);                                if ((row != -1) && (row == selected)) {                                    update_needed = true;                                }                                // Set the response and update table                                data.setSOAPResponse(soap);                                model.updateData(data);                                // Refresh details area (if needed)                                if (update_needed) {                                    valueChanged(null);                                }                            }                            break;                    }                } catch (Exception e) {                    // Exceptions are expected here when the                    // server communication has been terminated.                    if (stop_button.isEnabled()) {                        stop();                        setErrorStatus(STATUS_CLOSED);                    }                }            }        }        /**         * Listener to handle table selection changes         *          * @param e          */        public void valueChanged(ListSelectionEvent e) {            int row = table.getSelectedRow();            // Check if they selected a specific row            if (row > 0) {                remove_button.setEnabled(true);            } else {                remove_button.setEnabled(false);            }            // Check for "most recent" selection            if (row == 0) {                row = model.getRowCount() - 1;                if (row == 0) {                    row = -1;                }            }            if (row == -1) {                // Clear the details panel                details_time_value.setText("");                details_target_value.setText("");                details_status_value.setText("");                request_text.setText("");                response_text.setText("");            } else {                // Show the details for the row                SOAPMonitorData soap = model.getData(row);                details_time_value.setText(soap.getTime());                details_target_value.setText(soap.getTargetService());                details_status_value.setText(soap.getStatus());                if (soap.getSOAPRequest() == null) {                    request_text.setText("");                } else {                    request_text.setText(soap.getSOAPRequest());                    request_text.setCaretPosition(0);                }                if (soap.getSOAPResponse() == null) {                    response_text.setText("");                } else {                    response_text.setText(soap.getSOAPResponse());                    response_text.setCaretPosition(0);                }            }        }        /**         * Listener to handle button actions         *          * @param e          */        public void actionPerformed(ActionEvent e) {            // Check if the user pressed the remove button            if (e.getSource() == remove_button) {                int row = table.getSelectedRow();                model.removeRow(row);                table.clearSelection();                table.repaint();                valueChanged(null);            }            // Check if the user pressed the remove all button            if (e.getSource() == remove_all_button) {                model.clearAll();                table.setRowSelectionInterval(0, 0);                table.repaint();                valueChanged(null);            }            // Check if the user pressed the filter button            if (e.getSource() == filter_button) {                filter.showDialog();                if (filter.okPressed()) {                    // Update the display with new filter                    model.setFilter(filter);                    table.repaint();                }            }            // Check if the user pressed the start button            if (e.getSource() == start_button) {                start();            }            // Check if the user pressed the stop button            if (e.getSource() == stop_button) {                stop();            }            // Check if the user wants to switch layout            if (e.getSource() == layout_button) {                details_panel.remove(details_soap);                details_soap.removeAll();                if (details_soap.getOrientation()                        == JSplitPane.HORIZONTAL_SPLIT) {                    details_soap = new JSplitPane(JSplitPane.VERTICAL_SPLIT);                } else {                    details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);                }                details_soap.setTopComponent(request_panel);                details_soap.setRightComponent(response_panel);                details_soap.setResizeWeight(.5);                details_panel.add(details_soap, BorderLayout.CENTER);                details_panel.validate();                details_panel.repaint();            }            // Check if the user is changing the reflow option            if (e.getSource() == reflow_xml) {                request_text.setReflowXML(reflow_xml.isSelected());                response_text.setReflowXML(reflow_xml.isSelected());            }        }    }    /**     * This class represend the data for a SOAP request/response pair     */    class SOAPMonitorData {        /**         * Private data

⌨️ 快捷键说明

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