You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2008/12/29 12:39:33 UTC
svn commit: r729870 - in
/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon:
Connection.java SocketRR.java SocketWaiter.java eclipse/ui/Connection.java
eclipse/ui/SocketRR.java eclipse/ui/SocketWaiter.java
Author: veithen
Date: Mon Dec 29 03:39:33 2008
New Revision: 729870
URL: http://svn.apache.org/viewvc?rev=729870&view=rev
Log:
Some minor formatting changes so that we can better compare the code in the Swing UI and the Eclipse plugin.
Modified:
webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/Connection.java
webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketRR.java
webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketWaiter.java
webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/Connection.java
webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketRR.java
webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketWaiter.java
Modified: webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/Connection.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/Connection.java?rev=729870&r1=729869&r2=729870&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/Connection.java (original)
+++ webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/Connection.java Mon Dec 29 03:39:33 2008
@@ -34,7 +34,7 @@
*/
class Connection extends Thread {
- /**
+ /**
* Field listener
*/
Listener listener;
@@ -299,10 +299,9 @@
}
}
} else {
-
- //
+ //
// Change Host: header to point to correct host
- //
+ //
byte[] b1 = new byte[1];
buf = new StringBuffer();
String s1;
@@ -395,15 +394,15 @@
while ((rr1 != null) || (rr2 != null)) {
- if (rr2 != null) {
- listener.tableModel.setValueAt(rr2.getElapsed(), 1 + index, TCPMon.ELAPSED_COLUMN);
- }
-
+ if (rr2 != null) {
+ listener.tableModel.setValueAt(rr2.getElapsed(), 1 + index, TCPMon.ELAPSED_COLUMN);
+ }
+
// 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.
-
+
if ((null != rr1) && rr1.isDone()) {
if ((index >= 0) && (rr2 != null)) {
listener.tableModel.setValueAt(
Modified: webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketRR.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketRR.java?rev=729870&r1=729869&r2=729870&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketRR.java (original)
+++ webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketRR.java Mon Dec 29 03:39:33 2008
@@ -28,7 +28,7 @@
*/
class SocketRR extends Thread {
- /**
+ /**
* Field inSocket
*/
Socket inSocket = null;
@@ -137,7 +137,7 @@
}
public String getElapsed() {
- return String.valueOf(elapsed);
+ return String.valueOf(elapsed);
}
/**
@@ -165,9 +165,9 @@
long start = System.currentTimeMillis();
a:
for (; ;) {
-
+
elapsed = System.currentTimeMillis() - start;
-
+
if (done) {
break;
}
@@ -229,7 +229,7 @@
}
- if (xmlFormat) {
+ if (xmlFormat) {
// Do XML Formatting
boolean inXML = false;
@@ -281,6 +281,7 @@
tmpbuffer[i2++] = buffer[i1];
}
}
+
textArea.append(new String(tmpbuffer, 0, i2));
// Shift saved bytes to the beginning
Modified: webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketWaiter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketWaiter.java?rev=729870&r1=729869&r2=729870&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketWaiter.java (original)
+++ webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/SocketWaiter.java Mon Dec 29 03:39:33 2008
@@ -27,80 +27,80 @@
*/
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(
- TCPMon.getMessage("wait00",
- " Waiting for Connection...")));
- listener.repaint();
- sSocket = new ServerSocket(port);
- for (; ;) {
- Socket inSocket = sSocket.accept();
- if (pleaseStop) {
- break;
- }
- new Connection(listener, inSocket);
- inSocket = null;
- }
- } catch (Exception exp) {
- if (!"socket closed".equals(exp.getMessage())) {
- JLabel tmp = new JLabel(exp.toString());
- tmp.setForeground(Color.red);
- listener.setLeft(tmp);
- listener.setRight(new JLabel(""));
- listener.stop();
- }
- }
- }
-
- /**
- * force a halt by connecting to self and then closing the server socket
- */
- public void halt() {
- try {
- pleaseStop = true;
- new Socket("127.0.0.1", port);
- if (sSocket != null) {
- sSocket.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ /**
+ * 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(
+ TCPMon.getMessage("wait00",
+ " Waiting for Connection...")));
+ listener.repaint();
+ sSocket = new ServerSocket(port);
+ for (; ;) {
+ Socket inSocket = sSocket.accept();
+ if (pleaseStop) {
+ break;
+ }
+ new Connection(listener, inSocket);
+ inSocket = null;
+ }
+ } catch (Exception exp) {
+ if (!"socket closed".equals(exp.getMessage())) {
+ JLabel tmp = new JLabel(exp.toString());
+ tmp.setForeground(Color.red);
+ listener.setLeft(tmp);
+ listener.setRight(new JLabel(""));
+ listener.stop();
+ }
+ }
+ }
+
+ /**
+ * force a halt by connecting to self and then closing the server socket
+ */
+ public void halt() {
+ try {
+ pleaseStop = true;
+ new Socket("127.0.0.1", port);
+ if (sSocket != null) {
+ sSocket.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
Modified: webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/Connection.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/Connection.java?rev=729870&r1=729869&r2=729870&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/Connection.java (original)
+++ webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/Connection.java Mon Dec 29 03:39:33 2008
@@ -66,7 +66,7 @@
* Field elapsed time
*/
long elapsedTime;
-
+
/**
* Field inputText
*/
@@ -167,7 +167,6 @@
* Method run
*/
public void run() {
-
try {
active = true;
HTTPProxyHost = System.getProperty("http.proxyHost");
@@ -253,7 +252,6 @@
}
String bufferedData = null;
StringBuffer buf = null;
-
int index = listener.connections.indexOf(this);
MainView.display.syncExec(new Runnable() {
@@ -283,7 +281,6 @@
}
break;
}
-
bufferedData = buf.toString();
inputString = bufferedData;
MainView.display.syncExec(new Runnable() {
@@ -436,7 +433,6 @@
});
}
}
-
if (targetPort == -1) {
targetPort = 80;
}
@@ -470,7 +466,7 @@
rr2 = new SocketRR(this, outSocket, tmpIn2, inSocket, tmpOut1,
outputText, format, null, 0, "response:",
responseLink);
-
+
while ((rr1 != null) || (rr2 != null)) {
if (rr2 != null) {
@@ -481,12 +477,12 @@
}
});
}
-
+
// 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.
-
+
if ((null != rr1) && rr1.isDone()) {
if ((index >= 0) && (rr2 != null)) {
inputInt = index;
@@ -520,7 +516,6 @@
}
}
-
active = false;
if (index >= 0) {
@@ -567,7 +562,6 @@
halt();
}
-
}
/**
Modified: webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketRR.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketRR.java?rev=729870&r1=729869&r2=729870&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketRR.java (original)
+++ webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketRR.java Mon Dec 29 03:39:33 2008
@@ -74,7 +74,7 @@
* Field tmodel
*/
volatile long elapsed = 0;
-
+
/**
* Field tmodel
*/
@@ -146,7 +146,7 @@
public String getElapsed() {
return String.valueOf(elapsed);
}
-
+
/**
* Method run
*/
@@ -179,13 +179,13 @@
long start = System.currentTimeMillis();
a:
for (; ;) {
-
+
elapsed = System.currentTimeMillis() - start;
-
+
if (done) {
break;
}
-
+
// try{
// len = in.available();
// }catch(Exception e){len=0;}
@@ -259,8 +259,8 @@
}
});
}
-
-
+
+
if (xmlFormat) {
// Do XML Formatting
@@ -313,7 +313,7 @@
tmpbuffer[i2++] = buffer[i1];
}
}
-
+
inputString = new String(tmpbuffer, 0, i2);
MainView.display.syncExec(new Runnable() {
public void run() {
@@ -326,7 +326,6 @@
buffer[i] = buffer[bufferLen - saved + i];
}
} else {
-
inputString = new String(buffer, 0, len);
MainView.display.syncExec(new Runnable() {
public void run() {
Modified: webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketWaiter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketWaiter.java?rev=729870&r1=729869&r2=729870&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketWaiter.java (original)
+++ webservices/commons/trunk/modules/tcpmon/src/org/apache/ws/commons/tcpmon/eclipse/ui/SocketWaiter.java Mon Dec 29 03:39:33 2008
@@ -65,7 +65,6 @@
* Method run
*/
public void run() {
-
try {
MainView.display.syncExec(new Runnable() {
public void run() {
@@ -75,7 +74,6 @@
sSocket = new ServerSocket(port);
for (; ;) {
-
Socket inSocket = sSocket.accept();
if (pleaseStop) {
break;