You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/02/20 18:57:03 UTC
svn commit: r154537 [6/6] - in webservices/axis/trunk/java/modules:
core/src/java/org/apache/axis/ core/src/java/org/apache/axis/addressing/
core/src/java/org/apache/axis/addressing/miheaders/
core/src/java/org/apache/axis/addressing/om/
core/src/java/org/apache/axis/clientapi/
core/src/java/org/apache/axis/context/
core/src/java/org/apache/axis/description/
core/src/java/org/apache/axis/engine/ core/src/java/org/apache/axis/handlers/
core/src/java/org/apache/axis/phaseresolver/
core/src/java/org/apache/axis/providers/
core/src/java/org/apache/axis/receivers/
core/src/java/org/apache/axis/transport/
core/src/java/org/apache/axis/transport/http/
core/src/java/org/apache/axis/util/
deployment/src/samples/deployment/service1/org/apache/axis/sample/echo/
samples/src/java/encoding/sample1/
samples/src/java/encoding/sample2/benchMark/
samples/src/java/org/apache/axis/testUtils/
Modified: webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/util/tcpmon.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/util/tcpmon.java?view=diff&r1=154536&r2=154537
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/util/tcpmon.java (original)
+++ webservices/axis/trunk/java/modules/core/src/java/org/apache/axis/util/tcpmon.java Sun Feb 20 09:56:49 2005
@@ -1,12 +1,12 @@
/*
* Copyright 2004,2005 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.
@@ -82,33 +82,111 @@
* @author Steve Loughran
*/
public class tcpmon extends JFrame {
+ /**
+ * Field notebook
+ */
private JTabbedPane notebook = null;
+ /**
+ * Field STATE_COLUMN
+ */
private static final int STATE_COLUMN = 0;
+
+ /**
+ * Field OUTHOST_COLUMN
+ */
private static final int OUTHOST_COLUMN = 3;
+
+ /**
+ * Field REQ_COLUMN
+ */
private static final int REQ_COLUMN = 4;
+ /**
+ * Field DEFAULT_HOST
+ */
private static final String DEFAULT_HOST = "127.0.0.1";
+
+ /**
+ * Field DEFAULT_PORT
+ */
private static final int DEFAULT_PORT = 8080;
/**
* this is the admin page
*/
class AdminPage extends JPanel {
+ /**
+ * Field listenerButton, proxyButton
+ */
public JRadioButton listenerButton, proxyButton;
+
+ /**
+ * Field hostLabel, tportLabel
+ */
public JLabel hostLabel, tportLabel;
+
+ /**
+ * Field port
+ */
public NumberField port;
+
+ /**
+ * Field host
+ */
public HostnameField host;
+
+ /**
+ * Field tport
+ */
public NumberField tport;
+
+ /**
+ * Field noteb
+ */
public JTabbedPane noteb;
+
+ /**
+ * Field HTTPProxyBox
+ */
public JCheckBox HTTPProxyBox;
+
+ /**
+ * Field HTTPProxyHost
+ */
public HostnameField HTTPProxyHost;
+
+ /**
+ * Field HTTPProxyPort
+ */
public NumberField HTTPProxyPort;
+
+ /**
+ * Field HTTPProxyHostLabel, HTTPProxyPortLabel
+ */
public JLabel HTTPProxyHostLabel, HTTPProxyPortLabel;
+
+ /**
+ * Field delayTimeLabel, delayBytesLabel
+ */
public JLabel delayTimeLabel, delayBytesLabel;
+
+ /**
+ * Field delayTime, delayBytes
+ */
public NumberField delayTime, delayBytes;
+
+ /**
+ * Field delayBox
+ */
public JCheckBox delayBox;
+ /**
+ * Constructor AdminPage
+ *
+ * @param notebook
+ * @param name
+ */
public AdminPage(JTabbedPane notebook, String name) {
JPanel mainPane = null;
JButton addButton = null;
@@ -119,17 +197,21 @@
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);
+ 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);
+ tmpPanel.add(new JLabel(getMessage("listenPort00", "Listen Port #")
+ + " "), c);
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
tmpPanel.add(port = new NumberField(4), c);
@@ -143,7 +225,7 @@
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");
@@ -156,16 +238,21 @@
boolean state = listenerButton.isSelected();
tport.setEnabled(state);
host.setEnabled(state);
- hostLabel.setForeground(state ? Color.black : Color.gray);
- tportLabel.setForeground(state ? Color.black : Color.gray);
+ 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);
+ mainPane.add(hostLabel =
+ new JLabel(getMessage("targetHostname00", "Target Hostname")
+ + " "), c);
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
host = new HostnameField(30);
@@ -174,7 +261,9 @@
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);
+ mainPane.add(tportLabel =
+ new JLabel(getMessage("targetPort00", "Target Port #")
+ + " "), c);
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
tport = new NumberField(4);
@@ -182,7 +271,7 @@
tport.setValue(DEFAULT_PORT);
// Act as proxy section
- ///////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
final String proxy = getMessage("proxy00", "Proxy");
@@ -194,36 +283,42 @@
boolean state = proxyButton.isSelected();
tport.setEnabled(!state);
host.setEnabled(!state);
- hostLabel.setForeground(state ? Color.gray : Color.black);
- tportLabel.setForeground(state ? Color.gray : Color.black);
+ 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")));
+ 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");
+ 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);
+ opts.add(HTTPProxyHostLabel =
+ new JLabel(getMessage("hostname00", "Hostname") + " "), c);
HTTPProxyHostLabel.setForeground(Color.gray);
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
@@ -231,7 +326,8 @@
HTTPProxyHost.setEnabled(false);
c.anchor = GridBagConstraints.WEST;
c.gridwidth = 1;
- opts.add(HTTPProxyPortLabel = new JLabel(getMessage("port00", "Port #") + " "), c);
+ opts.add(HTTPProxyPortLabel =
+ new JLabel(getMessage("port00", "Port #") + " "), c);
HTTPProxyPortLabel.setForeground(Color.gray);
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
@@ -241,31 +337,36 @@
public void actionPerformed(ActionEvent event) {
if (proxySupport.equals(event.getActionCommand())) {
boolean b = HTTPProxyBox.isSelected();
- Color color = b ? Color.black : Color.gray;
+ 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("")) {
+ 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);
+ 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("")) {
+ if ((tmp != null) && tmp.equals("")) {
tmp = null;
}
if (tmp == null) {
@@ -274,17 +375,19 @@
HTTPProxyPort.setText(tmp);
}
- //add byte delay fields
+ // 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");
+ final String delaySupport = getMessage("delay00",
+ "Simulate Slow Connection");
opts.add(delayBox = new JCheckBox(delaySupport), c);
- //bytes per pause
+ // bytes per pause
c.anchor = GridBagConstraints.WEST;
c.gridwidth = 1;
- delayBytesLabel = new JLabel(getMessage("delay01", "Bytes per Pause"));
+ delayBytesLabel = new JLabel(getMessage("delay01",
+ "Bytes per Pause"));
opts.add(delayBytesLabel, c);
delayBytesLabel.setForeground(Color.gray);
c.anchor = GridBagConstraints.WEST;
@@ -292,10 +395,11 @@
opts.add(delayBytes = new NumberField(6), c);
delayBytes.setEnabled(false);
- //delay interval
+ // delay interval
c.anchor = GridBagConstraints.WEST;
c.gridwidth = 1;
- delayTimeLabel = new JLabel(getMessage("delay02", "Delay in Milliseconds"));
+ delayTimeLabel = new JLabel(getMessage("delay02",
+ "Delay in Milliseconds"));
opts.add(delayTimeLabel, c);
delayTimeLabel.setForeground(Color.gray);
c.anchor = GridBagConstraints.WEST;
@@ -303,27 +407,28 @@
opts.add(delayTime = new NumberField(6), c);
delayTime.setEnabled(false);
- //enabler callback
+ // enabler callback
delayBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (delaySupport.equals(event.getActionCommand())) {
boolean b = delayBox.isSelected();
- Color color = b ? Color.black : Color.gray;
+ Color color = b
+ ? Color.black
+ : Color.gray;
delayBytes.setEnabled(b);
delayTime.setEnabled(b);
delayBytesLabel.setForeground(color);
delayTimeLabel.setForeground(color);
}
}
- }
- );
+ });
// Spacer
- //////////////////////////////////////////////////////////////////
+ // ////////////////////////////////////////////////////////////////
mainPane.add(Box.createRigidArea(new Dimension(1, 10)), c);
// ADD Button
- ///////////////////////////////////////////////////////////////////
+ // /////////////////////////////////////////////////////////////////
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
final String add = getMessage("add00", "Add");
@@ -339,7 +444,8 @@
int lPort;
lPort = port.getValue(0);
if (lPort == 0) {
- //no port, button does nothing
+
+ // no port, button does nothing
return;
}
String tHost = host.getText();
@@ -353,12 +459,14 @@
}
try {
l = new Listener(noteb, null, lPort, tHost, tPort,
- proxyButton.isSelected(), slowLink);
+ proxyButton.isSelected(),
+ slowLink);
} catch (Exception e) {
e.printStackTrace();
}
+
// Pick-up the HTTP Proxy settings
- ///////////////////////////////////////////////////
+ // /////////////////////////////////////////////////
text = HTTPProxyHost.getText();
if ("".equals(text)) {
text = null;
@@ -369,24 +477,16 @@
if (proxyPort != -1) {
l.HTTPProxyPort = Integer.parseInt(text);
}
- //reset the port
- port.setText(null);
- /* but not, any more, the target port and host
- values
- host.setText(null);
- tport.setText(null);
- */
+ // reset the port
+ port.setText(null);
}
}
- }
- );
+ });
notebook.addTab(name, this);
notebook.repaint();
notebook.setSelectedIndex(notebook.getTabCount() - 1);
}
-
-
}
/**
@@ -394,20 +494,46 @@
* stuff comes in.
*/
class SocketWaiter extends Thread {
+ /**
+ * Field sSocket
+ */
ServerSocket sSocket = null;
+
+ /**
+ * Field listener
+ */
Listener listener;
+
+ /**
+ * Field port
+ */
int port;
+
+ /**
+ * Field pleaseStop
+ */
boolean pleaseStop = false;
+ /**
+ * Constructor SocketWaiter
+ *
+ * @param l
+ * @param p
+ */
public SocketWaiter(Listener l, int p) {
listener = l;
port = p;
start();
}
+ /**
+ * Method run
+ */
public void run() {
try {
- listener.setLeft(new JLabel(getMessage("wait00", " Waiting for Connection...")));
+ listener.setLeft(
+ new JLabel(
+ getMessage("wait00", " Waiting for Connection...")));
listener.repaint();
sSocket = new ServerSocket(port);
for (; ;) {
@@ -449,9 +575,24 @@
* class to simulate slow connections by slowing down the system
*/
static class SlowLinkSimulator {
+ /**
+ * Field delayBytes
+ */
private int delayBytes;
+
+ /**
+ * Field delayTime
+ */
private int delayTime;
+
+ /**
+ * Field currentBytes
+ */
private int currentBytes;
+
+ /**
+ * Field totalBytes
+ */
private int totalBytes;
/**
@@ -494,21 +635,25 @@
public void pump(int bytes) {
totalBytes += bytes;
if (delayBytes == 0) {
- //when not delaying, we are just a byte counter
+
+ // when not delaying, we are just a byte counter
return;
}
currentBytes += bytes;
if (currentBytes > delayBytes) {
- //we have overshot. lets find out how far
+
+ // we have overshot. lets find out how far
int delaysize = currentBytes / delayBytes;
long delay = delaysize * (long) delayTime;
- //move byte counter down to the remainder of bytes
+
+ // move byte counter down to the remainder of bytes
currentBytes = currentBytes % delayBytes;
- //now wait
+
+ // now wait
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
- ; //ignore the exception
+ ; // ignore the exception
}
}
}
@@ -530,7 +675,6 @@
public void setCurrentBytes(int currentBytes) {
this.currentBytes = currentBytes;
}
-
}
/**
@@ -538,23 +682,86 @@
* outgoing socket
*/
class SocketRR extends Thread {
+ /**
+ * Field inSocket
+ */
Socket inSocket = null;
+
+ /**
+ * Field outSocket
+ */
Socket outSocket = null;
+
+ /**
+ * Field textArea
+ */
JTextArea textArea;
+
+ /**
+ * Field in
+ */
InputStream in = null;
+
+ /**
+ * Field out
+ */
OutputStream out = null;
+
+ /**
+ * Field xmlFormat
+ */
boolean xmlFormat;
+
+ /**
+ * Field done
+ */
volatile boolean done = false;
+
+ /**
+ * Field tmodel
+ */
TableModel tmodel = null;
+
+ /**
+ * Field tableIndex
+ */
int tableIndex = 0;
+
+ /**
+ * Field type
+ */
String type = null;
+
+ /**
+ * Field myConnection
+ */
Connection myConnection = null;
+
+ /**
+ * Field slowLink
+ */
SlowLinkSimulator slowLink;
- public SocketRR(Connection c, Socket inputSocket, InputStream inputStream,
- Socket outputSocket, OutputStream outputStream,
- JTextArea _textArea, boolean format,
- TableModel tModel, int index, final String type, SlowLinkSimulator slowLink) {
+ /**
+ * Constructor SocketRR
+ *
+ * @param c
+ * @param inputSocket
+ * @param inputStream
+ * @param outputSocket
+ * @param outputStream
+ * @param _textArea
+ * @param format
+ * @param tModel
+ * @param index
+ * @param type
+ * @param slowLink
+ */
+ public SocketRR(Connection c, Socket inputSocket,
+ InputStream inputStream, Socket outputSocket,
+ OutputStream outputStream, JTextArea _textArea,
+ boolean format, TableModel tModel, int index,
+ final String type, SlowLinkSimulator slowLink) {
inSocket = inputSocket;
in = inputStream;
outSocket = outputSocket;
@@ -569,10 +776,18 @@
start();
}
+ /**
+ * Method isDone
+ *
+ * @return
+ */
public boolean isDone() {
return (done);
}
+ /**
+ * Method run
+ */
public void run() {
try {
byte[] buffer = new byte[4096];
@@ -584,13 +799,7 @@
int reqSaved = 0;
int tabWidth = 3;
boolean atMargin = true;
- int thisIndent = -1,
- nextIndent = -1,
- previousIndent = -1;
-
- //if ( inSocket != null ) inSocket.setSoTimeout( 10 );
- //if ( outSocket != null ) outSocket.setSoTimeout( 10 );
-
+ int thisIndent = -1, nextIndent = -1, previousIndent = -1;
if (tmodel != null) {
String tmpStr = (String) tmodel.getValueAt(tableIndex,
REQ_COLUMN);
@@ -603,10 +812,12 @@
if (done) {
break;
}
- //try{
- //len = in.available();
- //}catch(Exception e){len=0;}
+
+ // try{
+ // len = in.available();
+ // }catch(Exception e){len=0;}
len = buffer.length;
+
// Used to be 1, but if we block it doesn't matter
// however 1 will break with some servers, including apache
if (len == 0) {
@@ -620,7 +831,7 @@
try {
len1 = in.read(buffer, saved, len);
} catch (Exception ex) {
- if (done && saved == 0) {
+ if (done && (saved == 0)) {
break a;
}
len1 = -1;
@@ -628,7 +839,7 @@
}
}
len = len1;
- if (len == -1 && saved == 0) {
+ if ((len == -1) && (saved == 0)) {
break;
}
if (len == -1) {
@@ -638,11 +849,11 @@
// No matter how we may (or may not) format it, send it
// on unformatted - we don't want to mess with how its
// sent to the other side, just how its displayed
- if (out != null && len > 0) {
+ if ((out != null) && (len > 0)) {
slowLink.pump(len);
out.write(buffer, saved, len);
}
- if (tmodel != null && reqSaved < 50) {
+ if ((tmodel != null) && (reqSaved < 50)) {
String old = (String) tmodel.getValueAt(tableIndex,
REQ_COLUMN);
old = old + new String(buffer, saved, len);
@@ -657,6 +868,7 @@
tmodel.setValueAt(old, tableIndex, REQ_COLUMN);
}
if (xmlFormat) {
+
// Do XML Formatting
boolean inXML = false;
int bufferLen = saved;
@@ -667,25 +879,29 @@
i2 = 0;
saved = 0;
for (; i1 < bufferLen; i1++) {
+
// Except when we're at EOF, saved last char
- if (len != -1 && i1 + 1 == bufferLen) {
+ if ((len != -1) && (i1 + 1 == bufferLen)) {
saved = 1;
break;
}
thisIndent = -1;
- if (buffer[i1] == '<' && buffer[i1 + 1] != '/') {
+ if ((buffer[i1] == '<')
+ && (buffer[i1 + 1] != '/')) {
previousIndent = nextIndent++;
thisIndent = nextIndent;
inXML = true;
}
- if (buffer[i1] == '<' && buffer[i1 + 1] == '/') {
+ if ((buffer[i1] == '<')
+ && (buffer[i1 + 1] == '/')) {
if (previousIndent > nextIndent) {
thisIndent = nextIndent;
}
previousIndent = nextIndent--;
inXML = true;
}
- if (buffer[i1] == '/' && buffer[i1 + 1] == '>') {
+ if ((buffer[i1] == '/')
+ && (buffer[i1 + 1] == '>')) {
previousIndent = nextIndent--;
inXML = true;
}
@@ -697,7 +913,8 @@
tmpbuffer[i2++] = (byte) ' ';
}
}
- atMargin = (buffer[i1] == '\n' || buffer[i1] == '\r');
+ atMargin = ((buffer[i1] == '\n')
+ || (buffer[i1] == '\r'));
if (!inXML || !atMargin) {
tmpbuffer[i2++] = buffer[i1];
}
@@ -711,14 +928,7 @@
} else {
textArea.append(new String(buffer, 0, len));
}
- // this.sleep(3); // Let other threads have a chance to run
}
- // this.sleep(3); // Let other threads have a chance to run
- // halt();
- // Only set the 'done' flag if we were reading from a
- // Socket - if we were reading from an input stream then
- // we'll let the other side control when we're done
- // if ( inSocket != null ) done = true ;
} catch (Exception e) {
e.printStackTrace();
} finally {
@@ -734,7 +944,6 @@
out = null;
}
} catch (Exception e) {
- ;
}
try {
if (in != null) {
@@ -746,12 +955,14 @@
in = null;
}
} catch (Exception e) {
- ;
}
myConnection.wakeUp();
}
}
+ /**
+ * Method halt
+ */
public void halt() {
try {
if (inSocket != null) {
@@ -781,26 +992,101 @@
* a connection listens to a single current connection
*/
class Connection extends Thread {
+ /**
+ * Field listener
+ */
Listener listener;
+
+ /**
+ * Field active
+ */
boolean active;
+
+ /**
+ * Field fromHost
+ */
String fromHost;
+
+ /**
+ * Field time
+ */
String time;
+
+ /**
+ * Field inputText
+ */
JTextArea inputText = null;
+
+ /**
+ * Field inputScroll
+ */
JScrollPane inputScroll = null;
+
+ /**
+ * Field outputText
+ */
JTextArea outputText = null;
+
+ /**
+ * Field outputScroll
+ */
JScrollPane outputScroll = null;
+
+ /**
+ * Field inSocket
+ */
Socket inSocket = null;
+
+ /**
+ * Field outSocket
+ */
Socket outSocket = null;
+
+ /**
+ * Field clientThread
+ */
Thread clientThread = null;
+
+ /**
+ * Field serverThread
+ */
Thread serverThread = null;
+
+ /**
+ * Field rr1
+ */
SocketRR rr1 = null;
+
+ /**
+ * Field rr2
+ */
SocketRR rr2 = null;
+
+ /**
+ * Field inputStream
+ */
InputStream inputStream = null;
+ /**
+ * Field HTTPProxyHost
+ */
String HTTPProxyHost = null;
+
+ /**
+ * Field HTTPProxyPort
+ */
int HTTPProxyPort = 80;
+
+ /**
+ * Field slowLink
+ */
private SlowLinkSimulator slowLink;
+ /**
+ * Constructor Connection
+ *
+ * @param l
+ */
public Connection(Listener l) {
listener = l;
HTTPProxyHost = l.HTTPProxyHost;
@@ -808,28 +1094,43 @@
slowLink = l.slowLink;
}
+ /**
+ * Constructor Connection
+ *
+ * @param l
+ * @param s
+ */
public Connection(Listener l, Socket s) {
this(l);
inSocket = s;
start();
}
+ /**
+ * Constructor Connection
+ *
+ * @param l
+ * @param in
+ */
public Connection(Listener l, InputStream in) {
this(l);
inputStream = in;
start();
}
+ /**
+ * Method run
+ */
public void run() {
try {
active = true;
HTTPProxyHost = System.getProperty("http.proxyHost");
- if (HTTPProxyHost != null && HTTPProxyHost.equals("")) {
+ if ((HTTPProxyHost != null) && HTTPProxyHost.equals("")) {
HTTPProxyHost = null;
}
if (HTTPProxyHost != null) {
String tmp = System.getProperty("http.proxyPort");
- if (tmp != null && tmp.equals("")) {
+ if ((tmp != null) && tmp.equals("")) {
tmp = null;
}
if (tmp == null) {
@@ -843,24 +1144,27 @@
} else {
fromHost = "resend";
}
- String dateformat = getMessage("dateformat00", "yyyy-MM-dd HH:mm:ss");
+ String dateformat = getMessage("dateformat00",
+ "yyyy-MM-dd HH:mm:ss");
DateFormat df = new SimpleDateFormat(dateformat);
time = df.format(new Date());
int count = listener.connections.size();
- listener.tableModel.insertRow(count + 1, new Object[]{
- getMessage("active00", "Active"),
+ listener.tableModel.insertRow(count + 1,
+ new Object[]{
+ getMessage("active00",
+ "Active"),
time,
fromHost,
- listener.hostField.getText(), ""
- }
- );
+ listener.hostField.getText(),
+ ""});
listener.connections.add(this);
inputText = new JTextArea(null, null, 20, 80);
inputScroll = new JScrollPane(inputText);
outputText = new JTextArea(null, null, 20, 80);
outputScroll = new JScrollPane(outputText);
- ListSelectionModel lsm = listener.connectionTable.getSelectionModel();
- if (count == 0 || lsm.getLeadSelectionIndex() == 0) {
+ ListSelectionModel lsm =
+ listener.connectionTable.getSelectionModel();
+ if ((count == 0) || (lsm.getLeadSelectionIndex() == 0)) {
listener.outPane.setVisible(false);
int divLoc = listener.outPane.getDividerLocation();
listener.setLeft(inputScroll);
@@ -873,8 +1177,10 @@
listener.outPane.setVisible(true);
}
String targetHost = listener.hostField.getText();
- int targetPort = Integer.parseInt(listener.tPortField.getText());
- int listenPort = Integer.parseInt(listener.portField.getText());
+ int targetPort =
+ Integer.parseInt(listener.tPortField.getText());
+ int listenPort =
+ Integer.parseInt(listener.portField.getText());
InputStream tmpIn1 = inputStream;
OutputStream tmpOut1 = null;
InputStream tmpIn2 = null;
@@ -888,7 +1194,9 @@
String bufferedData = null;
StringBuffer buf = null;
int index = listener.connections.indexOf(this);
- if (listener.isProxyBox.isSelected() || HTTPProxyHost != null) {
+ if (listener.isProxyBox.isSelected()
+ || (HTTPProxyHost != null)) {
+
// Check if we're a proxy
byte[] b = new byte[1];
buf = new StringBuffer();
@@ -908,10 +1216,10 @@
}
bufferedData = buf.toString();
inputText.append(bufferedData);
- if (bufferedData.startsWith("GET ") ||
- bufferedData.startsWith("POST ") ||
- bufferedData.startsWith("PUT ") ||
- bufferedData.startsWith("DELETE ")) {
+ if (bufferedData.startsWith("GET ")
+ || bufferedData.startsWith("POST ")
+ || bufferedData.startsWith("PUT ")
+ || bufferedData.startsWith("DELETE ")) {
int start, end;
URL url;
start = bufferedData.indexOf(' ') + 1;
@@ -930,28 +1238,30 @@
if (targetPort == -1) {
targetPort = 80;
}
- listener.tableModel.setValueAt(targetHost, index + 1,
+ listener.tableModel.setValueAt(targetHost,
+ index + 1,
OUTHOST_COLUMN);
- bufferedData = bufferedData.substring(0, start) +
- url.getFile() +
- bufferedData.substring(end);
+ bufferedData = bufferedData.substring(0, start)
+ + url.getFile()
+ + bufferedData.substring(end);
} else {
- url = new URL("http://" + targetHost + ":" +
- targetPort + "/" + urlString);
- listener.tableModel.setValueAt(targetHost, index + 1,
+ url = new URL("http://" + targetHost + ":"
+ + targetPort + "/" + urlString);
+ listener.tableModel.setValueAt(targetHost,
+ index + 1,
OUTHOST_COLUMN);
- bufferedData = bufferedData.substring(0, start) +
- url.toExternalForm() +
- bufferedData.substring(end);
+ bufferedData = bufferedData.substring(0, start)
+ + url.toExternalForm()
+ + bufferedData.substring(end);
targetHost = HTTPProxyHost;
targetPort = HTTPProxyPort;
}
-
}
} else {
- //
+
+ //
// Change Host: header to point to correct host
- //
+ //
byte[] b1 = new byte[1];
buf = new StringBuffer();
String s1;
@@ -967,16 +1277,21 @@
if (b1[0] != '\n') {
continue;
}
+
// we have a complete line
String line = buf.toString();
buf.setLength(0);
+
// check to see if we have found Host: header
if (line.startsWith("Host: ")) {
+
// we need to update the hostname to target host
- String newHost = "Host: " + targetHost + ":" + listenPort + "\r\n";
+ String newHost = "Host: " + targetHost + ":"
+ + listenPort + "\r\n";
bufferedData = bufferedData.concat(newHost);
break;
}
+
// add it to our headers so far
if (bufferedData == null) {
bufferedData = line;
@@ -995,14 +1310,16 @@
}
if (bufferedData != null) {
inputText.append(bufferedData);
- int idx = bufferedData.length() < 50 ? bufferedData.length() : 50;
+ int idx = (bufferedData.length() < 50)
+ ? bufferedData.length()
+ : 50;
s1 = bufferedData.substring(0, idx);
int i = s1.indexOf('\n');
if (i > 0) {
s1 = s1.substring(0, i - 1);
}
- s1 = s1 + " " +
- " ";
+ s1 = s1 + " "
+ + " ";
s1 = s1.substring(0, 51);
listener.tableModel.setValueAt(s1, index + 1,
REQ_COLUMN);
@@ -1021,88 +1338,99 @@
}
boolean format = listener.xmlFormatBox.isSelected();
+ // this is the channel to the endpoint
+ rr1 = new SocketRR(this, inSocket, tmpIn1, outSocket, tmpOut2,
+ inputText, format, listener.tableModel,
+ index + 1, "request:", slowLink);
+
+ // create the response slow link from the inbound slow link
+ SlowLinkSimulator responseLink =
+ new SlowLinkSimulator(slowLink);
+
+ // this is the channel from the endpoint
+ rr2 = new SocketRR(this, outSocket, tmpIn2, inSocket, tmpOut1,
+ outputText, format, null, 0, "response:",
+ responseLink);
+ while ((rr1 != null) || (rr2 != null)) {
- //this is the channel to the endpoint
- rr1 = new SocketRR(this, inSocket, tmpIn1, outSocket,
- tmpOut2, inputText, format,
- listener.tableModel, index + 1, "request:", slowLink);
- //create the response slow link from the inbound slow link
- SlowLinkSimulator responseLink = new SlowLinkSimulator(slowLink);
- //this is the channel from the endpoint
- rr2 = new SocketRR(this, outSocket, tmpIn2, inSocket,
- tmpOut1, outputText, format,
- null, 0, "response:", responseLink);
- while (rr1 != null || rr2 != null) {
// Only loop as long as the connection to the target
// machine is available - once that's gone we can stop.
// The old way, loop until both are closed, left us
// looping forever since no one closed the 1st one.
// while( !rr2.isDone() )
- if (null != rr1 && rr1.isDone()) {
- if (index >= 0 && rr2 != null) {
- listener.tableModel.setValueAt(getMessage("resp00", "Resp"),
- 1 + index, STATE_COLUMN);
+ if ((null != rr1) && rr1.isDone()) {
+ if ((index >= 0) && (rr2 != null)) {
+ listener.tableModel.setValueAt(
+ getMessage("resp00", "Resp"), 1 + index,
+ STATE_COLUMN);
}
rr1 = null;
}
- if (null != rr2 && rr2.isDone()) {
- if (index >= 0 && rr1 != null) {
- listener.tableModel.setValueAt(getMessage("req00", "Req"),
- 1 + index, STATE_COLUMN);
+ if ((null != rr2) && rr2.isDone()) {
+ if ((index >= 0) && (rr1 != null)) {
+ listener.tableModel.setValueAt(
+ getMessage("req00", "Req"), 1 + index,
+ STATE_COLUMN);
}
rr2 = null;
}
- // Thread.sleep( 10 );
+ // Thread.sleep( 10 );
synchronized (this) {
- this.wait(1000); //Safety just incase we're not told to wake up.
+ this.wait(
+ 1000); // Safety just incase we're not told to wake up.
}
}
- // System.out.println("Done ");
+ // System.out.println("Done ");
// rr1.halt();
// rr2.halt();
-
-
active = false;
/*
- if ( inSocket != null ) {
- inSocket.close();
- inSocket = null ;
- }
- outSocket.close();
- outSocket = null ;
+ * if ( inSocket != null ) {
+ * inSocket.close();
+ * inSocket = null ;
+ * }
+ * outSocket.close();
+ * outSocket = null ;
*/
-
if (index >= 0) {
listener.tableModel.setValueAt(getMessage("done00", "Done"),
1 + index, STATE_COLUMN);
-
}
} catch (Exception e) {
StringWriter st = new StringWriter();
PrintWriter wr = new PrintWriter(st);
int index = listener.connections.indexOf(this);
if (index >= 0) {
- listener.tableModel.setValueAt(getMessage("error00", "Error"), 1 + index, STATE_COLUMN);
+ listener.tableModel.setValueAt(
+ getMessage("error00", "Error"), 1 + index,
+ STATE_COLUMN);
}
e.printStackTrace(wr);
wr.close();
if (outputText != null) {
outputText.append(st.toString());
} else {
- //something went wrong before we had the output area
+
+ // something went wrong before we had the output area
System.out.println(st.toString());
}
halt();
}
}
+ /**
+ * Method wakeUp
+ */
synchronized void wakeUp() {
this.notifyAll();
}
+ /**
+ * Method halt
+ */
public void halt() {
try {
if (rr1 != null) {
@@ -1124,6 +1452,9 @@
}
}
+ /**
+ * Method remove
+ */
public void remove() {
int index = -1;
try {
@@ -1142,34 +1473,144 @@
* this is one of the tabbed panels that acts as the actual proxy
*/
class Listener extends JPanel {
+ /**
+ * Field inputSocket
+ */
public Socket inputSocket = null;
+
+ /**
+ * Field outputSocket
+ */
public Socket outputSocket = null;
+
+ /**
+ * Field portField
+ */
public JTextField portField = null;
+
+ /**
+ * Field hostField
+ */
public JTextField hostField = null;
+
+ /**
+ * Field tPortField
+ */
public JTextField tPortField = null;
+
+ /**
+ * Field isProxyBox
+ */
public JCheckBox isProxyBox = null;
+
+ /**
+ * Field stopButton
+ */
public JButton stopButton = null;
+
+ /**
+ * Field removeButton
+ */
public JButton removeButton = null;
+
+ /**
+ * Field removeAllButton
+ */
public JButton removeAllButton = null;
+
+ /**
+ * Field xmlFormatBox
+ */
public JCheckBox xmlFormatBox = null;
+
+ /**
+ * Field saveButton
+ */
public JButton saveButton = null;
+
+ /**
+ * Field resendButton
+ */
public JButton resendButton = null;
+
+ /**
+ * Field switchButton
+ */
public JButton switchButton = null;
+
+ /**
+ * Field closeButton
+ */
public JButton closeButton = null;
+
+ /**
+ * Field connectionTable
+ */
public JTable connectionTable = null;
+
+ /**
+ * Field tableModel
+ */
public DefaultTableModel tableModel = null;
+
+ /**
+ * Field outPane
+ */
public JSplitPane outPane = null;
+
+ /**
+ * Field sSocket
+ */
public ServerSocket sSocket = null;
+
+ /**
+ * Field sw
+ */
public SocketWaiter sw = null;
+
+ /**
+ * Field leftPanel
+ */
public JPanel leftPanel = null;
+
+ /**
+ * Field rightPanel
+ */
public JPanel rightPanel = null;
+
+ /**
+ * Field notebook
+ */
public JTabbedPane notebook = null;
+
+ /**
+ * Field HTTPProxyHost
+ */
public String HTTPProxyHost = null;
+
+ /**
+ * Field HTTPProxyPort
+ */
public int HTTPProxyPort = 80;
+
+ /**
+ * Field delayBytes
+ */
public int delayBytes = 0;
+
+ /**
+ * Field delayTime
+ */
public int delayTime = 0;
+
+ /**
+ * Field slowLink
+ */
public SlowLinkSimulator slowLink;
+ /**
+ * Field connections
+ */
public final Vector connections = new Vector();
/**
@@ -1183,35 +1624,41 @@
* @param isProxy
* @param slowLink optional reference to a slow connection
*/
- public Listener(JTabbedPane _notebook, String name,
- int listenPort, String host, int targetPort,
- boolean isProxy, SlowLinkSimulator slowLink) {
+ public Listener(JTabbedPane _notebook, String name, int listenPort,
+ String host, int targetPort, boolean isProxy,
+ SlowLinkSimulator slowLink) {
notebook = _notebook;
if (name == null) {
name = getMessage("port01", "Port") + " " + listenPort;
}
- //set the slow link to the passed down link
+
+ // set the slow link to the passed down link
if (slowLink != null) {
this.slowLink = slowLink;
} else {
- //or make up a no-op one.
+
+ // or make up a no-op one.
this.slowLink = new SlowLinkSimulator(0, 0);
}
this.setLayout(new BorderLayout());
// 1st component is just a row of labels and 1-line entry fields
- /////////////////////////////////////////////////////////////////////
+ // ///////////////////////////////////////////////////////////////////
JPanel top = new JPanel();
top.setLayout(new BoxLayout(top, BoxLayout.X_AXIS));
top.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
final String start = getMessage("start00", "Start");
top.add(stopButton = new JButton(start));
top.add(Box.createRigidArea(new Dimension(5, 0)));
- top.add(new JLabel(" " + getMessage("listenPort01", "Listen Port:") + " ", SwingConstants.RIGHT));
+ top.add(new JLabel(" "
+ + getMessage("listenPort01", "Listen Port:")
+ + " ", SwingConstants.RIGHT));
top.add(portField = new JTextField("" + listenPort, 4));
- top.add(new JLabel(" " + getMessage("host00", "Host:"), SwingConstants.RIGHT));
+ top.add(new JLabel(" " + getMessage("host00", "Host:"),
+ SwingConstants.RIGHT));
top.add(hostField = new JTextField(host, 30));
- top.add(new JLabel(" " + getMessage("port02", "Port:") + " ", SwingConstants.RIGHT));
+ top.add(new JLabel(" " + getMessage("port02", "Port:") + " ",
+ SwingConstants.RIGHT));
top.add(tPortField = new JTextField("" + targetPort, 4));
top.add(Box.createRigidArea(new Dimension(5, 0)));
top.add(isProxyBox = new JCheckBox(getMessage("proxy00", "Proxy")));
@@ -1222,8 +1669,7 @@
tPortField.setEnabled(!state);
hostField.setEnabled(!state);
}
- }
- );
+ });
isProxyBox.setSelected(isProxy);
portField.setEditable(false);
portField.setMaximumSize(new Dimension(50, Short.MAX_VALUE));
@@ -1233,35 +1679,35 @@
tPortField.setMaximumSize(new Dimension(50, Short.MAX_VALUE));
stopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
- if (getMessage("stop00", "Stop").equals(event.getActionCommand())) {
+ if (getMessage("stop00",
+ "Stop").equals(event.getActionCommand())) {
stop();
}
if (start.equals(event.getActionCommand())) {
start();
}
}
- }
- );
+ });
this.add(top, BorderLayout.NORTH);
// 2nd component is a split pane with a table on the top
// and the request/response text areas on the bottom
- /////////////////////////////////////////////////////////////////////
-
+ // ///////////////////////////////////////////////////////////////////
tableModel = new DefaultTableModel(new String[]{
getMessage("state00", "State"),
getMessage("time00", "Time"),
getMessage("requestHost00", "Request Host"),
getMessage("targetHost", "Target Host"),
- getMessage("request00", "Request...")
- }, 0);
- tableModel.addRow(new Object[]{
- "---", getMessage("mostRecent00", "Most Recent"), "---", "---", "---"
- }
- );
+ getMessage("request00", "Request...")}, 0);
+ tableModel.addRow(new Object[]{"---",
+ getMessage("mostRecent00",
+ "Most Recent"),
+ "---", "---", "---"});
connectionTable = new JTable(1, 2);
connectionTable.setModel(tableModel);
- connectionTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ connectionTable.setSelectionMode(
+ ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
// Reduce the STATE column and increase the REQ column
TableColumn col;
col = connectionTable.getColumnModel().getColumn(STATE_COLUMN);
@@ -1274,10 +1720,15 @@
if (event.getValueIsAdjusting()) {
return;
}
- ListSelectionModel m = (ListSelectionModel) event.getSource();
+ ListSelectionModel m =
+ (ListSelectionModel) event.getSource();
int divLoc = outPane.getDividerLocation();
if (m.isSelectionEmpty()) {
- setLeft(new JLabel(" " + getMessage("wait00", "Waiting for Connection...")));
+ setLeft(
+ new JLabel(
+ " "
+ + getMessage(
+ "wait00", "Waiting for Connection...")));
setRight(new JLabel(""));
removeButton.setEnabled(false);
removeAllButton.setEnabled(false);
@@ -1287,14 +1738,20 @@
int row = m.getLeadSelectionIndex();
if (row == 0) {
if (connections.size() == 0) {
- setLeft(new JLabel(" " + getMessage("wait00", "Waiting for connection...")));
+ setLeft(
+ new JLabel(
+ " "
+ + getMessage(
+ "wait00",
+ "Waiting for connection...")));
setRight(new JLabel(""));
removeButton.setEnabled(false);
removeAllButton.setEnabled(false);
saveButton.setEnabled(false);
resendButton.setEnabled(false);
} else {
- Connection conn = (Connection) connections.lastElement();
+ Connection conn =
+ (Connection) connections.lastElement();
setLeft(conn.inputScroll);
setRight(conn.outputScroll);
removeButton.setEnabled(false);
@@ -1303,7 +1760,8 @@
resendButton.setEnabled(true);
}
} else {
- Connection conn = (Connection) connections.get(row - 1);
+ Connection conn = (Connection) connections.get(row
+ - 1);
setLeft(conn.inputScroll);
setRight(conn.outputScroll);
removeButton.setEnabled(true);
@@ -1314,8 +1772,7 @@
}
outPane.setDividerLocation(divLoc);
}
- }
- );
+ });
JPanel tablePane = new JPanel();
tablePane.setLayout(new BorderLayout());
JScrollPane tableScrollPane = new JScrollPane(connectionTable);
@@ -1323,7 +1780,8 @@
JPanel buttons = new JPanel();
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
buttons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- final String removeSelected = getMessage("removeSelected00", "Remove Selected");
+ final String removeSelected = getMessage("removeSelected00",
+ "Remove Selected");
buttons.add(removeButton = new JButton(removeSelected));
buttons.add(Box.createRigidArea(new Dimension(5, 0)));
final String removeAll = getMessage("removeAll00", "Remove All");
@@ -1336,8 +1794,7 @@
remove();
}
}
- }
- );
+ });
removeAllButton.setEnabled(false);
removeAllButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
@@ -1345,29 +1802,35 @@
removeAll();
}
}
- }
- );
+ });
// Add Response Section
- /////////////////////////////////////////////////////////////////////
+ // ///////////////////////////////////////////////////////////////////
JPanel pane2 = new JPanel();
pane2.setLayout(new BorderLayout());
leftPanel = new JPanel();
leftPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));
- leftPanel.add(new JLabel(" " + getMessage("request01", "Request")));
- leftPanel.add(new JLabel(" " + getMessage("wait01", "Waiting for connection")));
+ leftPanel.add(new JLabel(" "
+ + getMessage("request01", "Request")));
+ leftPanel.add(new JLabel(" "
+ + getMessage("wait01",
+ "Waiting for connection")));
rightPanel = new JPanel();
rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));
- rightPanel.add(new JLabel(" " + getMessage("response00", "Response")));
+ rightPanel.add(new JLabel(" "
+ + getMessage("response00", "Response")));
rightPanel.add(new JLabel(""));
outPane = new JSplitPane(0, leftPanel, rightPanel);
outPane.setDividerSize(4);
pane2.add(outPane, BorderLayout.CENTER);
JPanel bottomButtons = new JPanel();
- bottomButtons.setLayout(new BoxLayout(bottomButtons, BoxLayout.X_AXIS));
- bottomButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- bottomButtons.add(xmlFormatBox = new JCheckBox(getMessage("xmlFormat00", "XML Format")));
+ bottomButtons.setLayout(new BoxLayout(bottomButtons,
+ BoxLayout.X_AXIS));
+ bottomButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5,
+ 5));
+ bottomButtons.add(xmlFormatBox =
+ new JCheckBox(getMessage("xmlFormat00", "XML Format")));
bottomButtons.add(Box.createRigidArea(new Dimension(5, 0)));
final String save = getMessage("save00", "Save");
bottomButtons.add(saveButton = new JButton(save));
@@ -1388,8 +1851,7 @@
save();
}
}
- }
- );
+ });
resendButton.setEnabled(false);
resendButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
@@ -1397,32 +1859,31 @@
resend();
}
}
- }
- );
+ });
switchButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (switchStr.equals(event.getActionCommand())) {
int v = outPane.getOrientation();
if (v == 0) {
+
// top/bottom
outPane.setOrientation(1);
} else {
+
// left/right
outPane.setOrientation(0);
}
outPane.setDividerLocation(0.5);
}
}
- }
- );
+ });
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (close.equals(event.getActionCommand())) {
close();
}
}
- }
- );
+ });
JSplitPane pane1 = new JSplitPane(0);
pane1.setDividerSize(4);
pane1.setTopComponent(tablePane);
@@ -1430,24 +1891,37 @@
pane1.setDividerLocation(150);
this.add(pane1, BorderLayout.CENTER);
- //
- ////////////////////////////////////////////////////////////////////
+ //
+ // //////////////////////////////////////////////////////////////////
sel.setSelectionInterval(0, 0);
outPane.setDividerLocation(150);
notebook.addTab(name, this);
start();
}
+ /**
+ * Method setLeft
+ *
+ * @param left
+ */
public void setLeft(Component left) {
leftPanel.removeAll();
leftPanel.add(left);
}
+ /**
+ * Method setRight
+ *
+ * @param right
+ */
public void setRight(Component right) {
rightPanel.removeAll();
rightPanel.add(right);
}
+ /**
+ * Method start
+ */
public void start() {
int port = Integer.parseInt(portField.getText());
portField.setText("" + port);
@@ -1463,11 +1937,17 @@
isProxyBox.setEnabled(false);
}
+ /**
+ * Method close
+ */
public void close() {
stop();
notebook.remove(this);
}
+ /**
+ * Method stop
+ */
public void stop() {
try {
for (int i = 0; i < connections.size(); i++) {
@@ -1485,6 +1965,9 @@
}
}
+ /**
+ * Method remove
+ */
public void remove() {
ListSelectionModel lsm = connectionTable.getSelectionModel();
int bot = lsm.getMinSelectionIndex();
@@ -1498,6 +1981,9 @@
lsm.setSelectionInterval(bot, bot);
}
+ /**
+ * Method removeAll
+ */
public void removeAll() {
ListSelectionModel lsm = connectionTable.getSelectionModel();
lsm.clearSelection();
@@ -1507,6 +1993,9 @@
lsm.setSelectionInterval(0, 0);
}
+ /**
+ * Method save
+ */
public void save() {
JFileChooser dialog = new JFileChooser(".");
int rc = dialog.showSaveDialog(this);
@@ -1514,23 +2003,36 @@
try {
File file = dialog.getSelectedFile();
FileOutputStream out = new FileOutputStream(file);
- ListSelectionModel lsm = connectionTable.getSelectionModel();
+ ListSelectionModel lsm =
+ connectionTable.getSelectionModel();
rc = lsm.getLeadSelectionIndex();
int n = 0;
- for (Iterator i = connections.iterator(); i.hasNext(); n++) {
+ for (Iterator i = connections.iterator(); i.hasNext();
+ n++) {
Connection conn = (Connection) i.next();
- if (lsm.isSelectedIndex(n + 1) ||
- (!(i.hasNext()) && lsm.getLeadSelectionIndex() == 0)) {
+ if (lsm.isSelectedIndex(n + 1)
+ || (!(i.hasNext())
+ && (lsm.getLeadSelectionIndex() == 0))) {
rc = Integer.parseInt(portField.getText());
out.write("\n==============\n".getBytes());
- out.write(((getMessage("listenPort01", "Listen Port:") + " " + rc + "\n")).getBytes());
- out.write((getMessage("targetHost01", "Target Host:") + " " + hostField.getText() +
- "\n").getBytes());
+ out.write(
+ ((getMessage("listenPort01", "Listen Port:")
+ + " " + rc + "\n")).getBytes());
+ out.write(
+ (getMessage("targetHost01", "Target Host:")
+ + " " + hostField.getText()
+ + "\n").getBytes());
rc = Integer.parseInt(tPortField.getText());
- out.write(((getMessage("targetPort01", "Target Port:") + " " + rc + "\n")).getBytes());
- out.write((("==== " + getMessage("request01", "Request") + " ====\n")).getBytes());
+ out.write(
+ ((getMessage("targetPort01", "Target Port:")
+ + " " + rc + "\n")).getBytes());
+ out.write((("==== "
+ + getMessage("request01", "Request")
+ + " ====\n")).getBytes());
out.write(conn.inputText.getText().getBytes());
- out.write((("==== " + getMessage("response00", "Response") + " ====\n")).getBytes());
+ out.write((("==== "
+ + getMessage("response00", "Response")
+ + " ====\n")).getBytes());
out.write(conn.outputText.getText().getBytes());
out.write("\n==============\n".getBytes());
}
@@ -1542,6 +2044,9 @@
}
}
+ /**
+ * Method resend
+ */
public void resend() {
int rc;
try {
@@ -1560,6 +2065,7 @@
// Fix Content-Length HTTP headers
if (text.startsWith("POST ") || text.startsWith("GET ")) {
+
// System.err.println("IN CL" );
int pos1, pos2, pos3;
String headers;
@@ -1574,6 +2080,7 @@
}
headers = text.substring(0, pos3);
pos1 = headers.indexOf("Content-Length:");
+
// System.err.println("pos1: " + pos1 );
// System.err.println("pos3: " + pos3 );
if (pos1 != -1) {
@@ -1581,12 +2088,12 @@
pos2 = headers.indexOf("\n", pos1);
System.err.println("CL: " + newLen);
System.err.println("Hdrs: '" + headers + "'");
- System.err.println("subTEXT: '" +
- text.substring(pos3, pos3 + newLen) + "'");
- text = headers.substring(0, pos1) +
- "Content-Length: " + newLen + "\n" +
- headers.substring(pos2 + 1) +
- text.substring(pos3);
+ System.err.println("subTEXT: '"
+ + text.substring(pos3, pos3 + newLen)
+ + "'");
+ text = headers.substring(0, pos1) + "Content-Length: "
+ + newLen + "\n" + headers.substring(pos2 + 1)
+ + text.substring(pos3);
System.err.println("\nTEXT: '" + text + "'");
}
}
@@ -1598,7 +2105,16 @@
}
}
- public tcpmon(int listenPort, String targetHost, int targetPort, boolean embedded) {
+ /**
+ * Constructor tcpmon
+ *
+ * @param listenPort
+ * @param targetHost
+ * @param targetPort
+ * @param embedded
+ */
+ public tcpmon(int listenPort, String targetHost, int targetPort,
+ boolean embedded) {
super(getMessage("tcpmon00", "TCPMonitor"));
notebook = new JTabbedPane();
this.getContentPane().add(notebook);
@@ -1606,20 +2122,20 @@
if (listenPort != 0) {
Listener l = null;
if (targetHost == null) {
- l = new Listener(notebook, null, listenPort,
- targetHost, targetPort, true, null);
+ l = new Listener(notebook, null, listenPort, targetHost,
+ targetPort, true, null);
} else {
- l = new Listener(notebook, null, listenPort,
- targetHost, targetPort, false, null);
+ 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("")) {
+ 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("")) {
+ if ((tmp != null) && tmp.equals("")) {
tmp = null;
}
if (tmp == null) {
@@ -1637,14 +2153,25 @@
this.setVisible(true);
}
+ /**
+ * Constructor tcpmon
+ *
+ * @param listenPort
+ * @param targetHost
+ * @param targetPort
+ */
public tcpmon(int listenPort, String targetHost, int targetPort) {
this(listenPort, targetHost, targetPort, false);
}
/**
* set up the L&F
+ *
+ * @param nativeLookAndFeel
+ * @throws Exception
*/
- private static void setupLookAndFeel(boolean nativeLookAndFeel) throws Exception {
+ private static void setupLookAndFeel(boolean nativeLookAndFeel)
+ throws Exception {
String classname = UIManager.getCrossPlatformLookAndFeelClassName();
if (nativeLookAndFeel) {
classname = UIManager.getSystemLookAndFeelClassName();
@@ -1673,7 +2200,8 @@
*/
public static void main(String[] args) {
try {
- //switch between swing L&F here
+
+ // switch between swing L&F here
setupLookAndFeel(true);
if (args.length == 3) {
int p1 = Integer.parseInt(args[0]);
@@ -1683,7 +2211,8 @@
int p1 = Integer.parseInt(args[0]);
new tcpmon(p1, null, 0);
} else if (args.length != 0) {
- System.err.println(getMessage("usage00", "Usage:")
+ System.err.println(
+ getMessage("usage00", "Usage:")
+ " tcpmon [listenPort targetHost targetPort]\n");
} else {
new tcpmon(0, null, 0);
@@ -1693,11 +2222,17 @@
}
}
- // Message resource bundle.
+ /**
+ * Field messages
+ */
private static ResourceBundle messages = null;
/**
* Get the message with the given key. There are no arguments for this message.
+ *
+ * @param key
+ * @param defaultMsg
+ * @return
*/
public static String getMessage(String key, String defaultMsg) {
try {
@@ -1706,11 +2241,12 @@
}
return messages.getString(key);
} catch (Throwable t) {
+
// If there is any problem whatsoever getting the internationalized
// message, return the default.
return defaultMsg;
}
- } // getMessage
+ }
/**
* Load the resource bundle messages from the properties file. This is ONLY done when it is
@@ -1719,33 +2255,65 @@
*/
private static void initializeMessages() {
messages = ResourceBundle.getBundle("org.apache.axis.utils.tcpmon");
- } // initializeMessages
+ }
/**
* a text field with a restricted set of characters
*/
static class RestrictedTextField extends JTextField {
+ /**
+ * Field validText
+ */
protected String validText;
+ /**
+ * Constructor RestrictedTextField
+ *
+ * @param validText
+ */
public RestrictedTextField(String validText) {
setValidText(validText);
}
+ /**
+ * Constructor RestrictedTextField
+ *
+ * @param columns
+ * @param validText
+ */
public RestrictedTextField(int columns, String validText) {
super(columns);
setValidText(validText);
}
+ /**
+ * Constructor RestrictedTextField
+ *
+ * @param text
+ * @param validText
+ */
public RestrictedTextField(String text, String validText) {
super(text);
setValidText(validText);
}
+ /**
+ * Constructor RestrictedTextField
+ *
+ * @param text
+ * @param columns
+ * @param validText
+ */
public RestrictedTextField(String text, int columns, String validText) {
super(text, columns);
setValidText(validText);
}
+ /**
+ * Method setValidText
+ *
+ * @param validText
+ */
private void setValidText(String validText) {
this.validText = validText;
}
@@ -1770,7 +2338,6 @@
* <code>GapContent</code> is constructed and set.
*/
public RestrictedDocument() {
-
}
/**
@@ -1781,7 +2348,8 @@
* @param attributes
* @throws BadLocationException
*/
- public void insertString(int offset, String string, AttributeSet attributes)
+ public void insertString(
+ int offset, String string, AttributeSet attributes)
throws BadLocationException {
if (string == null) {
return;
@@ -1796,7 +2364,7 @@
}
super.insertString(offset, new String(buffer), attributes);
}
- } //end class NumericDocument
+ } // end class NumericDocument
}
/**
@@ -1804,6 +2372,9 @@
* a class that accepts numbers only
*/
static class NumberField extends RestrictedTextField {
+ /**
+ * Field VALID_TEXT
+ */
private static final String VALID_TEXT = "0123456789";
/**
@@ -1840,11 +2411,10 @@
public int getValue(int def) {
int result = def;
String text = getText();
- if (text != null && text.length() != 0) {
+ if ((text != null) && (text.length() != 0)) {
try {
result = Integer.parseInt(text);
} catch (NumberFormatException e) {
-
}
}
return result;
@@ -1858,24 +2428,35 @@
public void setValue(int value) {
setText(Integer.toString(value));
}
-
- } //end class NumericTextField
+ } // end class NumericTextField
/**
* hostname fields
*/
static class HostnameField extends RestrictedTextField {
- //list of valid chars in a hostname
+
+ // list of valid chars in a hostname
+
+ /**
+ * Field VALID_TEXT
+ */
private static final String VALID_TEXT =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYZ-.";
+ /**
+ * Constructor HostnameField
+ *
+ * @param columns
+ */
public HostnameField(int columns) {
super(columns, VALID_TEXT);
}
+ /**
+ * Constructor HostnameField
+ */
public HostnameField() {
super(VALID_TEXT);
}
}
-
}
Modified: webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service1/org/apache/axis/sample/echo/EchoProvider.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service1/org/apache/axis/sample/echo/EchoProvider.java?view=diff&r1=154536&r2=154537
==============================================================================
--- webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service1/org/apache/axis/sample/echo/EchoProvider.java (original)
+++ webservices/axis/trunk/java/modules/deployment/src/samples/deployment/service1/org/apache/axis/sample/echo/EchoProvider.java Sun Feb 20 09:56:49 2005
@@ -42,7 +42,6 @@
MessageContext msgContext,
Method method)
throws AxisFault {
- // org.TimeRecorder.BEFORE_DESERALIZE = System.currentTimeMillis();
XMLStreamReader xpp =
msgContext.getSoapOperationElement().getPullParser(true);
Class[] parms = method.getParameterTypes();
Modified: webservices/axis/trunk/java/modules/samples/src/java/encoding/sample1/EchoProvider.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/encoding/sample1/EchoProvider.java?view=diff&r1=154536&r2=154537
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/encoding/sample1/EchoProvider.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/java/encoding/sample1/EchoProvider.java Sun Feb 20 09:56:49 2005
@@ -40,7 +40,6 @@
MessageContext msgContext,
Method method)
throws AxisFault {
- // org.TimeRecorder.BEFORE_DESERALIZE = System.currentTimeMillis();
XMLStreamReader xpp =
msgContext.getSoapOperationElement().getPullParser(true);
Class[] parms = method.getParameterTypes();
Modified: webservices/axis/trunk/java/modules/samples/src/java/encoding/sample2/benchMark/BenchProvider.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/encoding/sample2/benchMark/BenchProvider.java?view=diff&r1=154536&r2=154537
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/encoding/sample2/benchMark/BenchProvider.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/java/encoding/sample2/benchMark/BenchProvider.java Sun Feb 20 09:56:49 2005
@@ -46,7 +46,6 @@
MessageContext msgContext,
Method method)
throws AxisFault {
- // org.TimeRecorder.BEFORE_DESERALIZE = System.currentTimeMillis();
XMLStreamReader xpp =
msgContext.getSoapOperationElement().getPullParser(true);
Class[] parms = method.getParameterTypes();
Modified: webservices/axis/trunk/java/modules/samples/src/java/org/apache/axis/testUtils/SimpleJavaProvider.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/samples/src/java/org/apache/axis/testUtils/SimpleJavaProvider.java?view=diff&r1=154536&r2=154537
==============================================================================
--- webservices/axis/trunk/java/modules/samples/src/java/org/apache/axis/testUtils/SimpleJavaProvider.java (original)
+++ webservices/axis/trunk/java/modules/samples/src/java/org/apache/axis/testUtils/SimpleJavaProvider.java Sun Feb 20 09:56:49 2005
@@ -94,7 +94,6 @@
public Object[] deserializeParameters(MessageContext msgContext,
Method method)
throws AxisFault {
- // org.TimeRecorder.BEFORE_DESERALIZE = System.currentTimeMillis();
XMLStreamReader xpp =
msgContext.getSoapOperationElement().getPullParser(true);
Class[] parms = method.getParameterTypes();