Class ProxyConnector
java.lang.Object
org.apache.mina.core.service.AbstractIoService
org.apache.mina.core.service.AbstractIoConnector
org.apache.mina.proxy.ProxyConnector
- All Implemented Interfaces:
IoConnector, IoService
ProxyConnector.java - Decorator for
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.
- Since:
- MINA 2.0.0-M3
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractIoService
AbstractIoService.ServiceOperationFuture -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SocketConnectorWrapped connector to use for outgoing TCP connections.private DefaultConnectFutureThis future will notify it's listeners when really connected to the targetprivate static final TransportMetadataprivate final ProxyFilterProxy filter instance.private ProxyIoSessionTheProxyIoSessionin use.Fields inherited from class AbstractIoService
disposalLock, LOGGER, sessionConfig -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new proxy connector.ProxyConnector(SocketConnector connector) Creates a new proxy connector.ProxyConnector(SocketConnector connector, IoSessionConfig config, Executor executor) Creates a new proxy connector. -
Method Summary
Modifier and TypeMethodDescriptionvoidCancels the real connection when reconnection is in use.protected ConnectFutureconnect0(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) Connects to the specifiedaddress.protected voiddispose0()Implement this method to release any acquired resources.protected ConnectFuturefireConnected(IoSession session) Fires the connection event on the real future to notify the client.final SocketConnectorprivate voidsetConnector(SocketConnector connector) Sets theSocketConnectorto be used for connections to the proxy server.voidsetProxyIoSession(ProxyIoSession proxyIoSession) Sets the proxy session object of this connector.Methods inherited from class AbstractIoConnector
connect, connect, connect, connect, connect, connect, finishSessionInitialization0, getConnectTimeout, getConnectTimeoutCheckInterval, getConnectTimeoutMillis, getDefaultLocalAddress, getDefaultRemoteAddress, setConnectTimeout, setConnectTimeoutCheckInterval, setConnectTimeoutMillis, setDefaultLocalAddress, setDefaultRemoteAddress, toStringMethods inherited from class AbstractIoService
addListener, broadcast, dispose, dispose, executeWorker, executeWorker, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, initSession, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactoryMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IoService
addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
-
Field Details
-
METADATA
-
connector
Wrapped connector to use for outgoing TCP connections. -
proxyFilter
Proxy filter instance. -
proxyIoSession
TheProxyIoSessionin use. -
future
This future will notify it's listeners when really connected to the target
-
-
Constructor Details
-
ProxyConnector
public ProxyConnector()Creates a new proxy connector. -
ProxyConnector
Creates a new proxy connector.- Parameters:
connector- Connector used to establish proxy connections.
-
ProxyConnector
Creates a new proxy connector.- Parameters:
connector- The Connector used to establish proxy connections.config- The session confiugarion to useexecutor- The associated executor
-
-
Method Details
-
getSessionConfig
- Returns:
- the default configuration of the new
IoSessions created by this service.
-
getProxyIoSession
- Returns:
- the
ProxyIoSessionlinked with this connector.
-
setProxyIoSession
Sets the proxy session object of this connector.- Parameters:
proxyIoSession- the configuration of this connector.
-
connect0
protected ConnectFuture connect0(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) Connects to the specifiedaddress. If communication starts successfully, events are fired to the connector'shandler.- Specified by:
connect0in classAbstractIoConnector- Parameters:
remoteAddress- the remote address to connect tolocalAddress- the local addresssessionInitializer- the session initializer- Returns:
ConnectFuturethat will tell the result of the connection attempt
-
cancelConnectFuture
public void cancelConnectFuture()Cancels the real connection when reconnection is in use. -
fireConnected
Fires the connection event on the real future to notify the client.- Parameters:
session- the current session- Returns:
- the future holding the connected session
-
getConnector
- Returns:
- the
SocketConnectorto be used for connections to the proxy server.
-
setConnector
Sets theSocketConnectorto be used for connections to the proxy server.- Parameters:
connector- the connector to use
-
dispose0
Implement this method to release any acquired resources. This method is invoked only once byAbstractIoService.dispose().- Specified by:
dispose0in classAbstractIoService- Throws:
Exception- If the dispose failed
-
getTransportMetadata
- Returns:
- the
TransportMetadatathat this service runs on.
-