/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.table.*;
import org.apache.axis.monitor.SOAPMonitorConstants;
/**
* This is a SOAP Mointor Applet class. This class provides
* the user interface for displaying data from the SOAP
* monitor service.
*
* @author Brian Price (pricebe@us.ibm.com)
*
*/
public class SOAPMonitorApplet extends JApplet {
/**
* Private data
*/
private JPanel main_panel = null;
private JTabbedPane tabbed_pane = null;
private int port = 0;
private Vector pages = null;
/**
* Constructor
*/
public SOAPMonitorApplet() {
}
/**
* Applet initialization
*/
public void init() {
// Get the port to be used
String port_str = getParameter("port");
if (port_str != null) {
port = Integer.parseInt(port_str);
}
// 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());
setContentPane(main_panel);
// Create the notebook
tabbed_pane = new JTabbedPane(JTabbedPane.TOP);
main_panel.add(tabbed_pane,BorderLayout.CENTER);
// Add notebook page for default host connection
pages = new Vector();
addPage(new SOAPMonitorPage(getCodeBase().getHost()));
}
/**
* Add a page to the notebook
*/
private void addPage(SOAPMonitorPage pg) {
tabbed_pane.addTab(" "+pg.getHost()+" ", pg);
pages.addElement(pg);
}
/**
* Applet is being displayed
*/
public void start() {
// Tell all pages to start talking to the server
Enumeration e = pages.elements();
while (e.hasMoreElements()) {
SOAPMonitorPage pg = (SOAPMonitorPage) e.nextElement();
if (pg != null) {
pg.start();
}
}
}
/*
* Applet is no longer displayed
*/
public void stop() {
// Tell all pages to stop talking to the server
Enumeration e = pages.elements();
while (e.hasMoreElements()) {
SOAPMonitorPage pg = (SOAPMonitorPage) e.nextElement();
if (pg != null) {
pg.stop();
}
}
}
/**
* Applet cleanup
*/
public void destroy() {
tabbed_pane = null;
main_panel = null;
}
/**
* This class provides the contents of a notebook page
* representing a server connection.
*/
class SOAPMonitorPage extends JPanel
implements Runnable,
ListSelectionListener,
ActionListener {
/**
* Status Strings
*/
private final String STATUS_ACTIVE = "The SOAP Monitor is started.";
private final String STATUS_STOPPED = "The SOAP Monitor is stopped.";
private final String STATUS_CLOSED = "The server communication has been terminated.";
private final String STATUS_NOCONNECT = "The SOAP Monitor is unable to communcate with the server.";
/**
* Private data
*/
private String host = null;
private Socket socket = null;
private ObjectInputStream in = null;
private ObjectOutputStream out = null;
private SOAPMonitorTableModel model = null;
private JTable table = null;
private JScrollPane scroll = null;
private JPanel list_panel = null;
private JPanel list_buttons = null;
private JButton remove_button = null;
private JButton remove_all_button = null;
private JButton filter_button = null;
private JPanel details_panel = null;
private JPanel details_header = null;
private JSplitPane details_soap = null;
private JPanel details_buttons = null;
private JLabel details_time = null;
private JLabel details_target = null;
private JLabel details_status = null;
private JLabel details_time_value = null;
private JLabel details_target_value = null;
private JLabel details_status_value = null;
private EmptyBorder empty_border = null;
private EtchedBorder etched_border = null;
private JPanel request_panel = null;
private JPanel response_panel = null;
private JLabel request_label = null;
private JLabel response_label = null;
评论0