org.apache.mina.proxy
Class ProxyConnector

java.lang.Object
  extended by org.apache.mina.core.service.AbstractIoService
      extended by org.apache.mina.core.service.AbstractIoConnector
          extended by org.apache.mina.proxy.ProxyConnector
All Implemented Interfaces:
IoConnector, IoService

public class ProxyConnector
extends AbstractIoConnector

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
Version:
$Rev: 685703 $, $Date: 2008-08-14 00:14:47 +0200 (Do, 14 Aug 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)
See Also:
http://www.nabble.com/Meta-Transport%3A-an-idea-on-implementing-reconnection-and-proxy-td12969001.html, http://issues.apache.org/jira/browse/DIRMINA-415

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
 
Constructor Summary
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
 void cancelConnectFuture()
           
protected  ConnectFuture connect0(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
          Connects to the specified address.
protected  IoFuture dispose0()
          Implement this method to release any acquired resources.
protected  ConnectFuture fireConnected(IoSession session)
           
 SocketConnector getConnector()
          Get the SocketConnector to be used for connections to the proxy server.
 ProxyIoSession getProxyIoSession()
           
 IoSessionConfig getSessionConfig()
          Returns the default configuration of the new IoSessions created by this service.
 TransportMetadata getTransportMetadata()
          Returns the TransportMetadata that this service runs on.
 void setConnector(SocketConnector newConnector)
          Set the SocketConnector to be used for connections to the proxy server.
 void setProxyIoSession(ProxyIoSession proxyIoSession)
           
 
Methods inherited from class org.apache.mina.core.service.AbstractIoConnector
connect, connect, connect, connect, connect, connect, finishSessionInitialization0, getConnectTimeout, getConnectTimeoutCheckInterval, getConnectTimeoutMillis, getDefaultRemoteAddress, setConnectTimeout, setConnectTimeoutCheckInterval, setConnectTimeoutMillis, setDefaultRemoteAddress, toString
 
Methods inherited from class org.apache.mina.core.service.AbstractIoService
addListener, broadcast, dispose, executeWorker, executeWorker, finishSessionInitialization, getActivationTime, getFilterChain, getFilterChainBuilder, getHandler, getListeners, getManagedSessionCount, getManagedSessions, getScheduledWriteBytes, getScheduledWriteMessages, getSessionDataStructureFactory, getStatistics, 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, 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.

See Also:
AbstractIoConnector(IoSessionConfig, Executor).
Method Detail

getSessionConfig

public IoSessionConfig getSessionConfig()
Description copied from class: AbstractIoService
Returns the default configuration of the new IoSessions created by this service.

Specified by:
getSessionConfig in interface IoService
Overrides:
getSessionConfig in class AbstractIoService

getProxyIoSession

public ProxyIoSession getProxyIoSession()

setProxyIoSession

public void setProxyIoSession(ProxyIoSession proxyIoSession)

connect0

protected ConnectFuture connect0(SocketAddress remoteAddress,
                                 SocketAddress localAddress,
                                 IoSessionInitializer<? extends ConnectFuture> sessionInitializer)
Connects to the specified address. If communication starts successfully, events are fired to the specified handler.

Specified by:
connect0 in class AbstractIoConnector
localAddress - null if no local address is specified
Returns:
ConnectFuture that will tell the result of the connection attempt

cancelConnectFuture

public void cancelConnectFuture()

fireConnected

protected ConnectFuture fireConnected(IoSession session)

getConnector

public final SocketConnector getConnector()
Get the SocketConnector to be used for connections to the proxy server.


setConnector

public final void setConnector(SocketConnector newConnector)
Set the SocketConnector to be used for connections to the proxy server.


dispose0

protected IoFuture dispose0()
                     throws Exception
Description copied from class: AbstractIoService
Implement this method to release any acquired resources. This method is invoked only once by AbstractIoService.dispose().

Specified by:
dispose0 in class AbstractIoService
Throws:
Exception

getTransportMetadata

public TransportMetadata getTransportMetadata()
Description copied from interface: IoService
Returns the TransportMetadata that this service runs on.



Copyright © 2004-2010 Apache MINA Project. All Rights Reserved.