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 2009/05/30 10:43:48 UTC

svn commit: r780204 - in /webservices/commons/trunk/modules/tcpmon/modules: tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/ tcpmon-core/src/main/java/org/apache/ws/commons...

Author: veithen
Date: Sat May 30 08:43:46 2009
New Revision: 780204

URL: http://svn.apache.org/viewvc?rev=780204&view=rev
Log:
Refactoring to cleanly separate the interceptor engine from the UI.

Added:
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Connection.java
      - copied, changed from r780128, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Connection.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Interceptor.java
      - copied, changed from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketWaiter.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfiguration.java   (with props)
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfigurationBuilder.java   (with props)
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorListener.java   (with props)
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/RequestResponseListener.java
      - copied, changed from r780126, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/IRequestResponse.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/SocketRR.java
      - copied, changed from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketRR.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/StreamFilterFactory.java   (with props)
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractListener.java
      - copied, changed from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/AbstractListener.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/Configuration.java
      - copied, changed from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Configuration.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/RawSender.java
      - copied, changed from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/RawSender.java
Removed:
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/AbstractListener.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Configuration.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Connection.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/IRequestResponse.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/RawSender.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketRR.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketWaiter.java
Modified:
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/throttle/ThrottleConfiguration.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractRequestResponse.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/Listener.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/MainView.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/AdminPane.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/Listener.java
    webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/TCPMon.java

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Connection.java (from r780128, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Connection.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Connection.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Connection.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Connection.java&r1=780128&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Connection.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Connection.java Sat May 30 08:43:46 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.engine;
 
 import org.apache.ws.commons.tcpmon.core.filter.Pipeline;
 import org.apache.ws.commons.tcpmon.core.filter.StreamException;
@@ -23,8 +23,6 @@
 import org.apache.ws.commons.tcpmon.core.filter.http.HttpProxyClientHandler;
 import org.apache.ws.commons.tcpmon.core.filter.http.HttpProxyServerHandler;
 import org.apache.ws.commons.tcpmon.core.filter.http.HttpRequestFilter;
-import org.apache.ws.commons.tcpmon.core.filter.throttle.Throttle;
-import org.apache.ws.commons.tcpmon.core.filter.throttle.ThrottleConfiguration;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -36,9 +34,9 @@
 /**
  * a connection listens to a single current connection
  */
-public class Connection extends Thread {
-    private final AbstractListener listener;
-    private final Configuration config;
+class Connection extends Thread {
+    private final InterceptorConfiguration config;
+    private final InterceptorListener listener;
 
     /**
      * Field active
@@ -65,7 +63,7 @@
      */
     private SocketRR rr2 = null;
 
-    private IRequestResponse requestResponse;
+    private RequestResponseListener requestResponseListener;
 
     /**
      * Constructor Connection
@@ -73,9 +71,9 @@
      * @param listener
      * @param s
      */
-    public Connection(AbstractListener listener, Socket s) {
+    public Connection(InterceptorConfiguration config, InterceptorListener listener, Socket s) {
+        this.config = config;
         this.listener = listener;
-        config = listener.getConfiguration();
         inSocket = s;
     }
 
@@ -87,10 +85,9 @@
             active = true;
             String HTTPProxyHost = config.getHttpProxyHost();
             int HTTPProxyPort = config.getHttpProxyPort();
-            ThrottleConfiguration throttleConfig = config.getThrottleConfiguration();
             final SocketFactory socketFactory = config.getSocketFactory();
             String targetHost = config.getTargetHost();
-            requestResponse = listener.createRequestResponse(inSocket.getInetAddress().getHostName());
+            requestResponseListener = listener.createRequestResponseListener(inSocket.getInetAddress().getHostName());
             int targetPort = config.getTargetPort();
             InputStream tmpIn1 = inSocket.getInputStream();
             OutputStream tmpOut1 = inSocket.getOutputStream();
@@ -101,7 +98,7 @@
             if (config.isProxy()) {
                 requestFilter.addHandler(new HttpProxyServerHandler() {
                     protected void handleConnection(String host, int port) {
-                        requestResponse.setTarget(host, port);
+                        requestResponseListener.setTarget(host, port);
                         try {
                             outSocket = socketFactory.createSocket(host, port);
                         } catch (IOException ex) {
@@ -110,14 +107,14 @@
                     }
                 });
             } else {
-                requestResponse.setTarget(targetHost, targetPort);
+                requestResponseListener.setTarget(targetHost, targetPort);
                 requestFilter.addHandler(new HttpHeaderRewriter("Host", targetHost + ":" + targetPort));
                 outSocket = socketFactory.createSocket(targetHost, targetPort);
             }
             // We log the request data at this stage. This means that the user will see the request
             // as if it had been sent directly from the client to the server (without TCPMon or a proxy
             // in between).
-            OutputStream requestOutputStream = requestResponse.getRequestOutputStream();
+            OutputStream requestOutputStream = requestResponseListener.getRequestOutputStream();
             if (requestOutputStream != null) {
                 requestPipeline.addFilter(new Tee(requestOutputStream));
             }
@@ -125,13 +122,11 @@
                 requestFilter.addHandler(new HttpProxyClientHandler(targetHost, targetPort));
                 outSocket = socketFactory.createSocket(HTTPProxyHost, HTTPProxyPort);
             }
-            if (throttleConfig != null) {
-                requestPipeline.addFilter(new Throttle(throttleConfig));
-            }
+            config.applyRequestFilters(requestPipeline);
             Tee requestTee = new Tee();
             requestPipeline.addFilter(requestTee);
             
-            requestResponse.setState(IRequestResponse.STATE_ACTIVE);
+            requestResponseListener.setState(RequestResponseListener.STATE_ACTIVE);
             
             // If we act as a proxy, we first need to read the start of the request before
             // the outSocket is available.
@@ -143,13 +138,11 @@
             requestTee.setOutputStream(tmpOut2);
             
             Pipeline responsePipeline = new Pipeline();
-            if (throttleConfig != null) {
-                responsePipeline.addFilter(new Throttle(throttleConfig));
-            }
+            config.applyResponseFilters(responsePipeline);
             if (tmpOut1 != null) {
                 responsePipeline.addFilter(new Tee(tmpOut1));
             }
-            OutputStream responseOutputStream = requestResponse.getResponseOutputStream();
+            OutputStream responseOutputStream = requestResponseListener.getResponseOutputStream();
             if (responseOutputStream != null) {
                 responsePipeline.addFilter(new Tee(responseOutputStream));
             }
@@ -166,7 +159,7 @@
             while ((rr1 != null) || (rr2 != null)) {
 
                 if (rr2 != null) {
-                    requestResponse.setElapsed(rr2.getElapsed());
+                    requestResponseListener.setElapsed(rr2.getElapsed());
                 }
                 
                 // Only loop as long as the connection to the target
@@ -176,14 +169,14 @@
                 
                 if ((null != rr1) && rr1.isDone()) {
                     if (rr2 != null) {
-                        requestResponse.setState(IRequestResponse.STATE_RESP);
+                        requestResponseListener.setState(RequestResponseListener.STATE_RESP);
                     }
                     rr1 = null;
                 }
 
                 if ((null != rr2) && rr2.isDone()) {
                     if (rr1 != null) {
-                        requestResponse.setState(IRequestResponse.STATE_REQ);
+                        requestResponseListener.setState(RequestResponseListener.STATE_REQ);
                     }
                     rr2 = null;
                 }
@@ -195,12 +188,12 @@
 
             active = false;
 
-            requestResponse.setState(IRequestResponse.STATE_DONE);
+            requestResponseListener.setState(RequestResponseListener.STATE_DONE);
 
         } catch (Exception e) {
-            if (requestResponse != null) {
-                requestResponse.setState(IRequestResponse.STATE_ERROR);
-                requestResponse.onError(e);
+            if (requestResponseListener != null) {
+                requestResponseListener.setState(RequestResponseListener.STATE_ERROR);
+                requestResponseListener.onError(e);
             }
             halt();
         }

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Interceptor.java (from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketWaiter.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Interceptor.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Interceptor.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketWaiter.java&r1=780076&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketWaiter.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/Interceptor.java Sat May 30 08:43:46 2009
@@ -14,39 +14,28 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.engine;
 
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.util.Iterator;
 import java.util.Vector;
 
-import javax.net.ServerSocketFactory;
-
 /**
  * wait for incoming connections, spawn a connection thread when
  * stuff comes in.
  */
-public class SocketWaiter extends Thread {
+public class Interceptor extends Thread {
 
     /**
      * Field sSocket
      */
     ServerSocket sSocket = null;
 
-    /**
-     * Field listener
-     */
-    AbstractListener listener;
-
-    private final ServerSocketFactory serverSocketFactory;
+    private final InterceptorConfiguration config;
+    private final InterceptorListener listener;
     
     /**
-     * Field port
-     */
-    int port;
-
-    /**
      * Field pleaseStop
      */
     boolean pleaseStop = false;
@@ -59,10 +48,9 @@
      * @param l
      * @param p
      */
-    public SocketWaiter(AbstractListener l, ServerSocketFactory serverSocketFactory, int p) {
-        listener = l;
-        this.serverSocketFactory = serverSocketFactory;
-        port = p;
+    public Interceptor(InterceptorConfiguration config, InterceptorListener listener) {
+        this.config = config;
+        this.listener = listener;
         start();
     }
 
@@ -72,13 +60,13 @@
     public void run() {
         try {
             listener.onServerSocketStart();
-            sSocket = serverSocketFactory.createServerSocket(port);
+            sSocket = config.getServerSocketFactory().createServerSocket(config.getListenPort());
             for (; ;) {
                 Socket inSocket = sSocket.accept();
                 if (pleaseStop) {
                     break;
                 }
-                Connection connection = new Connection(listener, inSocket);
+                Connection connection = new Connection(config, listener, inSocket);
                 // TODO: at some point we need to remove closed connections,
                 //       otherwise this will be a memory leak.
                 connections.add(connection);
@@ -98,7 +86,7 @@
     public void halt() {
         try {
             pleaseStop = true;
-            new Socket("127.0.0.1", port);
+            new Socket("127.0.0.1", config.getListenPort());
             if (sSocket != null) {
                 sSocket.close();
             }

Added: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfiguration.java?rev=780204&view=auto
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfiguration.java (added)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfiguration.java Sat May 30 08:43:46 2009
@@ -0,0 +1,103 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.commons.tcpmon.core.engine;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import org.apache.ws.commons.tcpmon.core.filter.Pipeline;
+import org.apache.ws.commons.tcpmon.core.filter.StreamFilterFactory;
+
+/**
+ * Holds the configuration for an {@link Interceptor} instance.
+ * To avoid any concurrency issue, this class is designed as immutable.
+ * Instances are created using {@link InterceptorConfigurationBuilder}. 
+ */
+public class InterceptorConfiguration {
+    private final ServerSocketFactory serverSocketFactory;
+    private final int listenPort;
+    private final SocketFactory socketFactory;
+    private final String targetHost;
+    private final int targetPort;
+    private final boolean proxy;
+    private final String httpProxyHost;
+    private final int httpProxyPort;
+    final StreamFilterFactory[] requestFilters;
+    final StreamFilterFactory[] responseFilters;
+
+    InterceptorConfiguration(ServerSocketFactory serverSocketFactory, int listenPort,
+            SocketFactory socketFactory, String targetHost, int targetPort, boolean proxy,
+            String httpProxyHost, int httpProxyPort, StreamFilterFactory[] requestFilters,
+            StreamFilterFactory[] responseFilters) {
+        this.serverSocketFactory = serverSocketFactory;
+        this.listenPort = listenPort;
+        this.socketFactory = socketFactory;
+        this.targetHost = targetHost;
+        this.targetPort = targetPort;
+        this.proxy = proxy;
+        this.httpProxyHost = httpProxyHost;
+        this.httpProxyPort = httpProxyPort;
+        this.requestFilters = requestFilters;
+        this.responseFilters = responseFilters;
+    }
+
+    public ServerSocketFactory getServerSocketFactory() {
+        return serverSocketFactory;
+    }
+
+    public int getListenPort() {
+        return listenPort;
+    }
+    
+    public SocketFactory getSocketFactory() {
+        return socketFactory;
+    }
+
+    public String getTargetHost() {
+        return targetHost;
+    }
+    
+    public int getTargetPort() {
+        return targetPort;
+    }
+    
+    public boolean isProxy() {
+        return proxy;
+    }
+
+    public String getHttpProxyHost() {
+        return httpProxyHost;
+    }
+
+    public int getHttpProxyPort() {
+        return httpProxyPort;
+    }
+    
+    private static void applyFilters(Pipeline pipeline, StreamFilterFactory[] filters) {
+        for (int i=0; i<filters.length; i++) {
+            pipeline.addFilter(filters[i].newInstance());
+        }
+    }
+    
+    public void applyRequestFilters(Pipeline pipeline) {
+        applyFilters(pipeline, requestFilters);
+    }
+    
+    public void applyResponseFilters(Pipeline pipeline) {
+        applyFilters(pipeline, responseFilters);
+    }
+}

Propchange: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfigurationBuilder.java?rev=780204&view=auto
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfigurationBuilder.java (added)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfigurationBuilder.java Sat May 30 08:43:46 2009
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.commons.tcpmon.core.engine;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+
+import org.apache.ws.commons.tcpmon.core.filter.StreamFilterFactory;
+
+/**
+ * Creates {@link InterceptorConfiguration} instances.
+ */
+public class InterceptorConfigurationBuilder {
+    private ServerSocketFactory serverSocketFactory;
+    private int listenPort;
+    private SocketFactory socketFactory;
+    private String targetHost;
+    private int targetPort;
+    private boolean proxy;
+    private String httpProxyHost;
+    private int httpProxyPort;
+    private final List/*<StreamFilterFactory>*/ requestFilters = new ArrayList();
+    private final List/*<StreamFilterFactory>*/ responseFilters = new ArrayList();
+
+    public InterceptorConfigurationBuilder() {
+    }
+    
+    public InterceptorConfigurationBuilder(InterceptorConfiguration config) {
+        serverSocketFactory = config.getServerSocketFactory();
+        listenPort = config.getListenPort();
+        socketFactory = config.getSocketFactory();
+        targetHost = config.getTargetHost();
+        targetPort = config.getTargetPort();
+        proxy = config.isProxy();
+        httpProxyHost = config.getHttpProxyHost();
+        httpProxyPort = config.getHttpProxyPort();
+        requestFilters.addAll(Arrays.asList(config.requestFilters));
+        responseFilters.addAll(Arrays.asList(config.responseFilters));
+    }
+    
+    public void setServerSocketFactory(ServerSocketFactory serverSocketFactory) {
+        this.serverSocketFactory = serverSocketFactory;
+    }
+
+    public void setListenPort(int listenPort) {
+        this.listenPort = listenPort;
+    }
+
+    public void setSocketFactory(SocketFactory socketFactory) {
+        this.socketFactory = socketFactory;
+    }
+
+    public void setTargetHost(String targetHost) {
+        this.targetHost = targetHost;
+    }
+    
+    public void setTargetPort(int targetPort) {
+        this.targetPort = targetPort;
+    }
+
+    public void setProxy(boolean proxy) {
+        this.proxy = proxy;
+    }
+
+    public void configProxyFromSystemProperties() {
+        String host = System.getProperty("http.proxyHost");
+        if (host != null && host.length() > 0) {
+            httpProxyHost = host;
+            String port = System.getProperty("http.proxyPort");
+            if (port != null && port.length() > 0) {
+                httpProxyPort = Integer.parseInt(port);
+            } else {
+                httpProxyPort = 80;
+            }
+        } else {
+            httpProxyHost = null;
+        }
+    }
+    
+    public void setHttpProxyHost(String httpProxyHost) {
+        this.httpProxyHost = httpProxyHost;
+    }
+
+    public void setHttpProxyPort(int httpProxyPort) {
+        this.httpProxyPort = httpProxyPort;
+    }
+    
+    public void addRequestFilter(StreamFilterFactory filter) {
+        requestFilters.add(filter);
+    }
+    
+    public void addResponseFilter(StreamFilterFactory filter) {
+        responseFilters.add(filter);
+    }
+    
+    public InterceptorConfiguration build() {
+        if (serverSocketFactory == null) {
+            serverSocketFactory = ServerSocketFactory.getDefault();
+        }
+        if (socketFactory == null) {
+            socketFactory = SocketFactory.getDefault();
+        }
+        if (proxy) {
+            targetHost = null;
+            targetPort = -1;
+        }
+        return new InterceptorConfiguration(serverSocketFactory, listenPort, socketFactory,
+                targetHost, targetPort, proxy, httpProxyHost, httpProxyPort,
+                (StreamFilterFactory[])requestFilters.toArray(new StreamFilterFactory[requestFilters.size()]),
+                (StreamFilterFactory[])responseFilters.toArray(new StreamFilterFactory[responseFilters.size()]));
+    }
+}

Propchange: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorConfigurationBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorListener.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorListener.java?rev=780204&view=auto
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorListener.java (added)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorListener.java Sat May 30 08:43:46 2009
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.commons.tcpmon.core.engine;
+
+public interface InterceptorListener {
+    void onServerSocketStart();
+    void onServerSocketError(Throwable ex);
+    RequestResponseListener createRequestResponseListener(String fromHost);
+}

Propchange: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/InterceptorListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/RequestResponseListener.java (from r780126, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/IRequestResponse.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/RequestResponseListener.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/RequestResponseListener.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/IRequestResponse.java&r1=780126&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/IRequestResponse.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/RequestResponseListener.java Sat May 30 08:43:46 2009
@@ -14,14 +14,14 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.engine;
 
 import java.io.OutputStream;
 
 /**
  * Listener receiving information about a given request-response exchange.
  */
-public interface IRequestResponse {
+public interface RequestResponseListener {
     int STATE_ACTIVE = 0;
     int STATE_REQ = 1;
     int STATE_RESP = 2;

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/SocketRR.java (from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketRR.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/SocketRR.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/SocketRR.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketRR.java&r1=780076&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/SocketRR.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/engine/SocketRR.java Sat May 30 08:43:46 2009
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.engine;
 
 import org.apache.ws.commons.tcpmon.core.filter.Pipeline;
 
@@ -27,7 +27,7 @@
  * this class handles the pumping of data from the incoming socket to the
  * outgoing socket
  */
-public class SocketRR extends Thread {
+class SocketRR extends Thread {
     private final Connection connection;
 
     /**

Added: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/StreamFilterFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/StreamFilterFactory.java?rev=780204&view=auto
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/StreamFilterFactory.java (added)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/StreamFilterFactory.java Sat May 30 08:43:46 2009
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.commons.tcpmon.core.filter;
+
+public interface StreamFilterFactory {
+    StreamFilter newInstance();
+}

Propchange: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/StreamFilterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/throttle/ThrottleConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/throttle/ThrottleConfiguration.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/throttle/ThrottleConfiguration.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/throttle/ThrottleConfiguration.java Sat May 30 08:43:46 2009
@@ -16,9 +16,12 @@
 
 package org.apache.ws.commons.tcpmon.core.filter.throttle;
 
-public class ThrottleConfiguration {
-    private int delayBytes;
-    private int delayTime;
+import org.apache.ws.commons.tcpmon.core.filter.StreamFilter;
+import org.apache.ws.commons.tcpmon.core.filter.StreamFilterFactory;
+
+public class ThrottleConfiguration implements StreamFilterFactory {
+    private final int delayBytes;
+    private final int delayTime;
     
     /**
      * construct
@@ -38,4 +41,8 @@
     public int getDelayTime() {
         return delayTime;
     }
+
+    public StreamFilter newInstance() {
+        return new Throttle(this);
+    }
 }

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractListener.java (from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/AbstractListener.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractListener.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractListener.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/AbstractListener.java&r1=780076&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/AbstractListener.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractListener.java Sat May 30 08:43:46 2009
@@ -14,13 +14,14 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.ui;
 
 import java.io.OutputStream;
 
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorListener;
 import org.apache.ws.commons.tcpmon.core.ui.AbstractRequestResponse;
 
-public abstract class AbstractListener {
+public abstract class AbstractListener implements InterceptorListener {
     protected void resend(AbstractRequestResponse requestResponse) {
         try {
             String text = requestResponse.getRequestAsString();
@@ -68,7 +69,4 @@
     }
     
     public abstract Configuration getConfiguration();
-    public abstract void onServerSocketStart();
-    public abstract void onServerSocketError(Throwable ex);
-    public abstract IRequestResponse createRequestResponse(String fromHost);
 }

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractRequestResponse.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractRequestResponse.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractRequestResponse.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/AbstractRequestResponse.java Sat May 30 08:43:46 2009
@@ -27,8 +27,7 @@
 import java.util.Date;
 
 import org.apache.ws.commons.tcpmon.TCPMonBundle;
-import org.apache.ws.commons.tcpmon.core.Configuration;
-import org.apache.ws.commons.tcpmon.core.IRequestResponse;
+import org.apache.ws.commons.tcpmon.core.engine.RequestResponseListener;
 import org.apache.ws.commons.tcpmon.core.filter.CharsetDecoderFilter;
 import org.apache.ws.commons.tcpmon.core.filter.Pipeline;
 import org.apache.ws.commons.tcpmon.core.filter.RequestLineExtractor;
@@ -36,7 +35,7 @@
 import org.apache.ws.commons.tcpmon.core.filter.http.HttpResponseFilter;
 import org.apache.ws.commons.tcpmon.core.filter.mime.DefaultContentFilterFactory;
 
-public abstract class AbstractRequestResponse implements IRequestResponse {
+public abstract class AbstractRequestResponse implements RequestResponseListener {
     private static final String[] states = new String[] {
         TCPMonBundle.getMessage("active00","Active"),
         TCPMonBundle.getMessage("req00", "Req"),

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/Configuration.java (from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Configuration.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/Configuration.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/Configuration.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Configuration.java&r1=780076&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/Configuration.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/Configuration.java Sat May 30 08:43:46 2009
@@ -14,94 +14,20 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.ui;
 
-import javax.net.ServerSocketFactory;
-import javax.net.SocketFactory;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfiguration;
 
-import org.apache.ws.commons.tcpmon.core.filter.throttle.ThrottleConfiguration;
-
-public class Configuration implements Cloneable {
-    private ServerSocketFactory serverSocketFactory;
-    private int listenPort;
-    private SocketFactory socketFactory;
-    private String targetHost;
-    private int targetPort;
-    private boolean proxy;
+public class Configuration {
+    private InterceptorConfiguration interceptorConfiguration;
     private boolean xmlFormat;
-    private String httpProxyHost;
-    private int httpProxyPort;
-    private ThrottleConfiguration throttleConfiguration;
-    
-    public void configProxyFromSystemProperties() {
-        String host = System.getProperty("http.proxyHost");
-        if (host != null && host.length() > 0) {
-            httpProxyHost = host;
-            String port = System.getProperty("http.proxyPort");
-            if (port != null && port.length() > 0) {
-                httpProxyPort = Integer.parseInt(port);
-            } else {
-                httpProxyPort = 80;
-            }
-        } else {
-            httpProxyHost = null;
-        }
-    }
     
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException ex) {
-            throw new InternalError();
-        }
-    }
-
-    public ServerSocketFactory getServerSocketFactory() {
-        return serverSocketFactory != null ? serverSocketFactory : ServerSocketFactory.getDefault();
+    public InterceptorConfiguration getInterceptorConfiguration() {
+        return interceptorConfiguration;
     }
 
-    public void setServerSocketFactory(ServerSocketFactory serverSocketFactory) {
-        this.serverSocketFactory = serverSocketFactory;
-    }
-
-    public int getListenPort() {
-        return listenPort;
-    }
-    
-    public void setListenPort(int listenPort) {
-        this.listenPort = listenPort;
-    }
-
-    public SocketFactory getSocketFactory() {
-        return socketFactory != null ? socketFactory : SocketFactory.getDefault();
-    }
-
-    public void setSocketFactory(SocketFactory socketFactory) {
-        this.socketFactory = socketFactory;
-    }
-
-    public String getTargetHost() {
-        return targetHost;
-    }
-    
-    public void setTargetHost(String targetHost) {
-        this.targetHost = targetHost;
-    }
-    
-    public int getTargetPort() {
-        return targetPort;
-    }
-    
-    public void setTargetPort(int targetPort) {
-        this.targetPort = targetPort;
-    }
-
-    public boolean isProxy() {
-        return proxy;
-    }
-
-    public void setProxy(boolean proxy) {
-        this.proxy = proxy;
+    public void setInterceptorConfiguration(InterceptorConfiguration interceptorConfiguration) {
+        this.interceptorConfiguration = interceptorConfiguration;
     }
 
     public boolean isXmlFormat() {
@@ -111,28 +37,4 @@
     public void setXmlFormat(boolean xmlFormat) {
         this.xmlFormat = xmlFormat;
     }
-
-    public String getHttpProxyHost() {
-        return httpProxyHost;
-    }
-
-    public void setHttpProxyHost(String httpProxyHost) {
-        this.httpProxyHost = httpProxyHost;
-    }
-
-    public int getHttpProxyPort() {
-        return httpProxyPort;
-    }
-
-    public void setHttpProxyPort(int httpProxyPort) {
-        this.httpProxyPort = httpProxyPort;
-    }
-
-    public ThrottleConfiguration getThrottleConfiguration() {
-        return throttleConfiguration;
-    }
-
-    public void setThrottleConfiguration(ThrottleConfiguration throttleConfiguration) {
-        this.throttleConfiguration = throttleConfiguration;
-    }
 }

Copied: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/RawSender.java (from r780076, webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/RawSender.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/RawSender.java?p2=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/RawSender.java&p1=webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/RawSender.java&r1=780076&r2=780204&rev=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/RawSender.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/ui/RawSender.java Sat May 30 08:43:46 2009
@@ -14,13 +14,15 @@
  * limitations under the License.
  */
 
-package org.apache.ws.commons.tcpmon.core;
+package org.apache.ws.commons.tcpmon.core.ui;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfiguration;
+import org.apache.ws.commons.tcpmon.core.engine.RequestResponseListener;
 import org.apache.ws.commons.tcpmon.core.filter.Pipeline;
 import org.apache.ws.commons.tcpmon.core.filter.Stream;
 import org.apache.ws.commons.tcpmon.core.filter.StreamFilter;
@@ -31,16 +33,16 @@
 import org.apache.ws.commons.tcpmon.core.filter.http.HttpResponseFilter;
 
 /**
- * Sends a raw HTTP request and invokes {@link IRequestResponse} as necessary.
+ * Sends a raw HTTP request and invokes {@link RequestResponseListener} as necessary.
  */
 public class RawSender implements Runnable {
-    private final IRequestResponse requestResponse;
+    private final RequestResponseListener requestResponse;
     private final Socket socket;
     private final OutputStream out;
     
     public RawSender(AbstractListener listener, String targetHost, int targetPort) throws IOException {
-        Configuration config = listener.getConfiguration();
-        requestResponse = listener.createRequestResponse("resend");
+        InterceptorConfiguration config = listener.getConfiguration().getInterceptorConfiguration();
+        requestResponse = listener.createRequestResponseListener("resend");
         requestResponse.setTarget(targetHost, targetPort);
         Pipeline pipeline = new Pipeline();
         pipeline.addFilter(new Tee(requestResponse.getRequestOutputStream()));
@@ -52,12 +54,12 @@
         } else {
             socket = new Socket(targetHost, targetPort);
         }
-        requestResponse.setState(IRequestResponse.STATE_ACTIVE);
+        requestResponse.setState(RequestResponseListener.STATE_ACTIVE);
         pipeline.addFilter(new StreamFilter() {
             public void invoke(Stream stream) {
                 stream.skipAll();
                 if (stream.isEndOfStream()) {
-                    requestResponse.setState(IRequestResponse.STATE_REQ);
+                    requestResponse.setState(RequestResponseListener.STATE_REQ);
                 }
             }
         });
@@ -90,9 +92,9 @@
             while (pipeline.readFrom(in) != -1) {
                 // Just loop
             }
-            requestResponse.setState(IRequestResponse.STATE_DONE);
+            requestResponse.setState(RequestResponseListener.STATE_DONE);
         } catch (IOException ex) {
-            requestResponse.setState(IRequestResponse.STATE_ERROR);
+            requestResponse.setState(RequestResponseListener.STATE_ERROR);
             requestResponse.onError(ex);
         } finally {
             requestResponse.setElapsed(System.currentTimeMillis() - start);

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/Listener.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/Listener.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/Listener.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/Listener.java Sat May 30 08:43:46 2009
@@ -16,10 +16,12 @@
 package org.apache.ws.commons.tcpmon.eclipse.ui;
 
 import org.apache.ws.commons.tcpmon.TCPMonBundle;
-import org.apache.ws.commons.tcpmon.core.AbstractListener;
-import org.apache.ws.commons.tcpmon.core.Configuration;
-import org.apache.ws.commons.tcpmon.core.IRequestResponse;
-import org.apache.ws.commons.tcpmon.core.SocketWaiter;
+import org.apache.ws.commons.tcpmon.core.engine.Interceptor;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfiguration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfigurationBuilder;
+import org.apache.ws.commons.tcpmon.core.engine.RequestResponseListener;
+import org.apache.ws.commons.tcpmon.core.ui.AbstractListener;
+import org.apache.ws.commons.tcpmon.core.ui.Configuration;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
@@ -55,14 +57,14 @@
     private TabFolder tabFolder;
     private TabItem portTabItem;
 
-    private SocketWaiter sw = null;
+    private Interceptor interceptor = null;
 
     public final Vector requestResponses = new Vector();
 
-    private final Configuration baseConfiguration;
+    private final InterceptorConfiguration baseConfiguration;
 
     public Listener(TabFolder tabFolder, String name,
-                    Configuration config) {
+                    InterceptorConfiguration config) {
         if (name == null) {
             name = TCPMonBundle.getMessage("port01", "Port") + " " + config.getListenPort();
         }
@@ -73,7 +75,7 @@
 
     }
 
-    public void createPortTab(Configuration config) {
+    public void createPortTab(InterceptorConfiguration config) {
         portTabItem = new TabItem(tabFolder, SWT.NONE);
 
         final Composite composite = new Composite(tabFolder, SWT.NONE);
@@ -387,12 +389,12 @@
     }
 
     public void start() {
-        Configuration config = getConfiguration();
+        InterceptorConfiguration config = getConfiguration().getInterceptorConfiguration();
         int port = config.getListenPort();
         portField.setText("" + port);
         portTabItem.setText(TCPMonBundle.getMessage("port01", "Port") + " " + port);
         tPortField.setText("" + config.getTargetPort());
-        sw = new SocketWaiter(this, config.getServerSocketFactory(), port);
+        interceptor = new Interceptor(config, this);
         stopButton.setText(TCPMonBundle.getMessage("stop00", "Stop"));
         portField.setEditable(false);
         hostField.setEditable(false);
@@ -402,7 +404,7 @@
 
     public void stop() {
         try {
-            sw.halt();
+            interceptor.halt();
             stopButton.setText(TCPMonBundle.getMessage("start00", "Start"));
             portField.setEditable(true);
             hostField.setEditable(true);
@@ -597,19 +599,18 @@
     }
 
     public Configuration getConfiguration() {
-        final Configuration config = (Configuration)baseConfiguration.clone();
+        final InterceptorConfigurationBuilder configBuilder = new InterceptorConfigurationBuilder(baseConfiguration);
+        final Configuration config = new Configuration();
         MainView.display.syncExec(new Runnable() {
             public void run() {
-                config.setListenPort(Integer.parseInt(portField.getText()));
-                config.setTargetHost(hostField.getText());
-                config.setTargetPort(Integer.parseInt(tPortField.getText()));
-                config.setProxy(isProxyBox.getSelection());
+                configBuilder.setListenPort(Integer.parseInt(portField.getText()));
+                configBuilder.setTargetHost(hostField.getText());
+                configBuilder.setTargetPort(Integer.parseInt(tPortField.getText()));
+                configBuilder.setProxy(isProxyBox.getSelection());
                 config.setXmlFormat(xmlFormatBox.getSelection());
             }
         });
-        if (config.getHttpProxyHost() == null) {
-            config.configProxyFromSystemProperties();
-        }
+        config.setInterceptorConfiguration(configBuilder.build());
         return config;
     }
 
@@ -631,7 +632,7 @@
         });
     }
 
-    public IRequestResponse createRequestResponse(String fromHost) {
+    public RequestResponseListener createRequestResponseListener(String fromHost) {
         return new RequestResponse(this, fromHost);
     }
 }

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/MainView.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/MainView.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/MainView.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-eclipse-plugin/src/main/java/org/apache/ws/commons/tcpmon/eclipse/ui/MainView.java Sat May 30 08:43:46 2009
@@ -17,7 +17,8 @@
 
 
 import org.apache.ws.commons.tcpmon.TCPMonBundle;
-import org.apache.ws.commons.tcpmon.core.Configuration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfiguration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfigurationBuilder;
 import org.apache.ws.commons.tcpmon.core.filter.throttle.ThrottleConfiguration;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
@@ -106,7 +107,7 @@
         addButton.addSelectionListener(new SelectionAdapter() {
             public void widgetSelected(final SelectionEvent e) {
                 if (add.equals(((Button) e.getSource()).getText())) {
-                    Configuration config = getConfiguration();
+                    InterceptorConfiguration config = getConfiguration();
                     if (config == null) {
                         return;
                     }
@@ -123,34 +124,36 @@
         configTab.setControl(composite);
     }
 
-    private Configuration getConfiguration() {
-        Configuration config = new Configuration();
+    private InterceptorConfiguration getConfiguration() {
+        InterceptorConfigurationBuilder configBuilder = new InterceptorConfigurationBuilder();
         
         int lPort = getValue(0, port.getText());
         if (lPort == 0) {
             return null;
         }
-        config.setListenPort(lPort);
-        config.setProxy(proxyButton.getSelection());
-        config.setTargetHost(host.getText());
-        config.setTargetPort(getValue(0, tport.getText()));
-        ThrottleConfiguration throttleConfig = null;
+        configBuilder.setListenPort(lPort);
+        configBuilder.setProxy(proxyButton.getSelection());
+        configBuilder.setTargetHost(host.getText());
+        configBuilder.setTargetPort(getValue(0, tport.getText()));
         if (delayBox.getSelection()) {
-            throttleConfig = new ThrottleConfiguration(getValue(0, delayBytes.getText()), getValue(0, delayTime.getText()));
+            ThrottleConfiguration throttleConfig = new ThrottleConfiguration(getValue(0, delayBytes.getText()), getValue(0, delayTime.getText()));
+            configBuilder.addRequestFilter(throttleConfig);
+            configBuilder.addResponseFilter(throttleConfig);
         }
-        config.setThrottleConfiguration(throttleConfig);
         
         String text = hTTPProxyHost.getText();
         if (text.length() > 0) {
-            config.setHttpProxyHost(text);
-        }
-        text = hTTPProxyPort.getText();
-        int proxyPort = getValue(-1, hTTPProxyPort.getText());
-        if (proxyPort != -1) {
-            config.setHttpProxyPort(Integer.parseInt(text));
+            configBuilder.setHttpProxyHost(text);
+            text = hTTPProxyPort.getText();
+            int proxyPort = getValue(-1, hTTPProxyPort.getText());
+            if (proxyPort != -1) {
+                configBuilder.setHttpProxyPort(Integer.parseInt(text));
+            }
+        } else {
+            configBuilder.configProxyFromSystemProperties();
         }
         
-        return config;
+        return configBuilder.build();
     }
 
     private void addActAsOptions(Composite composite) {

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/AdminPane.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/AdminPane.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/AdminPane.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/AdminPane.java Sat May 30 08:43:46 2009
@@ -35,7 +35,8 @@
 import javax.swing.text.PlainDocument;
 
 import org.apache.ws.commons.tcpmon.TCPMonBundle;
-import org.apache.ws.commons.tcpmon.core.Configuration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfiguration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfigurationBuilder;
 import org.apache.ws.commons.tcpmon.core.filter.throttle.ThrottleConfiguration;
 
 import java.awt.BorderLayout;
@@ -387,7 +388,7 @@
         addButton.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent event) {
                 if (add.equals(event.getActionCommand())) {
-                    Configuration config = getConfiguration();
+                    InterceptorConfiguration config = getConfiguration();
                     if (config == null) {
 
                         // no port, button does nothing
@@ -411,47 +412,47 @@
         notebook.setSelectedIndex(notebook.getTabCount() - 1);
     }
     
-    private Configuration getConfiguration() {
-        Configuration config = new Configuration();
+    private InterceptorConfiguration getConfiguration() {
+        InterceptorConfigurationBuilder configBuilder = new InterceptorConfigurationBuilder();
         
         int lPort = port.getValue(0);
         if (lPort == 0) {
             // no port, no configuration
             return null;
         }
-        config.setListenPort(lPort);
-        config.setProxy(proxyButton.isSelected());
-        config.setTargetHost(host.getText());
-        config.setTargetPort(tport.getValue(0));
-        ThrottleConfiguration throttleConfig = null;
+        configBuilder.setListenPort(lPort);
+        configBuilder.setProxy(proxyButton.isSelected());
+        configBuilder.setTargetHost(host.getText());
+        configBuilder.setTargetPort(tport.getValue(0));
         if (delayBox.isSelected()) {
-            throttleConfig = new ThrottleConfiguration(delayBytes.getValue(0), delayTime.getValue(0));
+            ThrottleConfiguration throttleConfig = new ThrottleConfiguration(delayBytes.getValue(0), delayTime.getValue(0));
+            configBuilder.addRequestFilter(throttleConfig);
+            configBuilder.addResponseFilter(throttleConfig);
         }
-        config.setThrottleConfiguration(throttleConfig);
 
         // Pick-up the HTTP Proxy settings
         // /////////////////////////////////////////////////
         String text = HTTPProxyHost.getText();
         if (text.length() > 0) {
-            config.setHttpProxyHost(text);
+            configBuilder.setHttpProxyHost(text);
         }
         text = HTTPProxyPort.getText();
         int proxyPort = HTTPProxyPort.getValue(-1);
         if (proxyPort != -1) {
-            config.setHttpProxyPort(Integer.parseInt(text));
+            configBuilder.setHttpProxyPort(Integer.parseInt(text));
         }
         
         if (outgoingSSLBox.isSelected()) {
             try {
                 SSLContext ctx = SSLContext.getInstance("SSL");
                 ctx.init(null, new TrustManager[] { new NoValidateCertTrustManager() }, null);
-                config.setSocketFactory(ctx.getSocketFactory());
+                configBuilder.setSocketFactory(ctx.getSocketFactory());
             } catch (GeneralSecurityException ex) {
                 throw new Error(ex);
             }
         }
         
-        return config;
+        return configBuilder.build();
     }
     
     /**

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/Listener.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/Listener.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/Listener.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/Listener.java Sat May 30 08:43:46 2009
@@ -41,10 +41,12 @@
 import javax.swing.table.TableColumn;
 
 import org.apache.ws.commons.tcpmon.TCPMonBundle;
-import org.apache.ws.commons.tcpmon.core.AbstractListener;
-import org.apache.ws.commons.tcpmon.core.Configuration;
-import org.apache.ws.commons.tcpmon.core.IRequestResponse;
-import org.apache.ws.commons.tcpmon.core.SocketWaiter;
+import org.apache.ws.commons.tcpmon.core.engine.Interceptor;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfiguration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfigurationBuilder;
+import org.apache.ws.commons.tcpmon.core.engine.RequestResponseListener;
+import org.apache.ws.commons.tcpmon.core.ui.AbstractListener;
+import org.apache.ws.commons.tcpmon.core.ui.Configuration;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
@@ -132,10 +134,7 @@
      */
     private final JSplitPane outPane;
 
-    /**
-     * Field sw
-     */
-    private SocketWaiter sw = null;
+    private Interceptor interceptor = null;
 
     /**
      * Field leftPanel
@@ -152,7 +151,7 @@
      */
     private JTabbedPane notebook = null;
 
-    private final Configuration baseConfiguration;
+    private final InterceptorConfiguration baseConfiguration;
 
     /**
      * Field connections
@@ -171,7 +170,7 @@
      * @param slowLink   optional reference to a slow connection
      */
     public Listener(JTabbedPane _notebook, String name,
-                    Configuration config) {
+                    InterceptorConfiguration config) {
         notebook = _notebook;
         if (name == null) {
             name = TCPMonBundle.getMessage("port01", "Port") + " " + config.getListenPort();
@@ -427,14 +426,14 @@
      * Method start
      */
     public void start() {
-        if (sw == null) {
-            Configuration config = getConfiguration();
+        if (interceptor == null) {
+            InterceptorConfiguration config = getConfiguration().getInterceptorConfiguration();
             int port = config.getListenPort();
             portField.setText("" + port);
             int i = notebook.indexOfComponent(panel);
             notebook.setTitleAt(i, TCPMonBundle.getMessage("port01", "Port") + " " + port);
             tPortField.setText("" + config.getTargetPort());
-            sw = new SocketWaiter(this, config.getServerSocketFactory(), port);
+            interceptor = new Interceptor(config, this);
             startButton.setSelected(true);
             portField.setEditable(false);
             hostField.setEditable(false);
@@ -447,10 +446,10 @@
      * Method stop
      */
     public void stop() {
-        if (sw != null) {
+        if (interceptor != null) {
             try {
-                sw.halt();
-                sw = null;
+                interceptor.halt();
+                interceptor = null;
                 startButton.setSelected(false);
                 portField.setEditable(true);
                 hostField.setEditable(true);
@@ -568,15 +567,14 @@
     }
 
     public Configuration getConfiguration() {
-        Configuration config = (Configuration)baseConfiguration.clone();
-        config.setListenPort(Integer.parseInt(portField.getText()));
-        config.setTargetHost(hostField.getText());
-        config.setTargetPort(Integer.parseInt(tPortField.getText()));
-        config.setProxy(isProxyBox.isSelected());
+        InterceptorConfigurationBuilder configBuilder = new InterceptorConfigurationBuilder(baseConfiguration);
+        Configuration config = new Configuration();
+        configBuilder.setListenPort(Integer.parseInt(portField.getText()));
+        configBuilder.setTargetHost(hostField.getText());
+        configBuilder.setTargetPort(Integer.parseInt(tPortField.getText()));
+        configBuilder.setProxy(isProxyBox.isSelected());
+        config.setInterceptorConfiguration(configBuilder.build());
         config.setXmlFormat(xmlFormatBox.isSelected());
-        if (config.getHttpProxyHost() == null) {
-            config.configProxyFromSystemProperties();
-        }
         return config;
     }
 
@@ -595,7 +593,7 @@
         stop();
     }
 
-    public IRequestResponse createRequestResponse(String fromHost) {
+    public RequestResponseListener createRequestResponseListener(String fromHost) {
         return new RequestResponse(this, fromHost);
     }
 }

Modified: webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/TCPMon.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/TCPMon.java?rev=780204&r1=780203&r2=780204&view=diff
==============================================================================
--- webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/TCPMon.java (original)
+++ webservices/commons/trunk/modules/tcpmon/modules/tcpmon-ui/src/main/java/org/apache/ws/commons/tcpmon/swing/TCPMon.java Sat May 30 08:43:46 2009
@@ -22,7 +22,7 @@
 import javax.swing.UnsupportedLookAndFeelException;
 
 import org.apache.ws.commons.tcpmon.TCPMonBundle;
-import org.apache.ws.commons.tcpmon.core.Configuration;
+import org.apache.ws.commons.tcpmon.core.engine.InterceptorConfigurationBuilder;
 
 /**
  * Proxy that sniffs and shows HTTP messages and responses, both SOAP and plain HTTP.
@@ -80,29 +80,14 @@
         new AdminPane(notebook, TCPMonBundle.getMessage("admin00", "Admin"));
         if (listenPort != 0) {
             Listener l = null;
-            Configuration config = new Configuration();
-            config.setListenPort(listenPort);
-            config.setTargetHost(targetHost);
-            config.setTargetPort(targetPort);
-            config.setProxy(targetHost == null);
+            InterceptorConfigurationBuilder configBuilder = new InterceptorConfigurationBuilder();
+            configBuilder.setListenPort(listenPort);
+            configBuilder.setTargetHost(targetHost);
+            configBuilder.setTargetPort(targetPort);
+            configBuilder.setProxy(targetHost == null);
+            configBuilder.configProxyFromSystemProperties();
             notebook.setSelectedIndex(0);
-            String HTTPProxyHost = System.getProperty("http.proxyHost");
-            if ((HTTPProxyHost != null) && HTTPProxyHost.equals("")) {
-                HTTPProxyHost = null;
-            }
-            if (HTTPProxyHost != null) {
-                config.setHttpProxyHost(HTTPProxyHost);
-                String tmp = System.getProperty("http.proxyPort");
-                if ((tmp != null) && tmp.equals("")) {
-                    tmp = null;
-                }
-                if (tmp == null) {
-                    config.setHttpProxyPort(80);
-                } else {
-                    config.setHttpProxyPort(Integer.parseInt(tmp));
-                }
-            }
-            new Listener(notebook, null, config);
+            new Listener(notebook, null, configBuilder.build());
         }
         if (!embedded) {
             this.setDefaultCloseOperation(EXIT_ON_CLOSE);