org.glassfish.grizzly
Class AbstractSocketConnectorHandler

java.lang.Object
  extended by org.glassfish.grizzly.AbstractSocketConnectorHandler
All Implemented Interfaces:
ConnectorHandler<java.net.SocketAddress>, SocketConnectorHandler
Direct Known Subclasses:
TCPNIOConnectorHandler, UDPNIOConnectorHandler

public abstract class AbstractSocketConnectorHandler
extends java.lang.Object
implements SocketConnectorHandler

Abstract class simplifies the implementation of SocketConnectorHandler interface by pre-implementing some of its methods.

Author:
Alexey Stashok

Nested Class Summary
static class AbstractSocketConnectorHandler.Builder<E extends AbstractSocketConnectorHandler.Builder>
          Builder
 
Field Summary
protected  java.util.List<ConnectionProbe> probes
           
protected  Transport transport
           
 
Constructor Summary
AbstractSocketConnectorHandler(Transport transport)
           
 
Method Summary
 void addMonitoringProbe(ConnectionProbe probe)
          Add the ConnectionProbe, which will be notified about Connection life-cycle events.
 GrizzlyFuture<Connection> connect(java.net.SocketAddress remoteAddress)
          Creates, initializes and connects socket to the specific SocketAddress and returns Connection, representing socket.
 void connect(java.net.SocketAddress remoteAddress, CompletionHandler<Connection> completionHandler)
          Creates, initializes and connects socket to the specific SocketAddress and returns Connection, representing socket.
 GrizzlyFuture<Connection> connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress)
          Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.
abstract  void connect(java.net.SocketAddress remoteAddress, java.net.SocketAddress localAddress, CompletionHandler<Connection> completionHandler)
          Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.
 GrizzlyFuture<Connection> connect(java.lang.String host, int port)
          Creates, initializes and connects socket to the specific remote host and port and returns Connection, representing socket.
 ConnectionProbe[] getMonitoringProbes()
          Get the ConnectionProbe, which are registered on the Connection.
 Processor getProcessor()
          Get the default Processor to process IOEvent, occurring on connection phase.
 ProcessorSelector getProcessorSelector()
          Gets the default ProcessorSelector, which will be used to get Processor to process I/O events, occurring on connection phase.
protected  void preConfigure(Connection connection)
          Pre-configures Connection object before actual connecting phase will be started.
 boolean removeMonitoringProbe(ConnectionProbe probe)
          Remove the ConnectionProbe.
 void setProcessor(Processor processor)
          Set the default Processor to process IOEvent, occurring on connection phase.
 void setProcessorSelector(ProcessorSelector processorSelector)
          Sets the default ProcessorSelector, which will be used to get Processor to process I/O events, occurring on connection phase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transport

protected final Transport transport

probes

protected final java.util.List<ConnectionProbe> probes
Constructor Detail

AbstractSocketConnectorHandler

public AbstractSocketConnectorHandler(Transport transport)
Method Detail

connect

public GrizzlyFuture<Connection> connect(java.lang.String host,
                                         int port)
Description copied from interface: SocketConnectorHandler
Creates, initializes and connects socket to the specific remote host and port and returns Connection, representing socket.

Specified by:
connect in interface SocketConnectorHandler
Parameters:
host - remote host to connect to.
port - remote port to connect to.
Returns:
Future of connect operation, which could be used to get resulting Connection.

connect

public GrizzlyFuture<Connection> connect(java.net.SocketAddress remoteAddress)
Description copied from interface: ConnectorHandler
Creates, initializes and connects socket to the specific SocketAddress and returns Connection, representing socket.

Specified by:
connect in interface ConnectorHandler<java.net.SocketAddress>
Parameters:
remoteAddress - remote address to connect to.
Returns:
Future of connect operation, which could be used to get resulting Connection.

connect

public void connect(java.net.SocketAddress remoteAddress,
                    CompletionHandler<Connection> completionHandler)
Description copied from interface: ConnectorHandler
Creates, initializes and connects socket to the specific SocketAddress and returns Connection, representing socket.

Specified by:
connect in interface ConnectorHandler<java.net.SocketAddress>
Parameters:
remoteAddress - remote address to connect to.
completionHandler - CompletionHandler.

connect

public GrizzlyFuture<Connection> connect(java.net.SocketAddress remoteAddress,
                                         java.net.SocketAddress localAddress)
Description copied from interface: ConnectorHandler
Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.

Specified by:
connect in interface ConnectorHandler<java.net.SocketAddress>
Parameters:
remoteAddress - remote address to connect to.
localAddress - local address to bind socket to.
Returns:
Future of connect operation, which could be used to get resulting Connection.

connect

public abstract void connect(java.net.SocketAddress remoteAddress,
                             java.net.SocketAddress localAddress,
                             CompletionHandler<Connection> completionHandler)
Description copied from interface: ConnectorHandler
Creates, initializes socket, binds it to the specific local and remote SocketAddress and returns Connection, representing socket.

Specified by:
connect in interface ConnectorHandler<java.net.SocketAddress>
Parameters:
remoteAddress - remote address to connect to.
localAddress - local address to bind socket to.
completionHandler - CompletionHandler.

getProcessor

public Processor getProcessor()
Get the default Processor to process IOEvent, occurring on connection phase.

Returns:
the default Processor to process IOEvent, occurring on connection phase.

setProcessor

public void setProcessor(Processor processor)
Set the default Processor to process IOEvent, occurring on connection phase.

Parameters:
processor - the default Processor to process IOEvent, occurring on connection phase.

getProcessorSelector

public ProcessorSelector getProcessorSelector()
Gets the default ProcessorSelector, which will be used to get Processor to process I/O events, occurring on connection phase.

Returns:
the default ProcessorSelector, which will be used to get Processor to process I/O events, occurring on connection phase.

setProcessorSelector

public void setProcessorSelector(ProcessorSelector processorSelector)
Sets the default ProcessorSelector, which will be used to get Processor to process I/O events, occurring on connection phase.

Parameters:
processorSelector - the default ProcessorSelector, which will be used to get Processor to process I/O events, occurring on connection phase.

addMonitoringProbe

public void addMonitoringProbe(ConnectionProbe probe)
Add the ConnectionProbe, which will be notified about Connection life-cycle events.

Parameters:
probe - the ConnectionProbe.

removeMonitoringProbe

public boolean removeMonitoringProbe(ConnectionProbe probe)
Remove the ConnectionProbe.

Parameters:
probe - the ConnectionProbe.

getMonitoringProbes

public ConnectionProbe[] getMonitoringProbes()
Get the ConnectionProbe, which are registered on the Connection. Please note, it's not appropriate to modify the returned array's content. Please use addMonitoringProbe(org.glassfish.grizzly.ConnectionProbe) and removeMonitoringProbe(org.glassfish.grizzly.ConnectionProbe) instead.

Returns:
the ConnectionProbe, which are registered on the Connection.

preConfigure

protected void preConfigure(Connection connection)
Pre-configures Connection object before actual connecting phase will be started.

Parameters:
connection - Connection to pre-configure.


Copyright © 2012 Oracle Corporation. All Rights Reserved.