Package org.apache.mina.proxy
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
public class ProxyConnector extends AbstractIoConnector
ProxyConnector.java - Decorator forSocketConnectorto 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
ProxyFilteras the firstIoFilterwhich 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
- Author:
- Apache MINA Project
- See Also:
- Proxy reconnection, Proxy support
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.mina.core.service.AbstractIoService
AbstractIoService.ServiceOperationFuture
-
-
Field Summary
-
Fields inherited from class org.apache.mina.core.service.AbstractIoService
disposalLock, LOGGER, sessionConfig
-
-
Constructor Summary
Constructors Constructor Description ProxyConnector()Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelConnectFuture()Cancels 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.SocketConnectorgetConnector()ProxyIoSessiongetProxyIoSession()IoSessionConfiggetSessionConfig()TransportMetadatagetTransportMetadata()voidsetProxyIoSession(ProxyIoSession proxyIoSession)Sets the proxy session object of this connector.-
Methods inherited from class org.apache.mina.core.service.AbstractIoConnector
connect, connect, connect, connect, connect, connect, finishSessionInitialization0, getConnectTimeout, getConnectTimeoutCheckInterval, getConnectTimeoutMillis, getDefaultLocalAddress, getDefaultRemoteAddress, setConnectTimeout, setConnectTimeoutCheckInterval, setConnectTimeoutMillis, setDefaultLocalAddress, setDefaultRemoteAddress, toString
-
Methods inherited from class org.apache.mina.core.service.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, setSessionDataStructureFactory
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.mina.core.service.IoService
addListener, broadcast, dispose, dispose, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, isActive, isDisposed, isDisposing, removeListener, setFilterChainBuilder, setHandler, setSessionDataStructureFactory
-
-
-
-
Constructor Detail
-
ProxyConnector
public ProxyConnector()
Creates a new proxy connector.
-
ProxyConnector
public ProxyConnector(SocketConnector connector)
Creates a new proxy connector.- Parameters:
connector- Connector used to establish proxy connections.
-
ProxyConnector
public ProxyConnector(SocketConnector connector, IoSessionConfig config, Executor executor)
Creates a new proxy connector.- Parameters:
connector- The Connector used to establish proxy connections.config- The session confiugarion to useexecutor- The associated executor
-
-
Method Detail
-
getSessionConfig
public IoSessionConfig getSessionConfig()
- Returns:
- the default configuration of the new
IoSessions created by this service.
-
getProxyIoSession
public ProxyIoSession getProxyIoSession()
- Returns:
- the
ProxyIoSessionlinked with this connector.
-
setProxyIoSession
public void setProxyIoSession(ProxyIoSession proxyIoSession)
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
protected ConnectFuture fireConnected(IoSession session)
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
public final SocketConnector getConnector()
- Returns:
- the
SocketConnectorto be used for connections to the proxy server.
-
dispose0
protected void dispose0() throws ExceptionImplement 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
public TransportMetadata getTransportMetadata()
- Returns:
- the
TransportMetadatathat this service runs on.
-
-