public class ProxyServer extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
protected Vector<CacheProcessingItem> |
cacheProcessingList |
protected ConnectionParam |
connectionParam |
protected boolean |
enableCacheProcessing |
protected boolean |
isProxyRunning |
protected Vector<ProxyListener> |
listenerList |
protected Vector<OverrideMessageProxyListener> |
overrideListeners |
protected Vector<PersistentConnectionListener> |
persistentConnectionListenerList |
protected static int |
PORT_TIME_OUT |
protected ProxyParam |
proxyParam |
protected ServerSocket |
proxySocket |
protected boolean |
serialize |
protected Thread |
thread |
Constructor and Description |
---|
ProxyServer() |
ProxyServer(String threadName) |
Modifier and Type | Method and Description |
---|---|
void |
addCacheProcessingList(CacheProcessingItem item) |
void |
addConnectRequestProxyListener(ConnectRequestProxyListener listener)
Adds the given
listener , that will be notified of the received CONNECT requests. |
void |
addOverrideMessageProxyListener(OverrideMessageProxyListener listener) |
void |
addPersistentConnectionListener(PersistentConnectionListener listener) |
void |
addProxyListener(ProxyListener listener) |
protected ProxyThread |
createProxyProcess(Socket clientSocket) |
protected ServerSocket |
createServerSocket(String ip,
int port) |
boolean |
excludeUrl(org.apache.commons.httpclient.URI uri) |
ConnectionParam |
getConnectionParam() |
ProxyParam |
getProxyParam() |
boolean |
isAnyProxyThreadRunning() |
boolean |
isEnableApi() |
boolean |
isEnableCacheProcessing() |
boolean |
isSerialize() |
void |
removeConnectRequestProxyListener(ConnectRequestProxyListener listener)
Removes the given
listener , to no longer be notified of the received CONNECT
requests. |
void |
removeOverrideMessageProxyListener(OverrideMessageProxyListener listener) |
void |
removePersistentConnectionListener(PersistentConnectionListener listener) |
void |
removeProxyListener(ProxyListener listener) |
void |
run() |
void |
setConnectionParam(ConnectionParam connection) |
void |
setEnableApi(boolean enableApi) |
void |
setEnableCacheProcessing(boolean enableCacheProcessing) |
void |
setExcludeList(List<String> urls) |
void |
setProxyParam(ProxyParam param) |
void |
setSerialize(boolean serialize) |
void |
setShouldPrompt(boolean shouldPrompt)
Sets whether or not the
ProxyServer should prompt the user for an alternate port when
there is a conflict. |
int |
startServer(String ip,
int port,
boolean isDynamicPort)
Starts the proxy server.
|
boolean |
stopServer()
Stops the proxy server.
|
protected void |
writeOutput(String s) |
protected Thread thread
protected static final int PORT_TIME_OUT
protected ServerSocket proxySocket
protected boolean isProxyRunning
protected ProxyParam proxyParam
protected ConnectionParam connectionParam
protected Vector<ProxyListener> listenerList
protected Vector<OverrideMessageProxyListener> overrideListeners
protected Vector<PersistentConnectionListener> persistentConnectionListenerList
protected boolean serialize
protected boolean enableCacheProcessing
protected Vector<CacheProcessingItem> cacheProcessingList
public ProxyServer()
public ProxyServer(String threadName)
public boolean isEnableCacheProcessing()
public void setEnableCacheProcessing(boolean enableCacheProcessing)
enableCacheProcessing
- The enableCacheProcessing to set.public boolean isSerialize()
public void setProxyParam(ProxyParam param)
public ProxyParam getProxyParam()
public void setConnectionParam(ConnectionParam connection)
public ConnectionParam getConnectionParam()
public int startServer(String ip, int port, boolean isDynamicPort)
If the proxy server was already running it's stopped first.
ip
- the IP/address the server should bind toport
- the portisDynamicPort
- true
if it should use another port if the given one is already
in use, false
otherwise.-1
if not able to startpublic boolean stopServer()
true
if the proxy server was stopped, false
if it was not running.protected ServerSocket createServerSocket(String ip, int port) throws UnknownHostException, IOException
UnknownHostException
IOException
protected ProxyThread createProxyProcess(Socket clientSocket)
protected void writeOutput(String s)
public void addProxyListener(ProxyListener listener)
public void removeProxyListener(ProxyListener listener)
public void addPersistentConnectionListener(PersistentConnectionListener listener)
public void removePersistentConnectionListener(PersistentConnectionListener listener)
public void addOverrideMessageProxyListener(OverrideMessageProxyListener listener)
public void removeOverrideMessageProxyListener(OverrideMessageProxyListener listener)
public void addConnectRequestProxyListener(ConnectRequestProxyListener listener)
listener
, that will be notified of the received CONNECT requests.listener
- the listener that will be addedIllegalArgumentException
- if the given listener
is null
.public void removeConnectRequestProxyListener(ConnectRequestProxyListener listener)
listener
, to no longer be notified of the received CONNECT
requests.listener
- the listener that should be removedIllegalArgumentException
- if the given listener
is null
.public boolean isAnyProxyThreadRunning()
public void setSerialize(boolean serialize)
serialize
- The serialize to set.public void addCacheProcessingList(CacheProcessingItem item)
public boolean excludeUrl(org.apache.commons.httpclient.URI uri)
public void setEnableApi(boolean enableApi)
public boolean isEnableApi()
public void setShouldPrompt(boolean shouldPrompt)
ProxyServer
should prompt the user for an alternate port when
there is a conflict.shouldPrompt
- true
if the user should be prompted, false
otherwise