Package org.glassfish.grizzly
Class AbstractSocketConnectorHandler
- java.lang.Object
-
- org.glassfish.grizzly.AbstractSocketConnectorHandler
-
- All Implemented Interfaces:
ConnectorHandler<SocketAddress>,SocketConnectorHandler
- Direct Known Subclasses:
TCPNIOConnectorHandler,UDPNIOConnectorHandler
public abstract class AbstractSocketConnectorHandler extends Object implements SocketConnectorHandler
Abstract class simplifies the implementation ofSocketConnectorHandlerinterface by pre-implementing some of its methods.- Author:
- Alexey Stashok
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractSocketConnectorHandler.Builder<E extends AbstractSocketConnectorHandler.Builder>Builder
-
Field Summary
Fields Modifier and Type Field Description protected List<ConnectionProbe>probesprotected Transporttransport-
Fields inherited from interface org.glassfish.grizzly.SocketConnectorHandler
DEFAULT_CONNECTION_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description AbstractSocketConnectorHandler(Transport transport)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddMonitoringProbe(ConnectionProbe probe)Add theConnectionProbe, which will be notified about Connection life-cycle events.GrizzlyFuture<Connection>connect(String host, int port)Creates, initializes and connects socket to the specific remote host and port and returnsConnection, representing socket.GrizzlyFuture<Connection>connect(SocketAddress remoteAddress)Creates, initializes and establishesConnectionto the specificremoteAddress.GrizzlyFuture<Connection>connect(SocketAddress remoteAddress, SocketAddress localAddress)Creates, initializesConnection, binds it to the specific local and remoteremoteAddress.voidconnect(SocketAddress remoteAddress, SocketAddress localAddress, CompletionHandler<Connection> completionHandler)Creates, initializesConnection, binds it to the specific local and remoteremoteAddress.voidconnect(SocketAddress remoteAddress, CompletionHandler<Connection> completionHandler)Creates, initializes and establishesConnectionto the specificremoteAddress.protected abstract FutureImpl<Connection>connectAsync(SocketAddress remoteAddress, SocketAddress localAddress, CompletionHandler<Connection> completionHandler, boolean needFuture)ConnectionProbe[]getMonitoringProbes()Get theConnectionProbe, which are registered on the Connection.ProcessorgetProcessor()ProcessorSelectorgetProcessorSelector()Gets the defaultProcessorSelector, which will be used to getProcessorto process I/O events, occurring on connection phase.protected FutureImpl<Connection>makeCancellableFuture(Connection connection)protected voidpreConfigure(Connection connection)Pre-configuresConnectionobject before actual connecting phase will be started.booleanremoveMonitoringProbe(ConnectionProbe probe)Remove theConnectionProbe.voidsetProcessor(Processor processor)voidsetProcessorSelector(ProcessorSelector processorSelector)Sets the defaultProcessorSelector, which will be used to getProcessorto process I/O events, occurring on connection phase.
-
-
-
Field Detail
-
transport
protected final Transport transport
-
probes
protected final List<ConnectionProbe> probes
-
-
Constructor Detail
-
AbstractSocketConnectorHandler
public AbstractSocketConnectorHandler(Transport transport)
-
-
Method Detail
-
connect
public GrizzlyFuture<Connection> connect(String host, int port)
Description copied from interface:SocketConnectorHandlerCreates, initializes and connects socket to the specific remote host and port and returnsConnection, representing socket.- Specified by:
connectin interfaceSocketConnectorHandler- Parameters:
host- remote host to connect to.port- remote port to connect to.- Returns:
Futureof connect operation, which could be used to get resultingConnection.
-
connect
public GrizzlyFuture<Connection> connect(SocketAddress remoteAddress)
Description copied from interface:ConnectorHandlerCreates, initializes and establishesConnectionto the specificremoteAddress.- Specified by:
connectin interfaceConnectorHandler<SocketAddress>- Parameters:
remoteAddress- remote address to connect to- Returns:
Futureof connect operation, which could be used to get resultingConnection
-
connect
public void connect(SocketAddress remoteAddress, CompletionHandler<Connection> completionHandler)
Description copied from interface:ConnectorHandlerCreates, initializes and establishesConnectionto the specificremoteAddress.- Specified by:
connectin interfaceConnectorHandler<SocketAddress>- Parameters:
remoteAddress- remote address to connect tocompletionHandler-CompletionHandler
-
connect
public GrizzlyFuture<Connection> connect(SocketAddress remoteAddress, SocketAddress localAddress)
Description copied from interface:ConnectorHandlerCreates, initializesConnection, binds it to the specific local and remoteremoteAddress.- Specified by:
connectin interfaceConnectorHandler<SocketAddress>- Parameters:
remoteAddress- remote address to connect tolocalAddress- local address to bind aConnectionto- Returns:
Futureof connect operation, which could be used to get resultingConnection
-
connect
public void connect(SocketAddress remoteAddress, SocketAddress localAddress, CompletionHandler<Connection> completionHandler)
Description copied from interface:ConnectorHandlerCreates, initializesConnection, binds it to the specific local and remoteremoteAddress.- Specified by:
connectin interfaceConnectorHandler<SocketAddress>- Parameters:
remoteAddress- remote address to connect tolocalAddress- local address to bind aConnectiontocompletionHandler-CompletionHandler
-
connectAsync
protected abstract FutureImpl<Connection> connectAsync(SocketAddress remoteAddress, SocketAddress localAddress, CompletionHandler<Connection> completionHandler, boolean needFuture)
-
getProcessor
public Processor getProcessor()
-
setProcessor
public void setProcessor(Processor processor)
-
getProcessorSelector
public ProcessorSelector getProcessorSelector()
Gets the defaultProcessorSelector, which will be used to getProcessorto process I/O events, occurring on connection phase.- Returns:
- the default
ProcessorSelector, which will be used to getProcessorto process I/O events, occurring on connection phase.
-
setProcessorSelector
public void setProcessorSelector(ProcessorSelector processorSelector)
Sets the defaultProcessorSelector, which will be used to getProcessorto process I/O events, occurring on connection phase.- Parameters:
processorSelector- the defaultProcessorSelector, which will be used to getProcessorto process I/O events, occurring on connection phase.
-
addMonitoringProbe
public void addMonitoringProbe(ConnectionProbe probe)
Add theConnectionProbe, which will be notified about Connection life-cycle events.- Parameters:
probe- theConnectionProbe.
-
removeMonitoringProbe
public boolean removeMonitoringProbe(ConnectionProbe probe)
Remove theConnectionProbe.- Parameters:
probe- theConnectionProbe.- Returns:
- true if probe was in the list and is now removed
-
getMonitoringProbes
public ConnectionProbe[] getMonitoringProbes()
Get theConnectionProbe, which are registered on the Connection. Please note, it's not appropriate to modify the returned array's content. Please useaddMonitoringProbe(org.glassfish.grizzly.ConnectionProbe)andremoveMonitoringProbe(org.glassfish.grizzly.ConnectionProbe)instead.- Returns:
- the
ConnectionProbe, which are registered on the Connection.
-
preConfigure
protected void preConfigure(Connection connection)
Pre-configuresConnectionobject before actual connecting phase will be started.- Parameters:
connection-Connectionto pre-configure.
-
makeCancellableFuture
protected FutureImpl<Connection> makeCancellableFuture(Connection connection)
-
-