Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse')
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/AcceptThread.java177
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Connection.java50
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ContentFilter.java79
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/FailedConnectionThread.java62
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IContentFilter.java66
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java120
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IProtocolAdapter.java55
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IStartup.java23
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.java30
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.properties21
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Monitor.java346
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java318
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorPlugin.java183
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorWorkingCopy.java133
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapter.java75
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapterDelegate.java86
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/SocketWrapper.java351
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPProtocolAdapter.java49
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPThread.java81
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Trace.java79
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java265
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPConnection.java120
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPProtocolAdapter.java52
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPRequest.java95
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPThread.java726
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPConnection.java36
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPRequest.java148
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/ContentFilterDelegate.java47
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitor.java212
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorListener.java44
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorWorkingCopy.java116
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IRequestListener.java54
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/MonitorCore.java109
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/Request.java349
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.html31
-rw-r--r--plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.xml27
36 files changed, 0 insertions, 4815 deletions
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/AcceptThread.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/AcceptThread.java
deleted file mode 100644
index 69111aa83..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/AcceptThread.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.InterruptedIOException;
-import java.net.*;
-
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-/**
- * The actual TCP/IP monitoring server. This is a thread that
- * listens on a port and relays a call to another server.
- */
-public class AcceptThread {
- protected IMonitor monitor;
-
- protected boolean alive = true;
- protected ServerSocket serverSocket;
-
- protected Thread thread;
-
- class ServerThread extends Thread {
- public ServerThread() {
- super("TCP/IP Monitor");
- }
-
- /**
- * ServerThread accepts incoming connections and delegates to the protocol
- * adapter to deal with the connection.
- */
- public void run() {
- // create a new server socket
- try {
- serverSocket = new ServerSocket(monitor.getLocalPort());
- serverSocket.setSoTimeout(2000);
- Trace.trace(Trace.FINEST, "Monitoring localhost:" + monitor.getLocalPort() + " -> " + monitor.getRemoteHost()
- + ":" + monitor.getRemotePort());
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not start monitoring");
- return;
- }
-
- while (alive) {
- try {
- // accept the connection from the client
- Socket localSocket = serverSocket.accept();
-
- int timeout = monitor.getTimeout();
- if (timeout != 0)
- localSocket.setSoTimeout(timeout);
-
- try {
- // connect to the remote server
- Socket remoteSocket = new Socket();
- if (timeout != 0)
- remoteSocket.setSoTimeout(timeout);
-
- remoteSocket.connect(new InetSocketAddress(monitor.getRemoteHost(), monitor.getRemotePort()), timeout);
-
- // relay the call through
- String protocolId = monitor.getProtocol();
- ProtocolAdapter adapter = MonitorPlugin.getInstance().getProtocolAdapter(protocolId);
- adapter.connect(monitor, localSocket, remoteSocket);
- } catch (SocketTimeoutException e) {
- FailedConnectionThread thread2 = new FailedConnectionThread((Monitor) monitor, localSocket, Messages.errorConnectTimeout);
- thread2.start();
- } catch (Exception e) {
- FailedConnectionThread thread2 = new FailedConnectionThread((Monitor) monitor, localSocket, null);
- thread2.start();
- }
- } catch (InterruptedIOException e) {
- // do nothing
- } catch (Exception e) {
- if (alive)
- Trace.trace(Trace.SEVERE, "Error while monitoring", e);
- }
- }
- }
- }
-
- /**
- * AcceptThread constructor.
- *
- * @param monitor a monitor
- */
- public AcceptThread(IMonitor monitor) {
- super();
- this.monitor = monitor;
- }
-
- /**
- * Start the server.
- */
- public void startServer() {
- if (thread != null)
- return;
- thread = new ServerThread();
- thread.setDaemon(true);
- thread.setPriority(Thread.NORM_PRIORITY + 1);
- thread.start();
-
- Thread.yield();
-
- // wait up to 2 seconds for initialization
- int i = 0;
- while (serverSocket == null && i < 10) {
- try {
- Thread.sleep(200);
- } catch (Exception e) {
- // ignore
- }
- i++;
- }
- }
-
- /**
- * Returns <code>true</code> if the server is running.
- *
- * @return <code>true</code> if the server is running, and <code>false</code>
- * otherwise
- */
- public boolean isRunning() {
- return (thread != null);
- }
-
- /**
- * Correctly close the server socket and shut down the server.
- */
- public void stopServer() {
- try {
- alive = false;
- thread = null;
-
- String protocolId = monitor.getProtocol();
- ProtocolAdapter adapter = MonitorPlugin.getInstance().getProtocolAdapter(protocolId);
- adapter.disconnect(monitor);
- if (serverSocket != null)
- serverSocket.close();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error stopping server", e);
- }
- }
-
- /**
- * Returns true if this port is in use.
- *
- * @return boolean
- * @param port int
- */
- public static boolean isPortInUse(int port) {
- ServerSocket s = null;
- try {
- s = new ServerSocket(port);
- } catch (SocketException e) {
- return true;
- } catch (Exception e) {
- return true;
- } finally {
- if (s != null) {
- try {
- s.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
-
- return false;
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Connection.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Connection.java
deleted file mode 100644
index 086fb3877..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Connection.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.net.Socket;
-/**
- *
- */
-public class Connection {
- protected Socket in;
- protected Socket out;
-
- /**
- * Creates a new connection.
- *
- * @param in inbound socket
- * @param out outbound socket
- */
- public Connection(Socket in, Socket out) {
- this.in = in;
- this.out = out;
- }
-
- /**
- * Close the connection.
- */
- public void close() {
- Trace.trace(Trace.FINEST, "Closing connection");
- try {
- in.getOutputStream().flush();
- in.shutdownInput();
- in.shutdownOutput();
-
- out.getOutputStream().flush();
- out.shutdownInput();
- out.shutdownOutput();
- Trace.trace(Trace.FINEST, "Connection closed");
- } catch (Exception ex) {
- Trace.trace(Trace.WARNING, "Error closing connection " + this, ex);
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ContentFilter.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ContentFilter.java
deleted file mode 100644
index 1ea64ccb1..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ContentFilter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.IOException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.ContentFilterDelegate;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- *
- */
-public class ContentFilter implements IContentFilter {
- protected IConfigurationElement element;
- protected ContentFilterDelegate delegate;
-
- protected ContentFilter(IConfigurationElement element) {
- this.element = element;
- }
-
- /**
- * Return the id.
- *
- * @return the id
- */
- public String getId() {
- return element.getAttribute("id");
- }
-
- /**
- * Returns the relative order for this filter.
- *
- * @return the order
- */
- public int getOrder() {
- try {
- return Integer.parseInt(element.getAttribute("order"));
- } catch (Exception e) {
- return 0;
- }
- }
-
- /**
- * Returns the name.
- *
- * @return the name
- */
- public String getName() {
- return element.getAttribute("name");
- }
-
- /**
- * Do the filtering.
- *
- * @param request the request
- * @param isRequest true if request, false if response
- * @param content the content
- * @return the filtered content
- * @throws IOException if there is a connection problem
- */
- public byte[] filter(Request request, boolean isRequest, byte[] content) throws IOException {
- if (delegate == null) {
- try {
- delegate = (ContentFilterDelegate) element.createExecutableExtension("class");
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not create content filter delegate: " + getId(), e);
- return new byte[0];
- }
- }
- return delegate.filter(request, isRequest, content);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/FailedConnectionThread.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/FailedConnectionThread.java
deleted file mode 100644
index b1d4547fc..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/FailedConnectionThread.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.InputStream;
-import java.net.Socket;
-
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-
-/**
- * Thread used if the connection to the server fails.
- */
-public class FailedConnectionThread extends Thread {
- private static final int BUFFER = 2048;
- protected Monitor monitor;
- protected Socket socket;
- protected String error;
-
- public FailedConnectionThread(Monitor monitor, Socket socket, String error) {
- super();
- this.monitor = monitor;
- this.socket = socket;
- this.error = error;
- }
-
- public void run() {
- Request request = new Request(monitor, IProtocolAdapter.TCPIP_PROTOCOL_ID, monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
- String err = error;
- if (err == null)
- err = Messages.errorConnectToServer;
- request.addToResponse(err.getBytes());
-
- try {
- InputStream in = socket.getInputStream();
- byte[] b = new byte[BUFFER];
- while (in.available() > 0) {
- int n = in.read(b);
- byte[] c = new byte[n];
- System.arraycopy(b, 0, c, 0, n);
- request.addToRequest(c);
- }
- } catch (Exception e) {
- // ignore
- } finally {
- try {
- socket.shutdownInput();
- socket.shutdownOutput();
- socket.close();
- } catch (Exception ex) {
- // ignore
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IContentFilter.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IContentFilter.java
deleted file mode 100644
index 99c7bb4ae..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IContentFilter.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.IOException;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- * A content filter that filters specific contents from the monitor traffic
- * of a request.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface IContentFilter {
- /**
- * Returns the id of this filter.
- * Each filter has a distinct, fixed id. Ids are intended to be used internally as keys;
- * they are not intended to be shown to end users.
- *
- * @return the element id
- */
- public String getId();
-
- /**
- * Returns the displayable (translated) name for this filter.
- *
- * @return a displayable name
- */
- public String getName();
-
- /**
- * Returns the relative order of this filter.
- * Each filter has a relative order that allows them to be applied in the correct
- * order relative to each other. Lower orders are processed first.
- *
- * @return the relative order
- *
- * [issue: CS - The schema (contentFilterns.exsd) defines an 'order' attribute.
- * The comments above suggest that filters should be designed to be composable. Is this correct?
- * It would be good to make this optional if the user had no idea how his filter should be ordered.
- * I've found that sometimes 'low', 'medium', 'high' are adequate to handle ordering issues and are
- * easier for the extension writer deal with and get a sense of the proper value to assign. ]
- */
- //public int getOrder();
-
- /**
- * Filter the given content from the given request. The content that has been filtered out will
- * not be shown to clients of the TCP/IP monitor.
- *
- * @param request the request that the filter will be performed on
- * @param isRequest set to true if the content filter applies to request monitor traffic,
- * or set to false if the content filter applies to the response monitor traffic
- * @param content the message content to be filtered out
- * @return the filtered content
- * @throws IOException if there is an error while parsing or filtering the content
- */
- public byte[] filter(Request request, boolean isRequest, byte[] content) throws IOException;
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java
deleted file mode 100644
index 6be5f28da..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IMemento.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-/**
- * Interface to a memento used for saving the important state of an object
- * in a form that can be persisted in the file system.
- * <p>
- * Mementos were designed with the following requirements in mind:
- * <ol>
- * <li>Certain objects need to be saved and restored across platform sessions.
- * </li>
- * <li>When an object is restored, an appropriate class for an object might not
- * be available. It must be possible to skip an object in this case.</li>
- * <li>When an object is restored, the appropriate class for the object may be
- * different from the one when the object was originally saved. If so, the
- * new class should still be able to read the old form of the data.</li>
- * </ol>
- * </p>
- * <p>
- * Mementos meet these requirements by providing support for storing a
- * mapping of arbitrary string keys to primitive values, and by allowing
- * mementos to have other mementos as children (arranged into a tree).
- * A robust external storage format based on XML is used.
- * </p><p>
- * The key for an attribute may be any alpha numeric value. However, the
- * value of <code>TAG_ID</code> is reserved for internal use.
- * </p><p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface IMemento {
- /**
- * Creates a new child of this memento with the given type.
- * <p>
- * The <code>getChild</code> and <code>getChildren</code> methods
- * are used to retrieve children of a given type.
- * </p>
- *
- * @param type the type
- * @return a new child memento
- * @see #getChild
- * @see #getChildren
- */
- public IMemento createChild(String type);
-
- /**
- * Returns the first child with the given type id.
- *
- * @param type the type id
- * @return the first child with the given type
- */
- public IMemento getChild(String type);
-
- /**
- * Returns all children with the given type id.
- *
- * @param type the type id
- * @return the list of children with the given type
- */
- public IMemento[] getChildren(String type);
-
- /**
- * Returns the integer value of the given key.
- *
- * @param key the key
- * @return the value, or <code>null</code> if the key was not found or was found
- * but was not an integer
- */
- public Integer getInteger(String key);
-
- /**
- * Returns the string value of the given key.
- *
- * @param key the key
- * @return the value, or <code>null</code> if the key was not found or was found
- * but was not an integer
- */
- public String getString(String key);
-
- /**
- * Returns the boolean value of the given key.
- *
- * @param key the key
- * @return the value, or <code>null</code> if the key was not found or was found
- * but was not a boolean
- */
- public Boolean getBoolean(String key);
-
- /**
- * Sets the value of the given key to the given integer.
- *
- * @param key the key
- * @param value the value
- */
- public void putInteger(String key, int value);
-
- /**
- * Sets the value of the given key to the given boolean value.
- *
- * @param key the key
- * @param value the value
- */
- public void putBoolean(String key, boolean value);
-
- /**
- * Sets the value of the given key to the given string.
- *
- * @param key the key
- * @param value the value
- */
- public void putString(String key, String value);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IProtocolAdapter.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IProtocolAdapter.java
deleted file mode 100644
index 63a838b6a..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IProtocolAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-/**
- * A protocol adapter enables a monitor to support a particular network
- * protocol used to communicate between a client and server. All supported
- * protocols will be based on TCP/IP.
- * <p>
- * Protocol adapters are registered via the <code>protocolAdapaters</code>
- * extension point in the <code>org.eclipse.wst.internet.monitor.core</code>
- * plug-in. The global list of known protocol adapters is available via
- * {@link MonitorPlugin#getProtocolAdapters()}. Standard protocol
- * adapters for {@linkplain #HTTP_PROTOCOL_ID HTTP} and
- * {@linkplain #TCPIP_PROTOCOL_ID TCP/IP} are built-in.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface IProtocolAdapter {
- /**
- * Protocol adapter id (value {@value}) for TCP/IP.
- * The TCP/IP protocol adapter is standard.
- */
- public static String TCPIP_PROTOCOL_ID = "TCP/IP";
-
- /**
- * Protocol adapter id (value {@value}) for HTTP.
- * The HTTP protocol adapter is standard.
- */
- public static String HTTP_PROTOCOL_ID = "HTTP";
-
- /**
- * Returns the id of this adapter.
- * Each adapter has a distinct, fixed id. Ids are intended to be used
- * internally as keys; they are not intended to be shown to end users.
- *
- * @return the element id
- */
- public String getId();
-
- /**
- * Returns the displayable (translated) name for this adapter.
- *
- * @return a displayable name
- */
- public String getName();
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IStartup.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IStartup.java
deleted file mode 100644
index d41417009..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/IStartup.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-/**
- * An interface for the startup extension point.
- * Plug-ins that register a startup extension will be activated when the monitor
- * core plug-in initializes and have an opportunity to run code that can't be
- * implemented using the normal contribution mechanisms.
- */
-public interface IStartup {
- /**
- * Will be called on monitor core startup.
- */
- public void startup();
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.java
deleted file mode 100644
index fc4ad45fd..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-/**
- * Translated messages.
- */
-public class Messages extends NLS {
- public static String errorInvalidLocalPort;
- public static String errorInvalidRemotePort;
- public static String errorInvalidRemoteHost;
- public static String errorConnectToServer;
- public static String errorConnectTimeout;
- public static String monitorValid;
- public static String errorPortInUse;
- public static String errorContentSize;
-
- static {
- NLS.initializeMessages(MonitorPlugin.PLUGIN_ID + ".internal.Messages", Messages.class);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.properties b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.properties
deleted file mode 100644
index f39c3f00f..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Messages.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2008 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# --------------- Errors ---------------
-errorPortInUse=The TCP/IP monitor could not start because port {0} is in use.
-errorInvalidLocalPort=The local port number is invalid.
-errorInvalidRemotePort=The remote port number is invalid.
-errorInvalidRemoteHost=The remote host name is invalid.
-errorConnectToServer=Error: Could not connect to server.
-errorConnectTimeout=Error: Timeout connecting to server.
-errorContentSize=The HTTP content is too large to display.
-
-monitorValid=The monitor is valid.
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Monitor.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Monitor.java
deleted file mode 100644
index e4dbc031f..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Monitor.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Tianchao Li (Tianchao.Li@gmail.com) - Start monitors by default
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.*;
-/**
- *
- */
-public class Monitor implements IMonitor {
- private static final String MEMENTO_ID = "id";
- private static final String MEMENTO_LOCAL_PORT = "local-port";
- private static final String MEMENTO_REMOTE_HOST = "remote-host";
- private static final String MEMENTO_REMOTE_PORT = "remote-port";
- private static final String MEMENTO_TYPE_ID = "type-id";
- private static final String MEMENTO_TIMEOUT = "timeout";
- private static final String MEMENTO_AUTO_START = "auto-start";
-
- private static final int ADD = 0;
- private static final int CHANGE = 1;
-
- protected String id;
- protected String remoteHost;
- protected int remotePort = 80;
- protected int localPort = 80;
- protected String protocolId;
- protected int timeout;
- protected boolean autoStart = false;
-
- protected List<IRequestListener> requestListeners = new ArrayList<IRequestListener>(2);
-
- /**
- * Create a new monitor.
- */
- public Monitor() {
- protocolId = MonitorPlugin.getInstance().getDefaultType();
- }
-
- /** (non-Javadoc)
- * @see IMonitor#getId()
- */
- public String getId() {
- return id;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#getRemoteHost()
- */
- public String getRemoteHost() {
- return remoteHost;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#getRemotePort()
- */
- public int getRemotePort() {
- return remotePort;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#getLocalPort()
- */
- public int getLocalPort() {
- return localPort;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#getProtocol()
- */
- public String getProtocol() {
- return protocolId;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#getTimeout()
- */
- public int getTimeout() {
- return timeout;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#isAutoStart()
- */
- public boolean isAutoStart() {
- return autoStart;
- }
-
- /** (non-Javadoc)
- * @see IMonitor#isRunning()
- */
- public boolean isRunning() {
- if (isWorkingCopy())
- return false;
- return MonitorManager.getInstance().isRunning(this);
- }
-
- /**
- * @see IMonitor#delete()
- */
- public void delete() {
- if (isWorkingCopy())
- return;
- MonitorManager.getInstance().removeMonitor(this);
- }
-
- /**
- * @see IMonitor#isWorkingCopy()
- */
- public boolean isWorkingCopy() {
- return false;
- }
-
- /**
- * @see IMonitor#createWorkingCopy()
- */
- public IMonitorWorkingCopy createWorkingCopy() {
- return new MonitorWorkingCopy(this);
- }
-
- protected void setInternal(IMonitor monitor) {
- id = monitor.getId();
- remoteHost = monitor.getRemoteHost();
- remotePort = monitor.getRemotePort();
- localPort = monitor.getLocalPort();
- protocolId = monitor.getProtocol();
- timeout = monitor.getTimeout();
- autoStart = monitor.isAutoStart();
- }
-
- protected void save(IMemento memento) {
- memento.putString(MEMENTO_ID, id);
- memento.putString(MEMENTO_TYPE_ID, protocolId);
- memento.putInteger(MEMENTO_LOCAL_PORT, localPort);
- memento.putString(MEMENTO_REMOTE_HOST, remoteHost);
- memento.putInteger(MEMENTO_REMOTE_PORT, remotePort);
- memento.putInteger(MEMENTO_TIMEOUT, timeout);
- memento.putBoolean(MEMENTO_AUTO_START, autoStart);
- }
-
- protected void load(IMemento memento) {
- id = memento.getString(MEMENTO_ID);
- protocolId = memento.getString(MEMENTO_TYPE_ID);
- Integer temp = memento.getInteger(MEMENTO_LOCAL_PORT);
- if (temp != null)
- localPort = temp.intValue();
- remoteHost = memento.getString(MEMENTO_REMOTE_HOST);
- temp = memento.getInteger(MEMENTO_REMOTE_PORT);
- if (temp != null)
- remotePort = temp.intValue();
- temp = memento.getInteger(MEMENTO_TIMEOUT);
- if (temp != null)
- timeout = temp.intValue();
- Boolean temp2 = memento.getBoolean(MEMENTO_AUTO_START);
- if (temp != null)
- autoStart = temp2.booleanValue();
- }
-
- /**
- * @see IMonitor#start()
- */
- public synchronized void start() throws CoreException {
- if (isRunning())
- return;
- if (isWorkingCopy() || !MonitorManager.getInstance().exists(this))
- throw new IllegalArgumentException();
-
- IStatus status = validate();
- if (!status.isOK())
- throw new CoreException(status);
-
- MonitorManager.getInstance().startMonitor(this);
- }
-
- /**
- * @see IMonitor#start()
- */
- public synchronized void stop() {
- if (isWorkingCopy() || !MonitorManager.getInstance().exists(this))
- throw new IllegalArgumentException();
- if (!isRunning())
- return;
- MonitorManager.getInstance().stopMonitor(this);
- }
-
- /**
- * @see IMonitor#addRequestListener(IRequestListener)
- */
- public synchronized void addRequestListener(IRequestListener listener) {
- if (listener == null)
- throw new IllegalArgumentException();
- if (!requestListeners.contains(listener))
- requestListeners.add(listener);
- }
-
- /**
- * @see IMonitor#removeRequestListener(IRequestListener)
- */
- public synchronized void removeRequestListener(IRequestListener listener) {
- if (listener == null)
- throw new IllegalArgumentException();
- requestListeners.remove(listener);
- }
-
- /**
- * Fire a request event.
- * @param rr
- * @param type
- */
- protected void fireRequestEvent(Request rr, int type) {
- int size = requestListeners.size();
- IRequestListener[] rl = new IRequestListener[size];
- requestListeners.toArray(rl);
-
- for (IRequestListener listener : rl) {
- if (type == ADD)
- listener.requestAdded(this, rr);
- else if (type == CHANGE)
- listener.requestChanged(this, rr);
- }
- }
-
- /**
- * Add a new request response pair.
- *
- * @param request a request
- */
- public void addRequest(Request request) {
- fireRequestEvent(request, ADD);
- }
-
- /**
- * A request response pair has been changed.
- *
- * @param request a request
- */
- public void requestChanged(Request request) {
- fireRequestEvent(request, CHANGE);
- }
-
- /**
- * @see IMonitor#validate()
- */
- public IStatus validate() {
- if (localPort < 0)
- return new Status(IStatus.ERROR, MonitorPlugin.PLUGIN_ID, 0, Messages.errorInvalidLocalPort, null);
-
- if (remotePort < 0)
- return new Status(IStatus.ERROR, MonitorPlugin.PLUGIN_ID, 0, Messages.errorInvalidRemotePort, null);
-
- if (remoteHost == null || remoteHost.length() == 0 || !isValidHostname(remoteHost))
- return new Status(IStatus.ERROR, MonitorPlugin.PLUGIN_ID, 0, Messages.errorInvalidRemoteHost, null);
-
- if (isLocalhost(remoteHost) && localPort == remotePort)
- return new Status(IStatus.ERROR, MonitorPlugin.PLUGIN_ID, 0, Messages.errorInvalidLocalPort, null);
-
- return Status.OK_STATUS;
- }
-
- protected static boolean isValidHostname(String host) {
- if (host == null || host.trim().length() < 1)
- return false;
-
- int length = host.length();
- for (int i = 0; i < length; i++) {
- char c = host.charAt(i);
- if (!Character.isLetterOrDigit(c) && c != ':' && c != '.' && c != '-')
- return false;
- }
- if (host.endsWith(":"))
- return false;
- return true;
- }
-
- protected static boolean isLocalhost(String host) {
- if (host == null)
- return false;
- try {
- if ("localhost".equals(host) || "127.0.0.1".equals(host))
- return true;
- InetAddress localHostaddr = InetAddress.getLocalHost();
- if (localHostaddr.getHostName().equals(host))
- return true;
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Error checking for localhost", e);
- }
- return false;
- }
-
- /**
- * @see Object#toString()
- */
- public String toString() {
- return "Monitor [" + getId() + ", " + getProtocol() + ", " + getLocalPort() + ", "
- + getRemoteHost() + ", " + getRemotePort() + "]";
- }
-
- /**
- * @see Object#equals(Object)
- */
- public boolean equals(Object obj) {
- if (!(obj instanceof Monitor))
- return false;
-
- IMonitor m = (IMonitor) obj;
- if (m.isWorkingCopy()) {
- m = ((IMonitorWorkingCopy) m).getOriginal();
- if (m == null)
- return false;
- }
- if (id == null && m.getId() != null)
- return false;
- if (id != null && !id.equals(m.getId()))
- return false;
-
- if (localPort != m.getLocalPort())
- return false;
- if (remotePort != m.getRemotePort())
- return false;
-
- if (remoteHost == null && m.getRemoteHost() != null)
- return false;
- if (remoteHost != null && !remoteHost.equals(m.getRemoteHost()))
- return false;
-
- if (protocolId == null && m.getProtocol() != null)
- return false;
- if (protocolId != null && !protocolId.equals(m.getProtocol()))
- return false;
-
- return true;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java
deleted file mode 100644
index ba5c55fd2..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorManager.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Tianchao Li (Tianchao.Li@gmail.com) - Start monitors by default
- **********************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.ByteArrayInputStream;
-import java.util.*;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.internet.monitor.core.internal.http.ResendHTTPRequest;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.*;
-/**
- *
- */
-public class MonitorManager {
- private static final int ADD = 0;
- private static final int CHANGE = 1;
- private static final int REMOVE = 2;
-
- // monitors
- protected List<IMonitor> monitors;
- protected Map<IMonitor, AcceptThread> threads = new HashMap<IMonitor, AcceptThread>();
-
- protected List<IMonitorListener> monitorListeners = new ArrayList<IMonitorListener>();
-
- private Preferences.IPropertyChangeListener pcl;
- protected boolean ignorePreferenceChanges = false;
-
- protected Map<Request, List<ResendHTTPRequest>> resendMap = new HashMap<Request, List<ResendHTTPRequest>>();
-
- protected static MonitorManager instance;
-
- static {
- MonitorPlugin.getInstance().executeStartups();
- }
-
- /**
- * Return a static instance.
- *
- * @return the instance
- */
- public static MonitorManager getInstance() {
- if (instance == null) {
- instance = new MonitorManager();
- instance.startMonitors();
- }
-
- return instance;
- }
-
- private MonitorManager() {
- loadMonitors();
-
- pcl = new Preferences.IPropertyChangeListener() {
- public void propertyChange(Preferences.PropertyChangeEvent event) {
- if (ignorePreferenceChanges)
- return;
- String property = event.getProperty();
- if (property.equals("monitors")) {
- loadMonitors();
- }
- }
- };
-
- MonitorPlugin.getInstance().getPluginPreferences().addPropertyChangeListener(pcl);
- }
-
- protected void dispose() {
- MonitorPlugin.getInstance().getPluginPreferences().removePropertyChangeListener(pcl);
- }
-
- /**
- * Create a new monitor.
- *
- * @return the new monitor
- */
- public IMonitorWorkingCopy createMonitor() {
- return new MonitorWorkingCopy();
- }
-
- /**
- * Return the list of monitors.
- *
- * @return the list of monitors
- */
- public List<IMonitor> getMonitors() {
- return new ArrayList<IMonitor>(monitors);
- }
-
- protected synchronized void addMonitor(IMonitor monitor) {
- if (!monitors.contains(monitor))
- monitors.add(monitor);
- fireMonitorEvent(monitor, ADD);
- saveMonitors();
- }
-
- protected boolean isRunning(IMonitor monitor) {
- return (threads.get(monitor) != null);
- }
-
- /**
- * Start a monitor.
- *
- * @param monitor the monitor
- * @throws CoreException
- */
- public void startMonitor(IMonitor monitor) throws CoreException {
- if (!monitors.contains(monitor))
- return;
-
- if (AcceptThread.isPortInUse(monitor.getLocalPort()))
- throw new CoreException(new Status(IStatus.ERROR, MonitorPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPortInUse, monitor.getLocalPort() + ""), null));
-
- AcceptThread thread = new AcceptThread(monitor);
- thread.startServer();
- threads.put(monitor, thread);
- }
-
- /**
- * Stop a monitor.
- *
- * @param monitor the monitor
- */
- public void stopMonitor(IMonitor monitor) {
- if (!monitors.contains(monitor))
- return;
-
- AcceptThread thread = threads.get(monitor);
- if (thread != null) {
- thread.stopServer();
- threads.remove(monitor);
- }
- }
-
- protected synchronized void removeMonitor(IMonitor monitor) {
- if (monitor.isRunning())
- stopMonitor(monitor);
- monitors.remove(monitor);
- fireMonitorEvent(monitor, REMOVE);
- saveMonitors();
- }
-
- protected synchronized void monitorChanged(IMonitor monitor) {
- fireMonitorEvent(monitor, CHANGE);
- saveMonitors();
- }
-
- protected boolean exists(IMonitor monitor) {
- return (monitors.contains(monitor));
- }
-
- /**
- * Add monitor listener.
- *
- * @param listener
- */
- public synchronized void addMonitorListener(IMonitorListener listener) {
- if (!monitorListeners.contains(listener))
- monitorListeners.add(listener);
- }
-
- /**
- * Remove monitor listener.
- *
- * @param listener
- */
- public synchronized void removeMonitorListener(IMonitorListener listener) {
- if (monitorListeners.contains(listener))
- monitorListeners.remove(listener);
- }
-
- /**
- * Fire a monitor event.
- *
- * @param monitor the monitor
- * @param type the type of event
- */
- protected void fireMonitorEvent(IMonitor monitor, int type) {
- IMonitorListener[] obj = monitorListeners.toArray(new IMonitorListener[monitorListeners.size()]);
-
- for (IMonitorListener listener : obj) {
- if (type == ADD)
- listener.monitorAdded(monitor);
- else if (type == CHANGE)
- listener.monitorChanged(monitor);
- else if (type == REMOVE)
- listener.monitorRemoved(monitor);
- }
- }
-
- protected synchronized void loadMonitors() {
- Trace.trace(Trace.FINEST, "Loading monitors");
-
- monitors = new ArrayList<IMonitor>();
- Preferences prefs = MonitorPlugin.getInstance().getPluginPreferences();
- String xmlString = prefs.getString("monitors");
- if (xmlString != null && xmlString.length() > 0) {
- try {
- ByteArrayInputStream in = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
- IMemento memento = XMLMemento.loadMemento(in);
-
- IMemento[] children = memento.getChildren("monitor");
- if (children != null) {
- int size = children.length;
- for (int i = 0; i < size; i++) {
- Monitor monitor = new Monitor();
- monitor.load(children[i]);
- monitors.add(monitor);
- }
- }
- } catch (Exception e) {
- Trace.trace(Trace.WARNING, "Could not load monitors", e);
- }
- }
- }
-
- protected synchronized void saveMonitors() {
- try {
- ignorePreferenceChanges = true;
- XMLMemento memento = XMLMemento.createWriteRoot("monitors");
-
- Iterator iterator = monitors.iterator();
- while (iterator.hasNext()) {
- Monitor monitor = (Monitor) iterator.next();
- IMemento child = memento.createChild("monitor");
- monitor.save(child);
- }
-
- String xmlString = memento.saveToString();
- Preferences prefs = MonitorPlugin.getInstance().getPluginPreferences();
- prefs.setValue("monitors", xmlString);
- MonitorPlugin.getInstance().savePluginPreferences();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not save browsers", e);
- }
- ignorePreferenceChanges = false;
- }
-
- /**
- * Creates a new resend request from the given request.
- *
- * @param request the request that is to be resent; may not be <code>null</code>
- * @return a new resend request
- */
- public static ResendHTTPRequest createResendRequest(Request request) {
- if (request == null)
- throw new IllegalArgumentException();
- return new ResendHTTPRequest((Monitor)request.getMonitor(), request);
- }
-
- /**
- * Adds a resend request to this request.
- *
- * @param request the resend request to add
- * @param resendReq the resend request
- */
- public void addResendRequest(Request request, ResendHTTPRequest resendReq) {
- if (request == null || resendReq == null)
- return;
-
- List<ResendHTTPRequest> list = null;
- try {
- list = resendMap.get(request);
- } catch (Exception e) {
- // ignore
- }
-
- if (list == null) {
- list = new ArrayList<ResendHTTPRequest>();
- resendMap.put(request, list);
- }
- list.add(resendReq);
- }
-
- /**
- * Returns an array of resend requests based on this request.
- *
- * @param request a request
- * @return the array of resend requests based on this request
- */
- public ResendHTTPRequest[] getResendRequests(Request request) {
- List<ResendHTTPRequest> list = resendMap.get(request);
- if (list != null)
- return list.toArray(new ResendHTTPRequest[list.size()]);
-
- return new ResendHTTPRequest[0];
- }
-
- /**
- * Start all monitors that are set to auto-start.
- */
- public synchronized void startMonitors() {
- MonitorManager manager = MonitorManager.getInstance();
- List monitorList = manager.getMonitors();
- Iterator monitorIterator = monitorList.iterator();
- while (monitorIterator.hasNext()) {
- IMonitor monitor = (IMonitor) monitorIterator.next();
- if (monitor.isAutoStart())
- try {
- monitor.start();
- } catch (CoreException e) {
- Trace.trace(Trace.SEVERE, "Failed to start monitor:" + monitor.toString(), e);
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorPlugin.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorPlugin.java
deleted file mode 100644
index 5f79b193b..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorPlugin.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-/**
- * The monitor core plugin.
- */
-public class MonitorPlugin extends Plugin {
- /**
- * The plugin/bundle id.
- */
- public static final String PLUGIN_ID = "org.eclipse.wst.internet.monitor.core";
-
- private static MonitorPlugin singleton;
-
- protected Map<String, ProtocolAdapter> protocolAdapters;
- protected Map<String, IContentFilter> contentFilters;
- protected boolean startupsLoaded;
-
- /**
- * MonitorPlugin constructor comment.
- */
- public MonitorPlugin() {
- super();
- singleton = this;
- loadProtocolAdapters();
- loadContentFilters();
- }
-
- /**
- * Returns the singleton instance of this plugin.
- *
- * @return org.eclipse.wst.internet.monitor.core.MonitorPlugin
- */
- public static MonitorPlugin getInstance() {
- return singleton;
- }
-
- /**
- * Returns the default protocol type.
- *
- * @return the protocol
- */
- public String getDefaultType() {
- return "HTTP";
- }
-
- /**
- * Returns the protocol adapter with the given id, or <code>null</code>
- * if none. This convenience method searches the list of known
- * protocol adapters ({@link #getProtocolAdapters()}) for the one with a
- * matching id.
- *
- * @param id the protocol adapter id; must not be <code>null</code>
- * @return the protocol adapter instance, or <code>null</code> if there
- * is no protocol adapter with the given id
- */
- public ProtocolAdapter getProtocolAdapter(String id) {
- return protocolAdapters.get(id);
- }
-
- /**
- * Returns a list of all known protocol adapter instances.
- * <p>
- * Protocol adapters are registered via the <code>protocolAdapaters</code>
- * extension point in the <code>org.eclipse.wst.internet.monitor.core</code>
- * plug-in.
- * </p>
- * <p>
- * A new array is returned on each call; clients may safely store or modify the result.
- * </p>
- *
- * @return a possibly-empty array of protocol adapter instances
- */
- public ProtocolAdapter[] getProtocolAdapters() {
- List<ProtocolAdapter> list = new ArrayList<ProtocolAdapter>();
- Iterator<ProtocolAdapter> iterator = protocolAdapters.values().iterator();
- while (iterator.hasNext()) {
- list.add(iterator.next());
- }
- ProtocolAdapter[] types = new ProtocolAdapter[list.size()];
- list.toArray(types);
- return types;
- }
-
- /**
- * Return the content filters.
- *
- * @return an array of content filters
- */
- public IContentFilter[] getContentFilters() {
- List<IContentFilter> list = new ArrayList<IContentFilter>();
- Iterator<IContentFilter> iterator = contentFilters.values().iterator();
- while (iterator.hasNext()) {
- list.add(iterator.next());
- }
- IContentFilter[] cf = new IContentFilter[list.size()];
- list.toArray(cf);
- return cf;
- }
-
- /**
- * Find a content filter by the id.
- *
- * @param id an id
- * @return the content filter, or <code>null</code> if it couldn't be found
- */
- public IContentFilter findContentFilter(String id) {
- if (id == null)
- throw new IllegalArgumentException();
- return contentFilters.get(id);
- }
-
- protected synchronized void loadProtocolAdapters() {
- if (protocolAdapters != null)
- return;
- Trace.trace(Trace.CONFIG, "Loading protocol adapters");
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(MonitorPlugin.PLUGIN_ID, "internalProtocolAdapters");
-
- int size = cf.length;
- Map<String, ProtocolAdapter> map = new HashMap<String, ProtocolAdapter>(size);
- for (int i = 0; i < size; i++) {
- String id = cf[i].getAttribute("id");
- Trace.trace(Trace.CONFIG, "Loading adapter: " + id);
- map.put(id, new ProtocolAdapter(cf[i]));
- }
- protocolAdapters = map;
- }
-
- protected synchronized void loadContentFilters() {
- if (contentFilters != null)
- return;
- Trace.trace(Trace.CONFIG, "Loading content filters");
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(MonitorPlugin.PLUGIN_ID, "internalContentFilters");
-
- int size = cf.length;
- Map<String, IContentFilter> map = new HashMap<String, IContentFilter>(size);
- for (int i = 0; i < size; i++) {
- String id = cf[i].getAttribute("id");
- Trace.trace(Trace.CONFIG, "Loading filter: " + id);
- map.put(id, new ContentFilter(cf[i]));
- }
- contentFilters = map;
- }
-
- protected synchronized void executeStartups() {
- if (startupsLoaded)
- return;
-
- Trace.trace(Trace.CONFIG, "Loading startups");
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] cf = registry.getConfigurationElementsFor(MonitorPlugin.PLUGIN_ID, "internalStartup");
-
- int size = cf.length;
- for (int i = 0; i < size; i++) {
- String id = cf[i].getAttribute("id");
- Trace.trace(Trace.CONFIG, "Loading startup: " + id);
- try {
- IStartup startup = (IStartup) cf[i].createExecutableExtension("class");
- try {
- startup.startup();
- } catch (Exception ex) {
- Trace.trace(Trace.SEVERE, "Startup failed" + startup.toString(), ex);
- }
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not create startup: " + id, e);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorWorkingCopy.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorWorkingCopy.java
deleted file mode 100644
index 21527c7a2..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/MonitorWorkingCopy.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Tianchao Li (Tianchao.Li@gmail.com) - Start monitors by default
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitorWorkingCopy;
-/**
- *
- */
-public class MonitorWorkingCopy extends Monitor implements IMonitorWorkingCopy {
- protected Monitor monitor;
-
- /**
- * Create a new monitor working copy. (used for initial creation)
- */
- public MonitorWorkingCopy() {
- // do nothing
- }
-
- /**
- * Create a new monitor working copy. (used for working copies)
- *
- * @param monitor the monitor this working copy is for
- */
- public MonitorWorkingCopy(Monitor monitor) {
- this.monitor = monitor;
- setInternal(monitor);
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#getOriginal()
- */
- public IMonitor getOriginal() {
- return monitor;
- }
-
- /**
- * Set the id.
- *
- * @param newId the id
- */
- public void setId(String newId) {
- id = newId;
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#setRemoteHost(String)
- */
- public void setRemoteHost(String host) {
- remoteHost = host;
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#setRemotePort(int)
- */
- public void setRemotePort(int port) {
- remotePort = port;
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#setLocalPort(int)
- */
- public void setLocalPort(int port) {
- localPort = port;
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#setProtocol(String)
- */
- public void setProtocol(String protocolId2) {
- protocolId = protocolId2;
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#setTimeout(int)
- */
- public void setTimeout(int timeout2) {
- timeout = timeout2;
- }
-
- /** (non-Javadoc)
- * @see IMonitorWorkingCopy#setAutoStart(boolean)
- */
- public void setAutoStart(boolean startByDefault) {
- autoStart = startByDefault;
- }
-
- /**
- * @see IMonitor#isWorkingCopy()
- */
- public boolean isWorkingCopy() {
- return true;
- }
-
- /**
- * @see IMonitor#createWorkingCopy()
- */
- public IMonitorWorkingCopy createWorkingCopy() {
- return this;
- }
-
- /**
- * @see IMonitorWorkingCopy#save()
- */
- public synchronized IMonitor save() {
- MonitorManager mm = MonitorManager.getInstance();
- if (monitor != null) {
- //boolean restart = false;
- if (monitor.isRunning()) {
- //restart = true;
- mm.stopMonitor(monitor);
- }
- monitor.setInternal(this);
- mm.monitorChanged(monitor);
- //if (restart)
- // mm.startMonitor(monitor);
- } else {
- monitor = new Monitor();
- monitor.setInternal(this);
- mm.addMonitor(monitor);
- }
- return monitor;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapter.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapter.java
deleted file mode 100644
index 44f8c0e71..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.IOException;
-import java.net.Socket;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-/**
- *
- */
-public class ProtocolAdapter implements IProtocolAdapter {
- protected IConfigurationElement element;
- protected ProtocolAdapterDelegate delegate;
-
- protected ProtocolAdapter(IConfigurationElement element) {
- this.element = element;
- }
-
- /**
- * @see IProtocolAdapter#getId()
- */
- public String getId() {
- return element.getAttribute("id");
- }
-
- /**
- * @see IProtocolAdapter#getName()
- */
- public String getName() {
- return element.getAttribute("name");
- }
-
- protected ProtocolAdapterDelegate getDelegate() {
- if (delegate != null)
- return delegate;
-
- try {
- delegate = (ProtocolAdapterDelegate) element.createExecutableExtension("class");
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not create protocol adapter delegate: " + getId(), e);
- }
- return delegate;
- }
-
- /**
- * Connect with the protocol.
- *
- * @param monitor a monitor
- * @param in an inbound socket
- * @param out an outbound socket
- * @throws IOException
- */
- public void connect(IMonitor monitor, Socket in, Socket out) throws IOException {
- getDelegate().connect(monitor, in, out);
- }
-
- /**
- * Disconnect from the sockets.
- *
- * @param monitor a monitor
- * @throws IOException
- */
- public void disconnect(IMonitor monitor) throws IOException {
- getDelegate().disconnect(monitor);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapterDelegate.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapterDelegate.java
deleted file mode 100644
index a07cd3dd2..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/ProtocolAdapterDelegate.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.IOException;
-import java.net.Socket;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-/**
- * Abstract base class for protocol adapter delegates, which provide the
- * implementation behind a particular protocol adapter.
- * A protocol adapter watches the message traffic passing between client and
- * server; it parses the messages and reports them in the form of
- * Request objects.
- * <p>
- * This abstract class is intended to be subclassed only by clients
- * to extend the <code>protocolAdapters</code> extension point.
- * The subclass must have a public 0-argument constructor, which will be used
- * automatically to instantiate the delegate when required.
- * </p>
- * <p>
- * There is only one delegate created per protocol, and this delegate must
- * be able to handle multiple monitor instances. This means that the delegate
- * typically will not have instance state, or must synchronize and keep the
- * state separate.
- * </p>
- * <p>
- * [issue: The HTTP and TCP/IP delegate implementations create threads which
- * shuffle info between sockets. If the monitor is changed or deleted, how do
- * these threads go away? Methinks that delegates in general should be forced
- * to implement disconnect(IMonitor) as well. This method would be called by the
- * system when the monitor is changed or deleted, or when the plug-in is
- * being shut down.]
- * </p>
- */
-public abstract class ProtocolAdapterDelegate {
- /**
- * Establishes an ongoing connection between client and server being
- * monitored by the given monitor. The <code>in</code> socket is associated
- * with the monitor's client. The <code>out</code> socket is associated with
- * the monitor's server. Different adapaters handle different network
- * protocols.
- * <p>
- * Subclasses must implement this method to achieve the following:
- * <ul>
- * <li>Client to server communication -
- * Opening an input stream on the <code>in</code> socket, opening an output
- * stream on the <code>out</code> socket, and establishing a mechanism that
- * will pass along all bytes received on the input stream to the output
- * stream.</li>
- * <li>Server to client communication - Opening an input stream on the
- * <code>out</code> socket, opening an output stream on the <code>in</code>
- * socket, and establishing a mechanism that will pass along all bytes
- * received on the input stream to the output stream.</li>
- * <li>Parsing the protocol-specific message traffic to create and report
- * request objects for each message passed between client and server.</li>
- * <li>Closing the input and output sockets and otherwise cleaning up
- * afterwards.</li>
- * </ul>
- * </p>
- *
- * @param monitor the monitor that uses this protocol adapter
- * @param in the input socket of the monitor client
- * @param out the output socket of the monitor server
- * @throws IOException if an exception occur when opening the streams of the
- * input or output sockets
- */
- public abstract void connect(IMonitor monitor, Socket in, Socket out) throws IOException;
-
- /**
- * Called if the monitor is changed or deleted, or the plugin is shutting down.
- * The delegate must clean up the connections and threads created to respond to
- * this monitor.
- *
- * @param monitor
- * @throws IOException
- */
- public abstract void disconnect(IMonitor monitor) throws IOException;
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/SocketWrapper.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/SocketWrapper.java
deleted file mode 100644
index 62b4dd9d3..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/SocketWrapper.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.nio.channels.SocketChannel;
-/**
- * A socket that is only used for resending requests. All input operations are
- * ignored.
- */
-public class SocketWrapper extends Socket {
- private InputStream inputStream;
- private OutputStream outputStream;
-
- /**
- * Create a new socket wrapper.
- *
- * @param inputStream
- */
- public SocketWrapper(InputStream inputStream) {
- this.inputStream = inputStream;
- this.outputStream = new DummyOutputStream();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#bind(java.net.SocketAddress)
- */
- public void bind(SocketAddress arg0) throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#close()
- */
- public synchronized void close() throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#connect(java.net.SocketAddress, int)
- */
- public void connect(SocketAddress arg0, int arg1) throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#connect(java.net.SocketAddress)
- */
- public void connect(SocketAddress arg0) throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getChannel()
- */
- public SocketChannel getChannel() {
- return super.getChannel();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getInetAddress()
- */
- public InetAddress getInetAddress() {
- return super.getInetAddress();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getInputStream()
- */
- public InputStream getInputStream() throws IOException {
- return inputStream;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getKeepAlive()
- */
- public boolean getKeepAlive() throws SocketException {
- return false;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getLocalAddress()
- */
- public InetAddress getLocalAddress() {
- return super.getLocalAddress();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getLocalPort()
- */
- public int getLocalPort() {
- return super.getLocalPort();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getLocalSocketAddress()
- */
- public SocketAddress getLocalSocketAddress() {
- return super.getLocalSocketAddress();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getOOBInline()
- */
- public boolean getOOBInline() throws SocketException {
- return super.getOOBInline();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getOutputStream()
- */
- public OutputStream getOutputStream() throws IOException {
- return outputStream;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getPort()
- */
- public int getPort() {
- return super.getPort();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getReceiveBufferSize()
- */
- public synchronized int getReceiveBufferSize() throws SocketException {
- return super.getReceiveBufferSize();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getRemoteSocketAddress()
- */
- public SocketAddress getRemoteSocketAddress() {
- return super.getRemoteSocketAddress();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getReuseAddress()
- */
- public boolean getReuseAddress() throws SocketException {
- return super.getReuseAddress();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getSendBufferSize()
- */
- public synchronized int getSendBufferSize() throws SocketException {
- return super.getSendBufferSize();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getSoLinger()
- */
- public int getSoLinger() throws SocketException {
- return super.getSoLinger();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getSoTimeout()
- */
- public synchronized int getSoTimeout() throws SocketException {
- return super.getSoTimeout();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getTcpNoDelay()
- */
- public boolean getTcpNoDelay() throws SocketException {
- return super.getTcpNoDelay();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#getTrafficClass()
- */
- public int getTrafficClass() throws SocketException {
- return super.getTrafficClass();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#isBound()
- */
- public boolean isBound() {
- return super.isBound();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#isClosed()
- */
- public boolean isClosed() {
- return false;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#isConnected()
- */
- public boolean isConnected() {
- return true;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#isInputShutdown()
- */
- public boolean isInputShutdown() {
- return false;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#isOutputShutdown()
- */
- public boolean isOutputShutdown() {
- return false;
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#sendUrgentData(int)
- */
- public void sendUrgentData(int arg0) throws IOException {
- super.sendUrgentData(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setKeepAlive(boolean)
- */
- public void setKeepAlive(boolean arg0) throws SocketException {
- super.setKeepAlive(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setOOBInline(boolean)
- */
- public void setOOBInline(boolean arg0) throws SocketException {
- super.setOOBInline(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setReceiveBufferSize(int)
- */
- public synchronized void setReceiveBufferSize(int arg0) throws SocketException {
- super.setReceiveBufferSize(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setReuseAddress(boolean)
- */
- public void setReuseAddress(boolean arg0) throws SocketException {
- super.setReuseAddress(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setSendBufferSize(int)
- */
- public synchronized void setSendBufferSize(int arg0) throws SocketException {
- super.setSendBufferSize(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setSoLinger(boolean, int)
- */
- public void setSoLinger(boolean arg0, int arg1) throws SocketException {
- super.setSoLinger(arg0, arg1);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setSoTimeout(int)
- */
- public synchronized void setSoTimeout(int arg0) throws SocketException {
- super.setSoTimeout(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setTcpNoDelay(boolean)
- */
- public void setTcpNoDelay(boolean arg0) throws SocketException {
- super.setTcpNoDelay(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#setTrafficClass(int)
- */
- public void setTrafficClass(int arg0) throws SocketException {
- super.setTrafficClass(arg0);
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#shutdownInput()
- */
- public void shutdownInput() throws IOException {
- inputStream.close();
- }
-
- /** (non-Javadoc)
- * @see java.net.Socket#shutdownOutput()
- */
- public void shutdownOutput() throws IOException {
- // do nothing
- }
-
- /**
- * A dummy OutputStream that allows us to fake output for a socket.
- */
- public class DummyOutputStream extends OutputStream {
- /** (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- public void close() throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- public void flush() throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write(byte[] arg0, int arg1, int arg2) throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.io.OutputStream#write(byte[])
- */
- public void write(byte[] arg0) throws IOException {
- // do nothing
- }
-
- /** (non-Javadoc)
- * @see java.io.OutputStream#write(int)
- */
- public void write(int arg0) throws IOException {
- // do nothing
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPProtocolAdapter.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPProtocolAdapter.java
deleted file mode 100644
index 8ca4ec827..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPProtocolAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- *
- */
-public class TCPIPProtocolAdapter extends ProtocolAdapterDelegate {
- protected Map<IMonitor, Connection> map = new HashMap<IMonitor, Connection>();
-
- /**
- * @see ProtocolAdapterDelegate#connect(IMonitor, Socket, Socket)
- */
- public void connect(IMonitor monitor, Socket in, Socket out) throws IOException {
- Request request = new Request((Monitor) monitor, IProtocolAdapter.TCPIP_PROTOCOL_ID, monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
- Connection conn = new Connection(in, out);
- map.put(monitor, conn);
- TCPIPThread requestThread = new TCPIPThread(conn, request, in.getInputStream(), out.getOutputStream(), true);
- requestThread.start();
- new TCPIPThread(conn, request, out.getInputStream(), in.getOutputStream(), false).start();
- }
-
- /**
- * @see ProtocolAdapterDelegate#disconnect(IMonitor)
- */
- public void disconnect(IMonitor monitor) throws IOException {
- try {
- Connection conn = map.get(monitor);
- conn.close();
- } catch (Exception e) {
- // ignore
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPThread.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPThread.java
deleted file mode 100644
index 234de8529..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/TCPIPThread.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.*;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- * Monitor server I/O thread.
- */
-public class TCPIPThread extends Thread {
- private static final int BUFFER = 2048;
- protected InputStream in;
- protected OutputStream out;
- protected boolean isRequest;
-
- protected Connection conn;
- protected Request request;
-
- /**
- * Create a new TCP/IP thread.
- *
- * @param conn
- * @param request
- * @param in
- * @param out
- * @param isRequest
- */
- public TCPIPThread(Connection conn, Request request, InputStream in, OutputStream out, boolean isRequest) {
- super("TCP/IP Monitor TCP/IP Connection");
- this.conn = conn;
- this.request = request;
- this.in = in;
- this.out = out;
- this.isRequest = isRequest;
- setPriority(Thread.NORM_PRIORITY + 1);
- setDaemon(true);
- }
-
- /**
- * Listen for input, save it, and pass to the output stream.
- */
- public void run() {
- try {
- byte[] b = new byte[BUFFER];
- int n = in.read(b);
- while (n > 0) {
- out.write(b, 0, n);
- if (b != null && n > 0) {
- byte[] x = null;
- if (n == BUFFER)
- x = b;
- else {
- x = new byte[n];
- System.arraycopy(b, 0, x, 0, n);
- }
- if (isRequest)
- request.addToRequest(x);
- else
- request.addToResponse(x);
- }
- n = in.read(b);
- Thread.yield();
- }
- out.flush();
- } catch (IOException e) {
- // ignore
- } finally {
- //request.fireChangedEvent();
- if (!isRequest)
- conn.close();
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Trace.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Trace.java
deleted file mode 100644
index e48ab968a..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/Trace.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-/**
- * Helper class to route trace output.
- */
-public class Trace {
- /**
- * Config trace event.
- */
- public static final byte CONFIG = 0;
-
- /**
- * Warning trace event.
- */
- public static final byte WARNING = 1;
-
- /**
- * Severe trace event.
- */
- public static final byte SEVERE = 2;
-
- /**
- * Finest trace event.
- */
- public static final byte FINEST = 3;
-
- /**
- * Parsing trace event.
- */
- public static final byte PARSING = 4;
-
- /**
- * Trace constructor comment.
- */
- private Trace() {
- super();
- }
-
- /**
- * Trace the given text.
- *
- * @param level the trace level
- * @param s a message
- */
- public static void trace(byte level, String s) {
- trace(level, s, null);
- }
-
- /**
- * Trace the given message and exception.
- *
- * @param level the trace level
- * @param s a message
- * @param t a throwable
- */
- public static void trace(byte level, String s, Throwable t) {
- if (level == SEVERE)
- MonitorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, MonitorPlugin.PLUGIN_ID, s, t));
-
- if (!MonitorPlugin.getInstance().isDebugging())
- return;
-
- System.out.println(MonitorPlugin.PLUGIN_ID + " " + System.currentTimeMillis() + " thread=["+Thread.currentThread().getId() +"]" + s);
- if (t != null)
- t.printStackTrace();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
deleted file mode 100644
index 8cbf23149..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/XMLMemento.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal;
-
-import java.io.*;
-import java.util.*;
-import org.w3c.dom.*;
-import org.xml.sax.*;
-
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-/**
- * A Memento is a class independent container for persistence
- * info. It is a reflection of 3 storage requirements.
- *
- * 1) We need the ability to persist an object and restore it.
- * 2) The class for an object may be absent. If so we would
- * like to skip the object and keep reading.
- * 3) The class for an object may change. If so the new class
- * should be able to read the old persistence info.
- *
- * We could ask the objects to serialize themselves into an
- * ObjectOutputStream, DataOutputStream, or Hashtable. However
- * all of these approaches fail to meet the second requirement.
- *
- * Memento supports binary persistence with a version ID.
- */
-public final class XMLMemento implements IMemento {
- private Document factory;
- private Element element;
-
- /**
- * Answer a memento for the document and element. For simplicity
- * you should use createReadRoot and createWriteRoot to create the initial
- * mementos on a document.
- */
- private XMLMemento(Document doc, Element el) {
- factory = doc;
- element = el;
- }
-
- /**
- * @see IMemento#createChild(String)
- */
- public IMemento createChild(String type) {
- Element child = factory.createElement(type);
- element.appendChild(child);
- return new XMLMemento(factory, child);
- }
-
- /**
- * Create a Document from a Reader and answer a root memento for reading
- * a document.
- */
- private static XMLMemento createReadRoot(InputStream in) {
- Document document = null;
- try {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder parser = factory.newDocumentBuilder();
- document = parser.parse(new InputSource(in));
- Node node = document.getFirstChild();
- if (node instanceof Element)
- return new XMLMemento(document, (Element) node);
- } catch (ParserConfigurationException e) {
- // ignore
- } catch (IOException e) {
- // ignore
- } catch (SAXException e) {
- // ignore
- } finally {
- try {
- in.close();
- } catch (Exception e) {
- // ignore
- }
- }
- return null;
- }
-
- /**
- * Answer a root memento for writing a document.
- *
- * @param type
- * @return a memento
- */
- public static XMLMemento createWriteRoot(String type) {
- Document document;
- try {
- document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- Element element = document.createElement(type);
- document.appendChild(element);
- return new XMLMemento(document, element);
- } catch (ParserConfigurationException e) {
- throw new Error(e);
- }
- }
-
- /**
- * @see IMemento#getChild(String)
- */
- public IMemento getChild(String type) {
- // Get the nodes.
- NodeList nodes = element.getChildNodes();
- int size = nodes.getLength();
- if (size == 0)
- return null;
-
- // Find the first node which is a child of this node.
- for (int nX = 0; nX < size; nX ++) {
- Node node = nodes.item(nX);
- if (node instanceof Element) {
- Element element2 = (Element)node;
- if (element2.getNodeName().equals(type))
- return new XMLMemento(factory, element2);
- }
- }
-
- // A child was not found.
- return null;
- }
-
- /**
- * @see IMemento#getChildren(String)
- */
- public IMemento [] getChildren(String type) {
- // Get the nodes.
- NodeList nodes = element.getChildNodes();
- int size = nodes.getLength();
- if (size == 0)
- return new IMemento[0];
-
- // Extract each node with given type.
- List<Element> list = new ArrayList<Element>(size);
- for (int nX = 0; nX < size; nX ++) {
- Node node = nodes.item(nX);
- if (node instanceof Element) {
- Element element2 = (Element)node;
- if (element2.getNodeName().equals(type))
- list.add(element2);
- }
- }
-
- // Create a memento for each node.
- size = list.size();
- IMemento [] results = new IMemento[size];
- for (int x = 0; x < size; x ++) {
- results[x] = new XMLMemento(factory, list.get(x));
- }
- return results;
- }
-
- /**
- * @see IMemento#getInteger(String)
- */
- public Integer getInteger(String key) {
- Attr attr = element.getAttributeNode(key);
- if (attr == null)
- return null;
- String strValue = attr.getValue();
- try {
- return new Integer(strValue);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- /**
- * @see IMemento#getString(String)
- */
- public String getString(String key) {
- Attr attr = element.getAttributeNode(key);
- if (attr == null)
- return null;
- return attr.getValue();
- }
-
- /**
- * Loads a memento from the given filename.
- *
- * @param in the input stream
- * @return a memento
- */
- public static IMemento loadMemento(InputStream in) {
- return createReadRoot(in);
- }
-
- /**
- * @see IMemento#putInteger(String, int)
- */
- public void putInteger(String key, int n) {
- element.setAttribute(key, String.valueOf(n));
- }
-
- /**
- * @see IMemento#putString(String, String)
- */
- public void putString(String key, String value) {
- if (value == null)
- return;
- element.setAttribute(key, value);
- }
-
- /**
- * Save this Memento to an output stream.
- *
- * @param os
- * @throws IOException
- */
- private void save(OutputStream os) throws IOException {
- Result result = new StreamResult(os);
- Source source = new DOMSource(factory);
- try {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
- transformer.transform(source, result);
- } catch (Exception e) {
- throw (IOException) (new IOException().initCause(e));
- }
- }
-
- /**
- * Save to string.
- *
- * @return the string
- * @throws IOException
- */
- public String saveToString() throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- save(out);
- return out.toString("UTF-8");
- }
-
- /**
- * @see IMemento#getBoolean(String)
- */
- public Boolean getBoolean(String key) {
- Attr attr = element.getAttributeNode(key);
- if (attr == null)
- return null;
- String strValue = attr.getValue();
- if ("true".equalsIgnoreCase(strValue))
- return new Boolean(true);
-
- return new Boolean(false);
- }
-
- /**
- * @see IMemento#putBoolean(String, boolean)
- */
- public void putBoolean(String key, boolean value) {
- element.setAttribute(key, value ? "true" : "false");
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPConnection.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPConnection.java
deleted file mode 100644
index 02cb85d42..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPConnection.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.http;
-
-import org.eclipse.wst.internet.monitor.core.internal.Monitor;
-import org.eclipse.wst.internet.monitor.core.internal.Trace;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-
-import java.util.List;
-import java.util.ArrayList;
-/**
- * Manages a monitor server connection between two hosts. This
- * connection may spawn one or more TCP/IP requests to be displayed
- * in the monitor server view.
- */
-public class HTTPConnection {
- protected IMonitor monitor;
-
- protected int req = -1;
- protected int resp = -1;
-
- protected List<Request> requests = new ArrayList<Request>();
-
- /**
- * HTTPConnection constructor comment.
- *
- * @param monitor a monitor
- */
- public HTTPConnection(IMonitor monitor) {
- super();
- this.monitor = monitor;
- Trace.trace(Trace.PARSING, "TCP/IP monitor connection opened " + monitor);
- }
-
- /**
- * Add a request.
- *
- * @param b the request data
- * @param isNew true if new
- */
- public void addRequest(byte[] b, boolean isNew) {
- if (isNew)
- req ++;
- HTTPRequest request = (HTTPRequest) getRequestResponse(req);
- request.addToRequest(b);
- }
-
- /**
- * Add a response.
- *
- * @param b the response data
- * @param isNew true if new
- */
- public void addResponse(byte[] b, boolean isNew) {
- if (isNew)
- resp ++;
- HTTPRequest request = (HTTPRequest) getRequestResponse(resp);
- request.addToResponse(b);
- }
-
- /**
- * Add a property.
- *
- * @param key
- * @param value
- */
- public void addProperty(String key, Object value) {
- Request request = getRequestResponse(req);
- request.setProperty(key, value);
- }
-
- /**
- * Get the request.
- *
- * @param isRequest
- * @return the request
- */
- public Request getRequestResponse(boolean isRequest) {
- if (isRequest)
- return getRequestResponse(req);
-
- return getRequestResponse(resp);
- }
-
- /**
- *
- */
- protected Request getRequestResponse(int i) {
- synchronized (this) {
- while (i >= requests.size()) {
- Request request = new HTTPRequest((Monitor) monitor, monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
- requests.add(request);
- return request;
- }
- return requests.get(i);
- }
- }
-
- /**
- * Set the title.
- *
- * @param title the title
- * @param isNew boolean
- */
- public void setLabel(String title, boolean isNew) {
- if (isNew)
- req ++;
- HTTPRequest request = (HTTPRequest) getRequestResponse(req);
- request.setName(title);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPProtocolAdapter.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPProtocolAdapter.java
deleted file mode 100644
index 7c24cfedb..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPProtocolAdapter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.http;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.internet.monitor.core.internal.Connection;
-import org.eclipse.wst.internet.monitor.core.internal.ProtocolAdapterDelegate;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.IMonitor;
-/**
- *
- */
-public class HTTPProtocolAdapter extends ProtocolAdapterDelegate {
- protected Map<IMonitor, Connection> map = new HashMap<IMonitor, Connection>();
-
- /**
- * @see ProtocolAdapterDelegate#connect(IMonitor, Socket, Socket)
- */
- public void connect(IMonitor monitor, Socket in, Socket out) throws IOException {
- Connection conn2 = new Connection(in, out);
- map.put(monitor, conn2);
- HTTPConnection conn = new HTTPConnection(monitor);
- HTTPThread request = new HTTPThread(conn2, in.getInputStream(), out.getOutputStream(), conn, true, monitor.getRemoteHost(), monitor.getRemotePort());
- HTTPThread response = new HTTPThread(conn2, out.getInputStream(), in.getOutputStream(), conn, false, "localhost", monitor.getLocalPort(), request);
- request.start();
- response.start();
- }
-
- /**
- * @see ProtocolAdapterDelegate#disconnect(IMonitor)
- */
- public void disconnect(IMonitor monitor) throws IOException {
- try {
- Connection conn = map.get(monitor);
- if (conn != null)
- conn.close();
- } catch (Exception e) {
- // ignore
- }
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPRequest.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPRequest.java
deleted file mode 100644
index 83e1655b2..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPRequest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.http;
-
-import org.eclipse.wst.internet.monitor.core.internal.IProtocolAdapter;
-import org.eclipse.wst.internet.monitor.core.internal.Monitor;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- *
- */
-public class HTTPRequest extends Request {
- protected static final String HTTP_REQUEST_HEADER = "request-header";
- protected static final String HTTP_RESPONSE_HEADER = "response-header";
-
- protected static final String HTTP_REQUEST_BODY = "request-body";
- protected static final String HTTP_RESPONSE_BODY = "response-body";
-
- protected static final byte[] EMPTY = new byte[0];
-
- /**
- * Create an HTTPRequest.
- *
- * @param monitor
- * @param localPort
- * @param remoteHost
- * @param remotePort
- */
- public HTTPRequest(Monitor monitor, int localPort, String remoteHost, int remotePort) {
- super(monitor, IProtocolAdapter.HTTP_PROTOCOL_ID, localPort, remoteHost, remotePort);
- }
-
- /**
- * @see Request#getRequest(int)
- */
- public byte[] getRequest(int type2) {
- if (type2 == ALL)
- return request;
- else if (type2 == TRANSPORT)
- return getRequestHeader();
- else
- return getRequestContent();
- }
-
- /**
- * @see Request#getResponse(int)
- */
- public byte[] getResponse(int type2) {
- if (type2 == ALL)
- return response;
- else if (type2 == TRANSPORT)
- return getResponseHeader();
- else
- return getResponseContent();
- }
-
- protected byte[] getRequestHeader() {
- Object obj = getProperty(HTTP_REQUEST_HEADER);
- if (obj == null || !(obj instanceof byte[]))
- return null;
- return (byte[]) obj;
- }
-
- protected byte[] getRequestContent() {
- Object obj = getProperty(HTTP_REQUEST_BODY);
- if (obj == null || !(obj instanceof byte[]))
- return null;
- return (byte[]) obj;
- }
-
- protected byte[] getResponseHeader() {
- Object obj = getProperty(HTTP_RESPONSE_HEADER);
- if (obj == null || !(obj instanceof byte[]))
- return null;
- return (byte[]) obj;
- }
-
- protected byte[] getResponseContent() {
- Object obj = getProperty(HTTP_RESPONSE_BODY);
- if (obj == null || !(obj instanceof byte[]))
- return null;
- return (byte[]) obj;
- }
-
- protected void setName(String n) {
- super.setName(n);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPThread.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPThread.java
deleted file mode 100644
index 8e61092a6..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/HTTPThread.java
+++ /dev/null
@@ -1,726 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.http;
-
-import java.io.*;
-import org.eclipse.wst.internet.monitor.core.internal.Connection;
-import org.eclipse.wst.internet.monitor.core.internal.Messages;
-import org.eclipse.wst.internet.monitor.core.internal.Trace;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- * Monitor server I/O thread.
- */
-public class HTTPThread extends Thread {
- private static final int BUFFER = 2048;
- private static final byte CR = (byte) '\r';
- private static final byte LF = (byte) '\n';
- protected static int threadCount = 0;
-
- private byte[] readBuffer = new byte[BUFFER];
-
- // buffer and index
- protected byte[] buffer = new byte[0];
- protected int bufferIndex = 0;
-
- protected InputStream in;
- protected OutputStream out;
- protected HTTPConnection conn;
- protected boolean isRequest;
- protected Connection conn2;
-
- protected HTTPThread request;
- protected boolean isWaiting;
-
- // user to translate the Host: header
- protected String host;
- protected int port;
-
- protected int contentLength = -1;
- protected byte transferEncoding = -1;
- protected String responseType = null;
- protected boolean connectionKeepAlive = false;
- protected boolean connectionClose = false;
-
- protected static final String[] ENCODING_STRING = new String[] {
- "chunked", "identity", "gzip", "compressed", "deflate"};
-
- protected static final byte ENCODING_CHUNKED = 0;
- protected static final byte ENCODING_IDENTITY = 1;
- protected static final byte ENCODING_GZIP = 2;
- protected static final byte ENCODING_COMPRESSED = 3;
- protected static final byte ENCODING_DEFLATE = 4;
-
-/* change:
-Referer: http://localhost:8081/index.html
-Host: localhost:8081
-*/
-/* The Connection header has the following grammar:
-
- Connection = "Connection" ":" 1#(connection-token)
- connection-token = token
-
- HTTP/1.1 proxies MUST parse the Connection header field before a
- message is forwarded and, for each connection-token in this field,
- remove any header field(s) from the message with the same name as the
- connection-token. */
-
- /**
- * Create a new HTTP thread.
- *
- * @param conn2
- * @param in
- * @param out
- * @param conn
- * @param isRequest
- * @param host
- * @param port
- */
- public HTTPThread(Connection conn2, InputStream in, OutputStream out, HTTPConnection conn, boolean isRequest, String host, int port) {
- super("TCP/IP Monitor HTTP Connection");
- this.conn2 = conn2;
- this.in = in;
- this.out = out;
- this.conn = conn;
- this.isRequest = isRequest;
- this.host = host;
- this.port = port;
-
- setName("HTTP (" + host + ":" + port + ") " + (isRequest ? "REQUEST" : "RESPONSE") + " " + (threadCount++));
- setPriority(Thread.NORM_PRIORITY + 1);
- setDaemon(true);
-
- Trace.trace(Trace.PARSING, "Started: " + this);
- }
-
- /**
- * Create a new HTTP thread.
- *
- * @param conn2
- * @param in
- * @param out
- * @param conn
- * @param isRequest
- * @param host
- * @param port
- * @param request
- */
- public HTTPThread(Connection conn2, InputStream in, OutputStream out, HTTPConnection conn, boolean isRequest, String host, int port, HTTPThread request) {
- this(conn2, in, out, conn, isRequest, host, port);
-
- this.request = request;
- }
-
- /**
- * Add a line feed to the end of the byte array.
- * @return byte[]
- * @param b byte[]
- */
- protected static byte[] convert(byte[] b) {
- if (b == null || b.length == 0)
- return b;
-
- int size = b.length;
- byte[] x = new byte[size + 2];
- System.arraycopy(b, 0, x, 0, size);
- x[size] = (byte) '\r'; // CR
- x[size + 1] = (byte) '\n'; // LF
- return x;
- }
-
- /**
- * Read more data into the buffer.
- */
- protected void fillBuffer() throws IOException {
- int n = in.read(readBuffer);
-
- if (n <= 0)
- throw new IOException("End of input");
-
- // add to full buffer
- int len = buffer.length - bufferIndex;
- if (len < 0)
- len = 0;
- byte[] x = new byte[n + len];
- System.arraycopy(buffer, bufferIndex, x, 0, len);
- System.arraycopy(readBuffer, 0, x, len, n);
- bufferIndex = 0;
- buffer = x;
- }
-
- /**
- * Returns the first location of a CRLF.
- *
- * @return int
- */
- protected int getFirstCRLF() {
- int size = buffer.length;
- int i = bufferIndex + 1;
- while (i < size) {
- if (buffer[i - 1] == CR && buffer[i] == LF)
- return i;
- i++;
- }
- return -1;
- }
-
- /**
- * Output the given bytes.
- * @param b byte[]
- */
- protected void outputBytes(byte[] b, boolean isNew) throws IOException {
- out.write(b);
- if (isRequest)
- conn.addRequest(b, isNew);
- else
- conn.addResponse(b, isNew);
- }
-
- /**
- * Parse the HTTP body.
- *
- * @throws IOException
- */
- public void parseBody() throws IOException {
- Trace.trace(Trace.PARSING, "Parsing body for: " + this);
-
- if (responseType != null && ("204".equals(responseType) || "304".equals(responseType))) {
- setHTTPBody(new byte[0]);
- return;
- }
-
- if (isRequest) {
- if (contentLength != -1) {
- byte[] b2 = null;
- int b2Index = 0;
- if (contentLength < 1024 * 1024)
- b2 = new byte[contentLength];
- byte[] b = removeFromBuffer(Math.min(buffer.length, bufferIndex + contentLength));
- if (b2 != null) {
- System.arraycopy(b, 0, b2, 0, b.length);
- b2Index += b.length;
- }
- int bytesLeft = contentLength - b.length;
- Trace.trace(Trace.PARSING, "[Request] bytesLeft: "+ bytesLeft);
- out.write(b);
-
- int n = 0;
- while (bytesLeft > 0) {
- n = in.read(readBuffer, 0, Math.min(readBuffer.length, bytesLeft));
- bytesLeft -= n;
- if (b2 != null) {
- System.arraycopy(readBuffer, 0, b2, b2Index, n);
- b2Index += n;
- }
- out.write(readBuffer, 0, n);
- Trace.trace(Trace.PARSING, "[Request] bytes read: "+ n + " bytesLeft: "+ bytesLeft);
- }
-
- // restore the byte array for display
- if (b2 == null)
- b2 = Messages.errorContentSize.getBytes();
-
- conn.addRequest(b2, false);
- setHTTPBody(b2);
- } else if (transferEncoding != -1 && transferEncoding != ENCODING_IDENTITY) {
- parseChunk();
- }
-
- Trace.trace(Trace.PARSING, "Done parsing request body for: " + this);
- return;
- }
-
- // just return body for HTTP 1.0 responses
- if (!isRequest && !connectionKeepAlive && contentLength == -1 && transferEncoding == -1) {
- Trace.trace(Trace.PARSING, "Assuming HTTP 1.0 for: " + this);
- int n = buffer.length - bufferIndex;
- byte[] b = readBytes(n);
- byte[] body = new byte[0];
- while (n >= 0) {
- Trace.trace(Trace.PARSING, "Bytes read: " + n + " " + this);
- if (b != null && n > 0) {
- byte[] x = null;
- if (n == b.length)
- x = b;
- else {
- x = new byte[n];
- System.arraycopy(b, 0, x, 0, n);
- }
- outputBytes(x, false);
-
- // copy to HTTP body
- byte[] temp = new byte[body.length + x.length];
- System.arraycopy(body, 0, temp, 0, body.length);
- System.arraycopy(x, 0, temp, body.length, x.length);
- body = temp;
- }
- if (b == null || b.length < BUFFER)
- b = new byte[BUFFER];
- n = in.read(b);
- Thread.yield();
- }
- out.flush();
- setHTTPBody(body);
- return;
- }
-
- // spec 4.4.1
- if (responseType != null && responseType.startsWith("1")) {
- setHTTPBody(new byte[0]);
- return;
- }
-
- // spec 4.4.2
- if (transferEncoding != -1 && transferEncoding != ENCODING_IDENTITY) {
- parseChunk();
- return;
- }
-
- // spec 4.4.3
- if (contentLength != -1) {
- byte[] b2 = null;
- int b2Index = 0;
- if (contentLength < 1024 * 1024)
- b2 = new byte[contentLength];
- byte[] b = removeFromBuffer(Math.min(buffer.length, bufferIndex + contentLength));
- if (b2 != null) {
- System.arraycopy(b, 0, b2, 0, b.length);
- b2Index += b.length;
- }
- int bytesLeft = contentLength - b.length;
- Trace.trace(Trace.PARSING,"bytesLeft: "+ bytesLeft);
- out.write(b);
-
- int n = 0;
- while (bytesLeft > 0) {
- n = in.read(readBuffer, 0, Math.min(readBuffer.length, bytesLeft));
- bytesLeft -= n;
- if (b2 != null) {
- System.arraycopy(readBuffer, 0, b2, b2Index, n);
- b2Index += n;
- }
- Trace.trace(Trace.PARSING,"bytes read: "+n + " bytesLeft: "+ bytesLeft);
- out.write(readBuffer, 0, n);
- }
-
- // restore the byte array for display
- if (b2 == null)
- b2 = Messages.errorContentSize.getBytes();
-
- if (isRequest)
- conn.addRequest(b2, false);
- else
- conn.addResponse(b2, false);
- setHTTPBody(b2);
- return;
- }
-
- // spec 4.4.4 (?)
-
- Trace.trace(Trace.PARSING, "Unknown body for: " + this);
- }
-
- // Use this method to dump the content of a byte array
- //
- // private void dumpBuffer(byte[] b) {
- // Trace.trace(Trace.PARSING, "Buffer dump to default.out:");
- // Trace.trace(Trace.PARSING, "Byte array: " + b.length);
- // for (int i = 0; i < b.length; i++) {
- // System.out.print(" [" + (char) b[i] + "]"); // +" ["+b[i+1]+"] "
- // if (i % 20 == 0) {
- // System.out.println();
- // }
- // }
- // }
-
-
- /**
- * Parse an HTTP chunk.
- *
- * @throws IOException
- */
- public void parseChunk() throws IOException {
- Trace.trace(Trace.PARSING, "Parsing chunk for: " + this);
- boolean done = false;
- byte[] body = new byte[0];
-
- while (!done) {
- // read chunk size
- byte[] b = readLine();
-
- String s = new String(b);
- Trace.trace(Trace.PARSING, "Chunk-length: "+s);
- int index = s.indexOf(" ");
- int length = -1;
- try {
- if (index > 0)
- s = s.substring(0, index);
- length = Integer.parseInt(s.trim(), 16);
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error chunk for: " + this, e);
- }
-
- // output bytes
- outputBytes(b, false);
-
- if (length <= 0)
- done = true;
- else {
- // read and output chunk data plus CRLF
- b = readBytes(length + 2);
- outputBytes(b, false);
-
- // copy to HTTP body
- byte[] temp = new byte[body.length + b.length - 2];
- System.arraycopy(body, 0, temp, 0, body.length);
- System.arraycopy(b, 0, temp, body.length, b.length - 2);
- body = temp;
- }
- }
-
- // read trailer
- byte[] b = readLine();
- while (b.length > 2) {
- outputBytes(b, false);
- b = readLine();
- }
-
- outputBytes(b, false);
- setHTTPBody(body);
- }
-
- /**
- * Parse an HTTP header.
- *
- * @throws IOException
- */
- public void parseHeader() throws IOException {
- Trace.trace(Trace.PARSING, "Parsing header for: " + this);
-
- // read until first blank line
- boolean isFirstLine = true;
- boolean isNew = true;
-
- byte[] b = readLine();
- while (b.length > 5) {
- Trace.trace(Trace.PARSING, "Parsing header line: '" + new String(b) + "'");
-
- if (isFirstLine) {
- String s = new String(b);
- if (isRequest) {
- setLabel(s);
- isNew = false;
- }
-
- if (!isRequest) {
- int index1 = s.indexOf(' ');
- int index2 = s.indexOf(' ', index1 + 1);
-
- try {
- responseType = s.substring(index1 + 1, index2).trim();
- Trace.trace(Trace.PARSING, "Response Type: " + this + " " + responseType);
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error parsing response type for: " + this, e);
- }
- if (responseType != null && responseType.equals("100")) {
- outputBytes(b, isNew);
- isNew = false;
-
- b = readLine();
- outputBytes(b, false);
-
- b = readLine();
-
- index1 = s.indexOf(' ');
- index2 = s.indexOf(' ', index1 + 1);
-
- try {
- responseType = s.substring(index1 + 1, index2).trim();
- Trace.trace(Trace.PARSING, "Response Type: " + this + " " + responseType);
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error parsing response type for: " + this, e);
- }
- }
- }
- isFirstLine = false;
- }
-
- // translate
- b = translateHeaderLine(b);
-
- outputBytes(b, isNew);
- isNew = false;
-
- b = readLine();
- }
-
- Trace.trace(Trace.PARSING, "Parsing final header line: '" + new String(b) + "'");
-
- outputBytes(b, false);
-
- Request rr = conn.getRequestResponse(isRequest);
- Trace.trace(Trace.PARSING, "Setting header length: " + rr.getRequest(Request.ALL).length);
-
- setHTTPHeader(rr);
- }
-
- /**
- * Read bytes from the stream.
- * @return byte[]
- */
- protected byte[] readBytes(int n) throws IOException {
- Trace.trace(Trace.PARSING, "readBytes() " + n + " for: " + this);
- while (buffer.length - bufferIndex < n)
- fillBuffer();
-
- return removeFromBuffer(bufferIndex + n);
- }
-
- /**
- * Read and return the next full line.
- *
- * @return byte[]
- */
- protected byte[] readLine() throws IOException {
- Trace.trace(Trace.PARSING, "readLine() for: " + this);
-
- int n = getFirstCRLF();
- while (n < 0) {
- fillBuffer();
- n = getFirstCRLF();
- }
- return removeFromBuffer(n + 1);
- }
-
- /**
- * Remove data from the buffer up to the absolute index n.
- * Return the data from between bufferIndex and n.
- *
- * @param n the bytes to remove
- * @return a byte array
- */
- protected byte[] removeFromBuffer(int n) {
- // copy line out of buffer
- byte[] b = new byte[n - bufferIndex];
- System.arraycopy(buffer, bufferIndex, b, 0, n - bufferIndex);
-
- if (buffer.length > BUFFER * 2 || bufferIndex > BUFFER) {
- // remove line from buffer
- int size = buffer.length;
- byte[] x = new byte[size - n];
- System.arraycopy(buffer, n, x, 0, size - n);
- buffer = x;
- bufferIndex = 0;
- } else
- bufferIndex = n;
-
- return b;
- }
-
- /**
- * Listen for input, save it, and pass to the output stream.
- * Philosophy: Read a single line separately and translate.
- * When blank line is reached, just pass all other data through.
- */
- public void run() {
- try {
- try {
- while (true) {
- contentLength = -1;
- transferEncoding = -1;
- connectionKeepAlive = false;
- connectionClose = false;
-
- parseHeader();
- parseBody();
-
- if (isRequest && connectionKeepAlive)
- waitForResponse();
-
- //Request r = conn.getRequestResponse(true);
- //r.fireChangedEvent();
-
- Trace.trace(Trace.PARSING, "Done HTTP request for " + this + " " + connectionKeepAlive);
- if (!isRequest && (!request.connectionKeepAlive || connectionClose)) {
- conn2.close();
- if (request.connectionKeepAlive && connectionClose)
- request.connectionKeepAlive = false;
- notifyRequest();
- break;
- }
-
- if (!isRequest)
- notifyRequest();
-
- Thread.yield();
- }
- } catch (IOException e) {
- // reached end of input
- Trace.trace(Trace.PARSING, "End of buffer for: " + this, e);
- if (!isRequest) {
- try {
- request.connectionKeepAlive = false;
- request.conn2.close();
- notifyRequest();
- } catch (Exception ex) {
- Trace.trace(Trace.PARSING, "Error closing request in response to error: " + this, e);
- }
- }
- }
-
- // send rest of buffer
- out.write(buffer, bufferIndex, buffer.length - bufferIndex);
- out.flush();
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error in: " + this, e);
- }
- //if (!isRequest)
- // conn2.close();
-
- Trace.trace(Trace.PARSING, "Closing thread " + this);
- }
-
- /**
- * Sets the title of the call.
- *
- * @param s java.lang.String
- */
- protected void setLabel(String s) {
- try {
- int index1 = s.indexOf(' ');
- if (index1 < 0 || index1 > 15)
- return;
- int index2 = s.indexOf(' ', index1 + 1);
- if (index2 < 0)
- return;
-
- conn.setLabel(s.substring(index1 + 1, index2), true);
- } catch (Exception e) {
- // ignore
- }
- }
-
- /**
- * Translate the header line.
- *
- * @return byte[]
- * @param b byte[]
- */
- protected byte[] translateHeaderLine(byte[] b) {
- String s = new String(b);
-
- if (isRequest && s.toLowerCase().startsWith("host: ")) {
- String t = "Host: " + host;
- if (port != 80)
- t += ":" + port;
- return convert(t.getBytes());
- } else if (s.toLowerCase().startsWith("content-length: ")) {
- try {
- contentLength = Integer.parseInt(s.substring(16).trim());
- Trace.trace(Trace.PARSING, "Content length: " + this + " " + contentLength);
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Content length error", e);
- }
- } else if (s.toLowerCase().startsWith("connection: ")) {
- try {
- String t = s.substring(11).trim();
- if (t.equalsIgnoreCase("Keep-Alive"))
- connectionKeepAlive = true;
- // response contains "Connection: close" header
- // close connection to the client even if "keepalive" had been requested
- // we can't just reset request.keepAlive - it's used as indicator whether
- // the request thread is (going to) wait for the response thread
- // (and must be notified (only then)),
- // so we have to let it alone
- if (t.equalsIgnoreCase("close"))
- connectionClose = true;
- Trace.trace(Trace.PARSING, "Keep alive: " + connectionKeepAlive);
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error getting Connection: from header", e);
- }
- } else if (s.toLowerCase().startsWith("transfer-encoding: ")) {
- String t = s.substring(19).trim();
- int size = ENCODING_STRING.length;
- for (int i = 0; i < size; i++) {
- if (ENCODING_STRING[i].equalsIgnoreCase(t)) {
- transferEncoding = (byte) i;
- Trace.trace(Trace.PARSING, "Transfer encoding: " + ENCODING_STRING[i]);
- }
- }
- }
-
- return b;
- }
-
- protected void close() {
- try {
- Trace.trace(Trace.PARSING, "Closing: " + this);
- out.close();
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error closing connection " + this, e);
- }
- }
-
- protected void waitForResponse() {
- Trace.trace(Trace.PARSING, "Waiting for response " + this);
- synchronized (this) {
- try {
- isWaiting = true;
- wait();
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error in waitForResponse() " + this, e);
- }
- isWaiting = false;
- }
- Trace.trace(Trace.PARSING, "Done waiting for response " + this);
- }
-
- protected void notifyRequest() {
- Trace.trace(Trace.PARSING, "Notifying request " + this);
- while (request.connectionKeepAlive && !request.isWaiting) {
- Trace.trace(Trace.PARSING, "Waiting for request " + this);
- try {
- Thread.sleep(100);
- } catch (Exception e) {
- // ignore
- }
- }
- synchronized (request) {
- try {
- request.notify();
- } catch (Exception e) {
- Trace.trace(Trace.PARSING, "Error in notifyRequest() " + this, e);
- }
- }
- Trace.trace(Trace.PARSING, "Done notifying request " + this);
- }
-
- protected void setHTTPHeader(Request rr) {
- if (isRequest) {
- byte[] b = rr.getRequest(Request.ALL);
- byte[] h = new byte[b.length];
- System.arraycopy(b, 0, h, 0, b.length);
- rr.setProperty(HTTPRequest.HTTP_REQUEST_HEADER, h);
- } else {
- byte[] b = rr.getResponse(Request.ALL);
- byte[] h = new byte[b.length];
- System.arraycopy(b, 0, h, 0, b.length);
- rr.setProperty(HTTPRequest.HTTP_RESPONSE_HEADER, h);
- }
- }
-
- protected void setHTTPBody(byte[] b) {
- Request rr = conn.getRequestResponse(isRequest);
- if (isRequest)
- rr.setProperty(HTTPRequest.HTTP_REQUEST_BODY, b);
- else
- rr.setProperty(HTTPRequest.HTTP_RESPONSE_BODY, b);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPConnection.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPConnection.java
deleted file mode 100644
index c9e344117..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPConnection.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.http;
-
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- * A resend HTTP connection wraps an HTTP connection to send an existing request.
- */
-public class ResendHTTPConnection extends HTTPConnection {
- protected Request existingRequest;
-
- /**
- * Create a new resend connection.
- *
- * @param request
- */
- public ResendHTTPConnection(Request request) {
- super(null);
- this.existingRequest = request;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.internet.monitor.core.internal.http.HTTPConnection#getRequestResponse(int)
- */
- protected Request getRequestResponse(int i) {
- return existingRequest;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPRequest.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPRequest.java
deleted file mode 100644
index 2a48859dd..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/http/ResendHTTPRequest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.http;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.net.Socket;
-
-import org.eclipse.wst.internet.monitor.core.internal.Connection;
-import org.eclipse.wst.internet.monitor.core.internal.Monitor;
-import org.eclipse.wst.internet.monitor.core.internal.SocketWrapper;
-import org.eclipse.wst.internet.monitor.core.internal.provisional.Request;
-/**
- * Wraps an existing request to create an HTTP request that can be sent. The
- * response is ignored. Only the request is important in this case.
- */
-public class ResendHTTPRequest extends HTTPRequest {
- private boolean sent = false;
-
- private byte[] header;
-
- private byte[] content;
-
- private Request originalRequest = null;
-
- /**
- * Constructor.
- *
- * @param monitor
- * @param req the request that is to be resent.
- */
- public ResendHTTPRequest(Monitor monitor, Request req) {
- super(monitor, req.getLocalPort(), req.getRemoteHost(), req.getRemotePort());
- setProperty(HTTP_REQUEST_HEADER, req.getProperty(HTTP_REQUEST_HEADER));
- setProperty(HTTP_REQUEST_BODY, req.getProperty(HTTP_REQUEST_BODY));
- header = req.getRequest(TRANSPORT);
- content = req.getRequest(CONTENT);
- request = req.getRequest(ALL);
- name = req.getName();
- this.originalRequest = req;
- }
-
- /**
- * Send the request.
- */
- public void sendRequest() {
- try {
- Socket inSocket = new SocketWrapper(new ByteArrayInputStream(request));
- Socket outSocket = new Socket(remoteHost, remotePort);
- //Connection conn = new Connection(inSocket, outSocket);
- //TCPIPThread requestThread = new TCPIPThread(conn, this, in,
- // outSocket.getOutputStream(), true);
- //requestThread.start();
- //new TCPIPThread(conn, this, outSocket.getInputStream(),
- // inSocket.getOutputStream(), false).start();
- Connection conn2 = new Connection(inSocket, outSocket);
- ResendHTTPConnection conn = new ResendHTTPConnection(this);
-
- HTTPThread request2 = new HTTPThread(conn2, inSocket.getInputStream(),
- outSocket.getOutputStream(), conn, true, remoteHost, remotePort);
- HTTPThread response2 = new HTTPThread(conn2, outSocket.getInputStream(),
- inSocket.getOutputStream(), conn, false, "localhost", localPort, request2);
- request2.start();
- response2.start();
- } catch (IOException e) {
- response = ("Unable to resend to server.\n" + e).getBytes();
- }
- sent = true;
- }
-
- /** (non-Javadoc)
- * @see Request#addToRequest(byte[])
- */
- public void addToRequest(byte[] addRequest) {
- // Don't want to add to the request as we already have the request.
- }
-
- /**
- * Returns <code>true</code> if the request has been sent.
- *
- * @return <code>true</code> if the request has been sent, and <code>false</code>
- * otherwise
- */
- public boolean hasBeenSent() {
- return sent;
- }
-
- /**
- * Set the request.
- *
- * @param request
- * @param type
- */
- public void setRequest(byte[] request, int type) {
- if (request == null)
- request = new byte[0];
- if (type == TRANSPORT)
- header = request;
- else if (type == CONTENT)
- content = request;
-
- int length = 0;
- int headerLength = 0;
- if (header != null) {
- length += header.length;
- headerLength = length;
- }
- if (content != null)
- length += content.length;
- byte[] newRequest = new byte[length];
- if (header != null)
- System.arraycopy(header, 0, newRequest, 0, header.length);
- if (content != null)
- System.arraycopy(content, 0, newRequest, headerLength, content.length);
- super.setRequest(newRequest);
- }
-
- /** (non-Javadoc)
- * @see HTTPRequest#getRequestContent()
- */
- protected byte[] getRequestContent() {
- return content;
- }
-
- /** (non-Javadoc)
- * @see HTTPRequest#getRequestHeader()
- */
- protected byte[] getRequestHeader() {
- return header;
- }
-
- /**
- * Returns the original request.
- *
- * @return the original request
- */
- public Request getOriginalRequest() {
- return originalRequest;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/ContentFilterDelegate.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/ContentFilterDelegate.java
deleted file mode 100644
index 55cdfaf22..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/ContentFilterDelegate.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-
-import java.io.IOException;
-/**
- * A content filter that filters contents from the monitor traffic on a request.
- * <p>
- * This abstract class is intended to be subclassed only by clients
- * to extend the <code>contentFilters</code> extension point.
- * The subclass must have a public 0-argument constructor, which will be used
- * automatically to instantiate the delegate when required.
- * </p>
- * <p>
- * [issue: The notion of content filters is a UI/presentation
- * concern, not something that is makes sense to have as core
- * functionality. The contentFilters extension point, IContentFilter,
- * and ContentFilterDelegate should all move to the o.e.wst.internet.monitor.ui
- * plug-in.]
- * [issue: CS - I'd echo the comment above that this seems like a UI concern.
- * I noticed there's also a viewer on the UI side, so i'm not sure how these would interact.
- * I assume that filters operate on the byte stream and aren't concerned with UI presentation...
- * but usually UI's and filters are tightly coupled.
- * </p>
- */
-public abstract class ContentFilterDelegate {
- /**
- * Filter the given content from the given request. The content that has been filtered out will
- * not be shown to clients of the TCP/IP monitor.
- *
- * @param request the request that the filter will be performed on
- * @param isRequest set to true if the content filter applies to request monitor traffic,
- * or set to false if the content filter applies to the response monitor traffic
- * @param content the message content to be filtered out
- * @return the filtered content
- * @throws IOException if there is an error while parsing or filtering the content
- */
- public abstract byte[] filter(Request request, boolean isRequest, byte[] content) throws IOException;
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitor.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitor.java
deleted file mode 100644
index 107f1383f..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitor.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Tianchao Li (Tianchao.Li@gmail.com) - Start monitors by default
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-/**
- * Represents a monitor between a client and server.
- * The monitor watches all network traffic between a local client (talking
- * on a given local port) and a remote server (identified by host and port).
- * The global list of known monitors is available via {@link MonitorCore#getMonitors()}.
- * IMonitor is thread-safe.
- * <p>
- * IMonitors are read-only. To make changes to a monitor, you must create an
- * IMonitorWorkingCopy by calling createWorkingCopy(). Changes to the working copy
- * are applied when the working copy is saved. Monitors and monitor working copies
- * have the following properties:
- * * equals() returns true for a monitor and it's working copy
- * <p>
- * [issue: Why the built-in assumption that the client is local? A monitor
- * would make just as much sense sitting between a client on a remote machine
- * and a server.]
- * </p>
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @see IMonitorWorkingCopy
- */
-public interface IMonitor {
- /**
- * Returns the id of this monitor.
- * Each monitor has a distinct, fixed id. Ids are intended to be used internally as keys;
- * they are not intended to be shown to end users.
- *
- * @return the monitor id
- */
- public String getId();
-
- /**
- * Returns the remote host name of the server being monitored.
- *
- * @return the remote host name
- */
- public String getRemoteHost();
-
- /**
- * Returns the remote port number of the server being monitored.
- *
- * @return the remote port number
- */
- public int getRemotePort();
-
- /**
- * Returns the local port number of the client being monitored. This
- * is the port that the client is talking to the remote server on.
- *
- * @return the local port number
- */
- public int getLocalPort();
-
- /**
- * Returns the protocol that this monitor uses to read network
- * traffic.
- *
- * @return the protocol id
- */
- public String getProtocol();
-
- /**
- * Returns the connection timeout (in ms). Returns 0 if there is no timeout.
- *
- * @return the timeout
- */
- public int getTimeout();
-
- /**
- * Returns whether this monitor starts by default.
- *
- * @return <code>true</code> if the monitor should be started by default, or
- * <code>false</code> otherwise
- */
- public boolean isAutoStart();
-
- /**
- * Returns whether this monitor is currently running. Monitor working
- * copies will always return false (since they cannot be run).
- *
- * @return <code>true</code> if the monitor is currently running, or
- * <code>false</code> otherwise
- */
- public boolean isRunning();
-
- /**
- * Deletes this monitor. The monitor will no longer be available to clients.
- * If the monitor is currently running, it will be stopped first.
- * This method has no effect if the monitor has already been deleted or if
- * it is called on a working copy. Clients have no obligation to delete
- * working copies.
- */
- public void delete();
-
- /**
- * Returns whether this monitor is a working copy. Monitors which return
- * <code>true</code> to this method can be safely cast to
- * {@link IMonitorWorkingCopy}.
- *
- * @return <code>true</code> if this monitor is a working copy, and
- * <code>false</code> otherwise
- */
- public boolean isWorkingCopy();
-
- /**
- * Returns a working copy for this monitor. If the receiver is not a
- * working copy, a new working copy will be created and initialized to have
- * the same attributes as this monitor. If the receiver is a working copy,
- * this method simply returns the receiver. After configuring attributes on
- * the working copy, calling {@link IMonitorWorkingCopy#save()} applies
- * the changes to the original monitor.
- *
- * @return a working copy of this monitor
- */
- public IMonitorWorkingCopy createWorkingCopy();
-
- /**
- * Starts the given monitor listening on its client port. This method is
- * synchronous and the monitor will be running and ready for use by the
- * time that the method returns. This method has no effect if the monitor
- * is already running.
- * <p>
- * A CoreException is thrown if the monitor is not valid, the local port
- * is in use, or if another problem occurs when starting the monitor.
- * </p>
- * <p>
- * This method must not be called on a working copy or after the monitor
- * has been deleted.
- * </p>
- *
- * @throws CoreException thrown if the monitor's properties are invalid,
- * if it fails to start because the port is in use, or another problem occurs
- */
- public void start() throws CoreException;
-
- /**
- * Stops the given monitor and frees up all underlying operating
- * system resources. This method is synchronous and the monitor will be
- * running and ready for use by the time that the method returns.
- * This method has no effect if the monitor was not already running.
- * <p>
- * After returning from this method, the monitor may be restarted at
- * any time. This method must not be called on a working copy or after
- * the monitor has been deleted.
- * </p>
- */
- public void stop();
-
- /**
- * Adds a request listener.
- * Once registered, a listener starts receiving notification of
- * changes to the global list of requests. The listener continues to receive
- * notifications until it is removed.
- * Has no effect if an identical listener is already registered.
- * <p>
- * If a listener is added to a working copy, it will automatically be added
- * to the original monitor. If the monitor does not exist yet (when the working
- * copy was just created from MonitorCore.createMonitor()), the listener will
- * be added to the created monitor when (if) the working copy is saved.
- * </p>
- *
- * @param listener the request listener
- * @see #removeRequestListener(IRequestListener)
- */
- public void addRequestListener(IRequestListener listener);
-
- /**
- * Removes the given request listener. Has no effect if the listener is
- * not registered.
- * <p>
- * If a listener is removed from a working copy, it will automatically be
- * removed from the corresponding original monitor. Removing a monitor from
- * a newly created monitor has no effect unless the monitor had already been
- * added, in which case it is removed from notification and will not be added
- * to the created monitor when (if) the working copy is saved.
- * </p>
- *
- * @param listener the listener
- * @see #addRequestListener(IRequestListener)
- */
- public void removeRequestListener(IRequestListener listener);
-
- /**
- * Validates this monitor. This method should return an error if the monitor
- * has invalid ports or remote hostname.
- * <p>
- * This method is not on the working copy so that the runtime can be validated
- * at any time.
- * </p>
- *
- * @return a status object with code <code>IStatus.OK</code> if this
- * runtime is valid, otherwise a status object indicating what is
- * wrong with it
- */
- public IStatus validate();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorListener.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorListener.java
deleted file mode 100644
index 75c947cbe..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-/**
- * Listener for global changes affecting monitors.
- * <p>
- * Clients should implement this interface and register
- * their listener via {@link MonitorCore#addMonitorListener(IMonitorListener)}.
- * </p>
- */
-public interface IMonitorListener {
-
- /**
- * Notification that the given monitor has been created (added to the
- * global list of known monitors).
- *
- * @param monitor the newly-created monitor
- */
- public void monitorAdded(IMonitor monitor);
-
- /**
- * Notification that the given monitor has been changed.
- * Note that the monitor is never a working copy.
- *
- * @param monitor the monitor that has been changed
- */
- public void monitorChanged(IMonitor monitor);
-
- /**
- * Notification that the given monitor has been deleted (removed
- * from the global list of known monitors).
- *
- * @param monitor the monitor that has been deleted
- */
- public void monitorRemoved(IMonitor monitor);
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorWorkingCopy.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorWorkingCopy.java
deleted file mode 100644
index 1b7405881..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IMonitorWorkingCopy.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Tianchao Li (Tianchao.Li@gmail.com) - Start monitors by default
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-
-import org.eclipse.core.runtime.CoreException;
-/**
- * Represents a working copy of a monitor. A working copy is a copy that the
- * attributes can be changed.
- * IMonitorWorkingCopy is thread-safe. However, working copies instances
- * should be short-lived to reduce the chance of multiple working copies
- * being created by different clients and one client overwritting changes
- * made to the other working copy.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- * @see IMonitor
- *
- * [issue : CS - it sounds like this is something useful for creating monitors.
- * Shouldn't this be called a IMonitorConfiguration? Is there an advantage to making
- * this actually seem to be a IMonitor? Perhaps some UI convenience?
- * Is a IMonitorWorkingCopy actually 'useable' for monitoring .. or is it really just a configuration? ]
- */
-public interface IMonitorWorkingCopy extends IMonitor {
- /**
- * Returns the original monitor that this working copy corresponds to, or
- * <code>null</code> if this working copy was just created from
- * MonitorCore.createMonitor().
- *
- * @return the original monitor, or <code>null</code> if this working copy
- * was just created
- */
- public IMonitor getOriginal();
-
- /**
- * Sets the local port number of the client to be monitored.
- *
- * @param port the local (client) port number
- * @see IMonitor#getLocalPort()
- */
- public void setLocalPort(int port);
-
- /**
- * Sets the remote host name of the server to be monitored.
- *
- * @param host the new remote host name
- * @see IMonitor#getRemoteHost()
- */
- public void setRemoteHost(String host);
-
- /**
- * Sets the remote port number of the server to be monitored.
- *
- * @param port the new remote port number
- * @see IMonitor#getRemotePort()
- */
- public void setRemotePort(int port);
-
- /**
- * Sets the protocol to be used to read network
- * traffic between the server and the client.
- *
- * @param protocolId the protocol id
- * @see IMonitor#getProtocol()
- */
- public void setProtocol(String protocolId);
-
- /**
- * Sets the connection timeout (in ms). Use 0 to clear the timeout.
- *
- * @param timeout the connection timeout
- * @see IMonitor#getTimeout()
- */
- public void setTimeout(int timeout);
-
- /**
- * Sets whether this monitor starts by default.
- *
- * @param startByDefault run the monitor on plug-in startup
- * @see IMonitor#isAutoStart()
- */
- public void setAutoStart(boolean startByDefault);
-
- /**
- * Saves the changes made to this working copy.
- * For a brand new working copy (created by
- * {@link MonitorCore#createMonitor()}, and not yet saved), this method
- * creates a new monitor instance with attributes matching this working copy.
- * For a working copy cloned from an existing monitor instance (by
- * {@link IMonitor#createWorkingCopy()}), this method stops the existing
- * monitor (using {@link IMonitor#stop()}) if necessary,
- * and then sets the attributes of the monitor instance to match this
- * working copy (the monitor instance is returned).
- * <p>
- * Saving a working copy for a monitor that was already deleted will cause
- * the monitor to get recreated (with any changes in the working copy).
- * </p>
- * <p>
- * This method throws a CoreException if there is a problem saving the
- * monitor. No validation checks occur when saving the monitor. This can be
- * done by calling IMonitor.validate() prior to saving.
- * </p>
- *
- * @return the affected monitor
- * @throws CoreException thrown if a problem occurs while saving the monitor
- */
- public IMonitor save() throws CoreException;
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IRequestListener.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IRequestListener.java
deleted file mode 100644
index bd0c5b6c4..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/IRequestListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-/**
- * Listener for new or modified requests created from a single monitor.
- * Each request represents message traffic between a monitored client
- * and server.
- * <p>
- * Requests are not persisted - they only exist in this API until the
- * connection is done. An initial requestAdded() event is fired when the
- * request is created (by the client creating a connection), and then
- * requestChanged() events occur as data is passed through the request
- * or changes are made to the request's properties.
- * </p>
- *
- * @see IMonitor#addRequestListener(IRequestListener)
- */
-public interface IRequestListener {
- /**
- * Notification that the given request was created.
- * <p>
- * Requests may be created with little to no data in them.
- * As additional information is available, the
- * <code>requestChanged</code> method is called.
- * </p>
- *
- * @param monitor the monitor from which the request was initiated
- * @param request the request that has been added
- */
- public void requestAdded(IMonitor monitor, Request request);
-
- /**
- * Notification that the given request has been changed.
- * This method is called when more data is available in the
- * request.
- * <p>
- * Individual values within the request are rarely modified.
- * This method may be called when they are initially set or
- * when more data is received from the client or server.
- * </p>
- *
- * @param monitor the monitor from which the request was initiated
- * @param request the request that has been changed
- */
- public void requestChanged(IMonitor monitor, Request request);
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/MonitorCore.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/MonitorCore.java
deleted file mode 100644
index 441488296..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/MonitorCore.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-
-import java.util.List;
-
-import org.eclipse.wst.internet.monitor.core.internal.MonitorManager;
-/**
- * Main class for creating new monitors and locating existing ones. The methods on
- * this class are thread safe.
- * <p>
- * This class provides all functionality through static members. It is not intended
- * to be instantiated or subclassed.
- * </p>
- */
-public final class MonitorCore {
- private static MonitorManager manager;
-
- /**
- * Cannot create MonitorCore - use static methods.
- */
- private MonitorCore() {
- // can't create
- }
-
- /**
- * Returns a monitor manager instance.
- *
- * @return the monitor manager
- */
- private static MonitorManager getManager() {
- if (manager == null)
- manager = MonitorManager.getInstance();
- return manager;
- }
-
- /**
- * Returns a list of all known monitor instances. The list will not contain any
- * working copies and is persisted between workbench sessions.
- * <p>
- * A new array is returned on each call; clients may safely store or modify the result.
- * </p>
- *
- * @return a possibly-empty array of monitor instances
- */
- public static IMonitor[] getMonitors() {
- List<IMonitor> list = getManager().getMonitors();
- IMonitor[] m = new IMonitor[list.size()];
- list.toArray(m);
- return m;
- }
-
- /**
- * Creates a new monitor working copy. After configuring parameters on
- * the working copy, calling {@link IMonitorWorkingCopy#save()} brings
- * the monitor into existence.
- * <p>
- * Note that the client is responsible for calling {@link IMonitor#delete()}
- * to delete the monitor once it is no longer needed.
- * </p>
- * <p>
- * When monitors are created, the local and remote port values default to
- * <code>80</code>, but they do not have a protocol or remote host (values
- * are <code>null</code>).
- * </p>
- *
- * @return a monitor working copy
- */
- public static IMonitorWorkingCopy createMonitor() {
- return getManager().createMonitor();
- }
-
- /**
- * Adds a monitor listener.
- * Once registered, a listener starts receiving notification of
- * changes to the monitors. The listener continues to receive
- * notifications until it is removed.
- * Has no effect if an identical listener is already registered.
- *
- * @param listener the monitor listener
- * @see #removeMonitorListener(IMonitorListener)
- */
- public static void addMonitorListener(IMonitorListener listener) {
- if (listener == null)
- throw new IllegalArgumentException();
- getManager().addMonitorListener(listener);
- }
-
- /**
- * Removes the given monitor listener. Has no
- * effect if the listener is not registered.
- *
- * @param listener the listener
- * @see #addMonitorListener(IMonitorListener)
- */
- public static void removeMonitorListener(IMonitorListener listener) {
- if (listener == null)
- throw new IllegalArgumentException();
- getManager().removeMonitorListener(listener);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/Request.java b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/Request.java
deleted file mode 100644
index 06ebd2e13..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/Request.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.internet.monitor.core.internal.provisional;
-
-import java.util.Date;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.internet.monitor.core.internal.Monitor;
-import org.eclipse.wst.internet.monitor.core.internal.Trace;
-/**
- * Represents a TCP/IP request made between the client and the server.
- * Each request represents a request-response pair, where the request
- * is from client -> server, and the response is from server -> client.
- * <p>
- * Requests are created by a running monitor. They do not have a reference
- * back to the monitor because the monitor may have been deleted or modified
- * since the request was created.
- * </p>
- * <p>
- * This interface is intended to be extended only by clients
- * to extend the <code>protocolAdapters</code> extension point.
- * </p>
- */
-public class Request implements IAdaptable {
- protected Monitor monitor;
- protected Date date;
- protected long responseTime = -1;
- protected int localPort;
- protected String remoteHost;
- protected int remotePort;
- protected byte[] request;
- protected byte[] response;
-
- protected String name;
- protected String protocolId;
-
- protected Properties properties;
-
- /**
- * Request2 content type (value 1) for the transport (header) of a request
- * or response.
- *
- * @see #getRequest(int)
- * @see #getResponse(int)
- */
- public static final int TRANSPORT = 1;
-
- /**
- * Request2 content type (value 2) for the content (body) of a request
- * or response.
- *
- * @see #getRequest(int)
- * @see #getResponse(int)
- */
- public static final int CONTENT = 2;
-
- /**
- * Request2 content type (value 3) for the entire content of a request
- * or response.
- *
- * @see #getRequest(int)
- * @see #getResponse(int)
- */
- public static final int ALL = 3;
-
- /**
- * Create a new Request.
- *
- * @param monitor a monitor
- * @param protocolId the protocol id
- * @param localPort a local port number
- * @param remoteHost a remote hostname
- * @param remotePort a remote port number
- */
- public Request(Monitor monitor, String protocolId, int localPort, String remoteHost, int remotePort) {
- super();
- this.monitor = monitor;
- this.protocolId = protocolId;
- this.localPort = localPort;
- this.remoteHost = remoteHost;
- this.remotePort = remotePort;
- date = new Date();
- properties = new Properties();
- if (monitor != null)
- monitor.addRequest(this);
- }
-
- /**
- * Returns the protocol responsible for creating this request.
- *
- * @return the protocol id
- */
- public String getProtocol() {
- return protocolId;
- }
-
- /**
- * Returns the time this request was made.
- *
- * @return the timestamp
- */
- public Date getDate() {
- return date;
- }
-
- /**
- * Returns the local (client) port.
- *
- * @return the local port number
- */
- public int getLocalPort() {
- return localPort;
- }
-
- /**
- * Returns the remote (server) host.
- *
- * @return the remote host
- */
- public String getRemoteHost() {
- return remoteHost;
- }
-
- /**
- * Returns the remote (server) port.
- *
- * @return the remote port number
- */
- public int getRemotePort() {
- return remotePort;
- }
-
- /**
- * Returns the selected content of the request portion of this request.
- * <p>
- * [issue: I don't know how to explain this. For basic TCP/IP requests,
- * distinction between transport and content is ignored.
- * For HTTP requests, this TRANSPORT returns just the HTTP header and
- * CONTENT returns just the HTTP body without the headers. What would
- * it mean for other protocols?
- * </p>
- *
- * @param type the content type: one of {@link #TRANSPORT},
- * {@link #CONTENT}, or {@link #ALL}
- * @return the content bytes
- */
- public byte[] getRequest(int type) {
- return request;
- }
-
- /**
- * Returns the selected content of the response portion of this request.
- * <p>
- * [issue: I don't know how to explain this. For basic TCP/IP requests,
- * distinction between transport and content is ignored.
- * For HTTP requests, this TRANSPORT returns just the HTTP header and
- * CONTENT returns just the HTTP body without the headers. What would
- * it mean for other protocols?]
- * </p>
- *
- * @param type the content type: one of {@link #TRANSPORT},
- * {@link #CONTENT}, or {@link #ALL}
- * @return the content bytes
- */
- public byte[] getResponse(int type) {
- return response;
- }
-
- /**
- * Returns the server's response time in milliseconds. If the request
- * has not been completed yet, -1 is returned.
- *
- * @return the server's response time, or -1 if there has been no
- * response yet
- */
- public long getResponseTime() {
- return responseTime;
- }
-
- /**
- * Returns a name for this request.
- *
- * @return the name
- */
- public String getName() {
- if (name == null)
- return getRemoteHost() + ":" + getRemotePort();
-
- return name;
- }
-
- /**
- * Sets the name of this request.
- *
- * @param n the name
- */
- protected void setName(String n) {
- name = n;
- }
-
- /**
- * Sets the given key-value property on this request. To remove a property,
- * set the value to null.
- * <p>
- * This method is typically called by protocol adapters to attach protocol-
- * specific fields to the request, but it may be called by any client.
- * </p>
- *
- * @param key the key
- * @param value the value
- */
- public void setProperty(String key, Object value) {
- try {
- if (properties.containsKey(key))
- properties.remove(key);
- if (value != null)
- properties.put(key, value);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not add property", e);
- }
- monitor.requestChanged(this);
- }
-
- /**
- * Returns the value of the property with the given key from this request.
- * If the key does not exist, <code>null</code> is returned.
- *
- * @param key the property key
- * @return the property value
- */
- public Object getProperty(String key) {
- try {
- return properties.get(key);
- } catch (Exception e) {
- return null;
- }
- }
-
- /**
- * Add to the request.
- *
- * @param addRequest byte[]
- */
- public void addToRequest(byte[] addRequest) {
- if (addRequest == null || addRequest.length == 0)
- return;
-
- if (request == null || request.length == 0) {
- setRequest(addRequest);
- return;
- }
-
- int size = request.length + addRequest.length;
- byte[] b = new byte[size];
- System.arraycopy(request, 0, b, 0, request.length);
- System.arraycopy(addRequest, 0, b, request.length, addRequest.length);
- request = b;
- fireChangedEvent();
- }
-
- /**
- * Add to the response.
- *
- * @param addResponse byte[]
- */
- public void addToResponse(byte[] addResponse) {
- if (addResponse == null || addResponse.length == 0)
- return;
-
- if (response == null || response.length == 0) {
- setResponse(addResponse);
- return;
- }
-
- int size = response.length + addResponse.length;
- byte[] b = new byte[size];
- System.arraycopy(response, 0, b, 0, response.length);
- System.arraycopy(addResponse, 0, b, response.length, addResponse.length);
- response = b;
- fireChangedEvent();
- }
-
- /**
- * Set the request.
- *
- * @param request byte[]
- */
- protected void setRequest(byte[] request) {
- if (request == null || request.length == 0)
- return;
-
- this.request = request;
- monitor.requestChanged(this);
- }
-
- /**
- * Set the response.
- *
- * @param response byte[]
- */
- protected void setResponse(byte[] response) {
- if (response == null || response.length == 0)
- return;
-
- this.response = response;
- responseTime = System.currentTimeMillis() - date.getTime();
- monitor.requestChanged(this);
- }
-
- /**
- * Returns the monitor that created this request.
- * Change events will be fired from this monitor.
- * <p>
- * Note that the monitor may have been editted since this
- * request was created, so you cannot rely on the monitor's
- * hostname or port values.
- * </p>
- *
- * @return the monitor that created this request
- */
- public IMonitor getMonitor() {
- return monitor;
- }
-
- /**
- * Fire a change event to notify monitor listeners that the request has changed.
- */
- protected void fireChangedEvent() {
- if (monitor != null)
- monitor.requestChanged(this);
- }
-
- /** (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-}
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.html b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.html
deleted file mode 100644
index 505ed58f4..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<html>
-<head>
-<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<link rel="stylesheet" href="../../../../../..//apistyles.css" type="text/css">
-<title>WTP API overview</title>
-</head>
-<body>
-<p>This package gives core (non-UI) access to the TCP/IP monitor. Clients can
-query for existing monitors, create new monitors, start/stop monitors, and
-listen for requests being received by a running monitor.</p>
-<table width="500">
-<tr>
-<td>
-<p>The MonitorCore class gives initial access to all of the API. From here you
-can query the existing monitors, create new ones, and add/remove a listener for
-monitor changes.</p>
-</td>
-</tr>
-</table>
-<table width="500">
-<tr>
-<td>
-<p>The IMonitor interface provides information about a particular monitor,
-allowing you to change it via a working copy, start/stop it, or add a listener
-for request activity.</p>
-</td>
-</tr>
-</table>
-</body>
-</html>
diff --git a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.xml b/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.xml
deleted file mode 100644
index 3f4e04aa6..000000000
--- a/plugins/org.eclipse.wst.internet.monitor.core/monitorcore/org/eclipse/wst/internet/monitor/core/internal/provisional/package.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<html>
-<head>
- <!-- Escape to the root of your source folder -->
- <meta
- name="root"
- content="../../../../../../" />
- <title>WTP API overview</title>
-</head>
-
-<body>
-
-
-<abstract>This package gives core (non-UI) access to the TCP/IP monitor. Clients can
-query for existing monitors, create new monitors, start/stop monitors, and
-listen for requests being received by a running monitor.</abstract>
-
-<p>The MonitorCore class gives initial access to all of the API. From here you
-can query the existing monitors, create new ones, and add/remove a listener for
-monitor changes.</p>
-
-<p>The IMonitor interface provides information about a particular monitor,
-allowing you to change it via a working copy, start/stop it, or add a listener
-for request activity.</p>
-
-</body>
-</html>

Back to the top