FileDocCategorySizeDatePackage
tcpmon.javaAPI DocApache Axis 1.480640Sat Apr 22 18:57:28 BST 2006org.apache.axis.utils

tcpmon

public class tcpmon extends JFrame
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

Fields Summary
private JTabbedPane
notebook
private static final int
STATE_COLUMN
private static final int
TIME_COLUMN
private static final int
INHOST_COLUMN
private static final int
OUTHOST_COLUMN
private static final int
REQ_COLUMN
private static final String
DEFAULT_HOST
private static final int
DEFAULT_PORT
private static ResourceBundle
messages
Constructors Summary
public tcpmon(int listenPort, String targetHost, int targetPort, boolean embedded)

        super ( getMessage("tcpmon00", "TCPMonitor") );

        notebook = new JTabbedPane();
        this.getContentPane().add( notebook );

        new AdminPage( notebook, getMessage("admin00", "Admin") );

        if ( listenPort != 0 ) {
            Listener l = null ;

            if ( targetHost == null ) {
                l = new Listener( notebook, null, listenPort,
                    targetHost, targetPort, true, null);
            } else {
                l = new Listener( notebook, null, listenPort,
                    targetHost, targetPort, false, null);
            }
            notebook.setSelectedIndex( 1 );

            l.HTTPProxyHost = System.getProperty( "http.proxyHost" );
            if ( l.HTTPProxyHost != null && l.HTTPProxyHost.equals("") ) {
                l.HTTPProxyHost = null ;
            }

            if ( l.HTTPProxyHost != null ) {
                String tmp = System.getProperty( "http.proxyPort" );

                if ( tmp != null && tmp.equals("") ) {
                    tmp = null ;
                }
                if ( tmp == null ) {
                    l.HTTPProxyPort = 80 ;
                } else {
                    l.HTTPProxyPort = Integer.parseInt( tmp );
                }
            }
        }
        
        if(!embedded) {
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        }
        this.pack();
        this.setSize( 600, 600 );
        this.setVisible( true );
    
public tcpmon(int listenPort, String targetHost, int targetPort)

        this(listenPort, targetHost, targetPort, false);
    
Methods Summary
public static java.lang.StringgetMessage(java.lang.String key, java.lang.String defaultMsg)
Get the message with the given key. There are no arguments for this message.


                        
           
        try {
            if (messages == null) {
                initializeMessages();
            }
            return messages.getString(key);
        } catch (Throwable t) {
            // If there is any problem whatsoever getting the internationalized
            // message, return the default.
            return defaultMsg;
        }
    
private static voidinitializeMessages()
Load the resource bundle messages from the properties file. This is ONLY done when it is needed. If no messages are printed (for example, only Wsdl2java is being run in non- verbose mode) then there is no need to read the properties file.

        messages = ResourceBundle.getBundle("org.apache.axis.utils.tcpmon");
    
public static voidmain(java.lang.String[] args)
this is our main method

param
args

        try {
            //switch between swing L&F here
            setupLookAndFeel(true);
            if ( args.length == 3 ) {
                int p1 = Integer.parseInt( args[0] );
                int p2 = Integer.parseInt( args[2] );

                new tcpmon( p1, args[1], p2 );
            }
            else if ( args.length == 1 ) {
                int p1 = Integer.parseInt( args[0] );

                new tcpmon( p1, null, 0 );
            }
            else if ( args.length != 0 ) {
                System.err.println( getMessage("usage00", "Usage:")
                        + " tcpmon [listenPort targetHost targetPort]\n");
            }
            else {
                new tcpmon(0, null, 0);
            }
        }
        catch ( Throwable exp ) {
            exp.printStackTrace();
        }
    
private static voidsetupLookAndFeel(boolean nativeLookAndFeel)
set up the L&F

        String classname= UIManager.getCrossPlatformLookAndFeelClassName();
        if(nativeLookAndFeel) {
            classname= UIManager.getSystemLookAndFeelClassName();
        }
        String lafProperty= System.getProperty("tcpmon.laf", "");
        if(lafProperty.length()>0) {
            classname=lafProperty;
        }
        try {
            UIManager.setLookAndFeel(classname);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }