public class ProxyConnector extends AbstractIoConnector
SocketConnector to provide proxy
support, as suggested by MINA list discussions.
Operates by intercepting connect requests and replacing the endpoint address
with the proxy address, then adding a ProxyFilter as the first
IoFilter which performs any necessary handshaking with the proxy
before allowing data to flow normally. During the handshake, any outgoing
write requests are buffered.
AbstractIoService.ServiceOperationFuture| Modifier and Type | Field and Description |
|---|---|
private SocketConnector |
connector
Wrapped connector to use for outgoing TCP connections.
|
private DefaultConnectFuture |
future
This future will notify it's listeners when really connected to the target
|
private static TransportMetadata |
METADATA |
private ProxyFilter |
proxyFilter
Proxy filter instance.
|
private ProxyIoSession |
proxyIoSession
The
ProxyIoSession in use. |
disposalLock, sessionConfig| Constructor and Description |
|---|
ProxyConnector()
Creates a new proxy connector.
|
ProxyConnector(SocketConnector connector)
Creates a new proxy connector.
|
ProxyConnector(SocketConnector connector,
IoSessionConfig config,
java.util.concurrent.Executor executor)
Creates a new proxy connector.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelConnectFuture()
Cancels the real connection when reconnection is in use.
|
protected ConnectFuture |
connect0(java.net.SocketAddress remoteAddress,
java.net.SocketAddress localAddress,
IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
Connects to the specified
address. |
protected void |
dispose0()
Implement this method to release any acquired resources.
|
protected ConnectFuture |
fireConnected(IoSession session)
Fires the connection event on the real future to notify the client.
|
SocketConnector |
getConnector()
Get the
SocketConnector to be used for connections
to the proxy server. |
ProxyIoSession |
getProxyIoSession()
Returns the
ProxyIoSession linked with this connector. |
IoSessionConfig |
getSessionConfig()
Returns the default configuration of the new
IoSessions
created by this service. |
TransportMetadata |
getTransportMetadata()
Returns the
TransportMetadata that this service runs on. |
private void |
setConnector(SocketConnector connector)
Sets the
SocketConnector to be used for connections
to the proxy server. |
void |
setProxyIoSession(ProxyIoSession proxyIoSession)
Sets the proxy session object of this connector.
|
connect, connect, connect, connect, connect, connect, finishSessionInitialization0, getConnectTimeout, getConnectTimeoutCheckInterval, getConnectTimeoutMillis, getDefaultLocalAddress, getDefaultRemoteAddress, setConnectTimeout, setConnectTimeoutCheckInterval, setConnectTimeoutMillis, setDefaultLocalAddress, setDefaultRemoteAddress, toStringaddListener, broadcast, dispose, dispose, executeWorker, executeWorker, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryprivate static final TransportMetadata METADATA
private SocketConnector connector
private final ProxyFilter proxyFilter
private ProxyIoSession proxyIoSession
ProxyIoSession in use.private DefaultConnectFuture future
public ProxyConnector()
public ProxyConnector(SocketConnector connector)
connector - Connector used to establish proxy connections.public ProxyConnector(SocketConnector connector, IoSessionConfig config, java.util.concurrent.Executor executor)
public IoSessionConfig getSessionConfig()
IoSessions
created by this service.public ProxyIoSession getProxyIoSession()
ProxyIoSession linked with this connector.public void setProxyIoSession(ProxyIoSession proxyIoSession)
proxyIoSession - the configuration of this connector.protected ConnectFuture connect0(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
address. If communication starts
successfully, events are fired to the connector's handler.connect0 in class AbstractIoConnectorremoteAddress - the remote address to connect tolocalAddress - the local addresssessionInitializer - the session initializerConnectFuture that will tell the result of the connection attemptpublic void cancelConnectFuture()
protected ConnectFuture fireConnected(IoSession session)
session - the current sessionpublic final SocketConnector getConnector()
SocketConnector to be used for connections
to the proxy server.private final void setConnector(SocketConnector connector)
SocketConnector to be used for connections
to the proxy server.connector - the connector to useprotected void dispose0()
throws java.lang.Exception
AbstractIoService.dispose().dispose0 in class AbstractIoServicejava.lang.Exceptionpublic TransportMetadata getTransportMetadata()
TransportMetadata that this service runs on.