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

📄 tcpmon.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Copyright 2001-2004 The Apache Software Foundation. *  * Licensed under the Apache License, 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 java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.ByteArrayInputStream;import java.io.File;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStream;import java.io.PrintWriter;import java.io.StringWriter;import java.net.ServerSocket;import java.net.Socket;import java.net.URL;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Date;import java.util.Iterator;import java.util.ResourceBundle;import java.util.Vector;import javax.swing.BorderFactory;import javax.swing.Box;import javax.swing.BoxLayout;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;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.UIManager;import javax.swing.UnsupportedLookAndFeelException;import javax.swing.border.TitledBorder;import javax.swing.event.ChangeEvent;import javax.swing.event.ListSelectionEvent;import javax.swing.event.ListSelectionListener;import javax.swing.plaf.basic.BasicButtonListener;import javax.swing.table.DefaultTableModel;import javax.swing.table.TableColumn;import javax.swing.table.TableModel;import javax.swing.text.AttributeSet;import javax.swing.text.BadLocationException;import javax.swing.text.Document;import javax.swing.text.PlainDocument;/** * TCP monitor to log http messages and responses, both SOAP and plain HTTP. * If you want to choose a different Swing look and feel, set the property * tcpmon.laf to the classname of the new look and feel * @author Doug Davis (dug@us.ibm.com) * @author Steve Loughran */public class tcpmon extends JFrame {    private JTabbedPane  notebook = null ;    private static final int STATE_COLUMN    = 0 ;    private static final int TIME_COLUMN     = 1 ;    private static final int INHOST_COLUMN   = 2 ;    private static final int OUTHOST_COLUMN  = 3 ;    private static final int REQ_COLUMN      = 4 ;    private static final String DEFAULT_HOST="127.0.0.1";    private static final int    DEFAULT_PORT=8080;    /**     * this is the admin page     */    class AdminPage extends JPanel {        public JRadioButton  listenerButton, proxyButton ;        public JLabel        hostLabel, tportLabel;        public NumberField  port;        public HostnameField host;        public NumberField  tport ;        public JTabbedPane   noteb ;        public JCheckBox     HTTPProxyBox ;        public HostnameField    HTTPProxyHost;        public NumberField HTTPProxyPort ;        public JLabel        HTTPProxyHostLabel, HTTPProxyPortLabel ;        public JLabel        delayTimeLabel, delayBytesLabel;        public NumberField delayTime, delayBytes;        public JCheckBox     delayBox;        public AdminPage( JTabbedPane notebook, String name ) {            JPanel     mainPane  = null ;            JButton    addButton = null ;            this.setLayout( new BorderLayout() );            noteb = notebook ;            GridBagLayout       layout        = new GridBagLayout();            GridBagConstraints  c             = new GridBagConstraints();            mainPane = new JPanel(layout);            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER;            mainPane.add( new JLabel(getMessage("newTCP00", "Create a new TCP/IP Monitor...") + " "), c );            // Add some blank space            mainPane.add( Box.createRigidArea(new Dimension(1, 5)), c );            // The listener info            ///////////////////////////////////////////////////////////////////            JPanel   tmpPanel = new JPanel(new GridBagLayout());            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = 1 ;            tmpPanel.add( new JLabel(getMessage("listenPort00", "Listen Port #") + " "), c );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            tmpPanel.add( port = new NumberField(4), c );            mainPane.add( tmpPanel, c );            mainPane.add( Box.createRigidArea(new Dimension(1, 5)), c );            // Group for the radio buttons            ButtonGroup btns = new ButtonGroup();            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            mainPane.add( new JLabel(getMessage("actAs00", "Act as a...") ), c );            // Target Host/Port section            ///////////////////////////////////////////////////////////////////            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            final String listener = getMessage("listener00", "Listener");            mainPane.add( listenerButton  = new JRadioButton( listener ), c );            btns.add( listenerButton );            listenerButton.setSelected( true );            listenerButton.addActionListener( new ActionListener() {                    public void actionPerformed(ActionEvent event) {                        if (listener.equals(event.getActionCommand())) {                            boolean state = listenerButton.isSelected();                            tport.setEnabled( state );                            host.setEnabled( state );                            hostLabel.setForeground(state ? Color.black : Color.gray);                            tportLabel.setForeground(state ? Color.black : Color.gray);                        }                    }                }            );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = 1 ;            mainPane.add( Box.createRigidArea(new Dimension(25, 0)) );            mainPane.add( hostLabel = new JLabel(getMessage("targetHostname00", "Target Hostname") + " "), c );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            host = new HostnameField(30);            mainPane.add( host, c );            host.setText(DEFAULT_HOST);            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = 1 ;            mainPane.add( Box.createRigidArea(new Dimension(25, 0)) );            mainPane.add( tportLabel = new JLabel(getMessage("targetPort00", "Target Port #") + " "), c );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            tport = new NumberField(4);            mainPane.add( tport, c );            tport.setValue(DEFAULT_PORT);            // Act as proxy section            ///////////////////////////////////////////////////////////////////            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            final String proxy = getMessage("proxy00", "Proxy");            mainPane.add( proxyButton = new JRadioButton( proxy ), c);            btns.add( proxyButton );            proxyButton.addActionListener( new ActionListener() {                    public void actionPerformed(ActionEvent event) {                        if (proxy.equals(event.getActionCommand())) {                            boolean state = proxyButton.isSelected();                            tport.setEnabled( !state );                            host.setEnabled( !state );                            hostLabel.setForeground(state ? Color.gray : Color.black);                            tportLabel.setForeground(state ? Color.gray : Color.black);                        }                    }                }            );            // Spacer            /////////////////////////////////////////////////////////////////            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            mainPane.add( Box.createRigidArea(new Dimension(1, 10)), c );            // Options section            ///////////////////////////////////////////////////////////////////            JPanel       opts = new JPanel(new GridBagLayout());            opts.setBorder( new TitledBorder(getMessage("options00", "Options")) );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            mainPane.add( opts, c );            // HTTP Proxy Support section            ///////////////////////////////////////////////////////////////////            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            final String proxySupport = getMessage("proxySupport00", "HTTP Proxy Support");            opts.add(HTTPProxyBox = new JCheckBox(proxySupport), c);            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = 1 ;            opts.add( HTTPProxyHostLabel = new JLabel(getMessage("hostname00", "Hostname") + " "), c );            HTTPProxyHostLabel.setForeground( Color.gray );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            opts.add( HTTPProxyHost = new HostnameField(30), c );            HTTPProxyHost.setEnabled( false );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = 1 ;            opts.add( HTTPProxyPortLabel = new JLabel(getMessage("port00", "Port #") + " "), c );            HTTPProxyPortLabel.setForeground( Color.gray );            c.anchor    = GridBagConstraints.WEST ;            c.gridwidth = GridBagConstraints.REMAINDER ;            opts.add( HTTPProxyPort = new NumberField(4), c );            HTTPProxyPort.setEnabled( false );            HTTPProxyBox.addActionListener( new ActionListener() {                    public void actionPerformed(ActionEvent event) {                        if (proxySupport.equals(event.getActionCommand())) {                            boolean b = HTTPProxyBox.isSelected();                            Color   color = b ? Color.black : Color.gray ;                            HTTPProxyHost.setEnabled( b );                            HTTPProxyPort.setEnabled( b );                            HTTPProxyHostLabel.setForeground( color );                            HTTPProxyPortLabel.setForeground( color );                        }                    }                }            );            // Set default proxy values...            String tmp = System.getProperty( "http.proxyHost" );            if ( tmp != null && tmp.equals("") ) {                tmp = null ;            }            HTTPProxyBox.setSelected( tmp != null );            HTTPProxyHost.setEnabled( tmp != null );            HTTPProxyPort.setEnabled( tmp != null );            HTTPProxyHostLabel.setForeground( tmp != null ? Color.black : Color.gray);            HTTPProxyPortLabel.setForeground( tmp != null ? Color.black : Color.gray);            if ( tmp != null ) {                HTTPProxyBox.setSelected( true );                HTTPProxyHost.setText( tmp );                tmp = System.getProperty( "http.proxyPort" );                if ( tmp != null && tmp.equals("") ) {                    tmp = null ;                }                if ( tmp == null ) {                    tmp = "80" ;                }                HTTPProxyPort.setText( tmp );            }            //add byte delay fields            opts.add(Box.createRigidArea(new Dimension(1, 10)), c);            c.anchor = GridBagConstraints.WEST;            c.gridwidth = GridBagConstraints.REMAINDER;            final String delaySupport = getMessage("delay00", "Simulate Slow Connection");            opts.add(delayBox = new JCheckBox(delaySupport), c);            //bytes per pause            c.anchor = GridBagConstraints.WEST;            c.gridwidth = 1;            delayBytesLabel=new JLabel(getMessage("delay01",  "Bytes per Pause"));            opts.add(delayBytesLabel, c);            delayBytesLabel.setForeground(Color.gray);            c.anchor = GridBagConstraints.WEST;            c.gridwidth = GridBagConstraints.REMAINDER;            opts.add(delayBytes = new NumberField(6), c);            delayBytes.setEnabled(false);            //delay interval            c.anchor = GridBagConstraints.WEST;            c.gridwidth = 1;

⌨️ 快捷键说明

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