- java.lang.Object
-
- swim.io.AbstractService
-
- All Implemented Interfaces:
FlowContext
,Service
public abstract class AbstractService extends Object implements Service, FlowContext
-
-
Field Summary
Fields Modifier and Type Field Description protected ServiceContext
context
-
Constructor Summary
Constructors Constructor Description AbstractService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Modem<?,?>
createModem()
Socket
createSocket()
Returns a newSocket
binding to handle an incoming network connection.void
didAccept(Socket socket)
Lifecycle callback invoked by the service context after the underlying network listener has accepted a newsocket
connection.void
didBind()
Lifecycle callback invoked by the service context after the underlying network listener has bound to a port.void
didFail(Throwable error)
Lifecycle callback invoked by the service context when the underlying network listener fails by throwing anerror
.void
didUnbind()
Lifecycle callback invoked by the service context after the underlying network listener has been unbound.FlowControl
flowControl()
Returns the currentFlowControl
state of the underlying network channel.void
flowControl(FlowControl flowControl)
Enqueues an atomic replacement of the underlying network channel's flow control state with a newflowControl
.FlowControl
flowControl(FlowModifier flowModifier)
Enqueues an atomic modification to the underlying network channel's flow control state by applying aflowModifier
delta.InetSocketAddress
localAddress()
ServiceContext
serviceContext()
Returns the network listener context to which thisService
is bound; returnsnull
if thisService
is unbound.void
setServiceContext(ServiceContext context)
Sets the network listener context to which thisService
is bound.SocketSettings
socketSettings()
void
unbind()
-
-
-
Field Detail
-
context
protected ServiceContext context
-
-
Method Detail
-
serviceContext
public ServiceContext serviceContext()
Description copied from interface:Service
Returns the network listener context to which thisService
is bound; returnsnull
if thisService
is unbound.- Specified by:
serviceContext
in interfaceService
-
setServiceContext
public void setServiceContext(ServiceContext context)
Description copied from interface:Service
Sets the network listener context to which thisService
is bound.- Specified by:
setServiceContext
in interfaceService
-
createSocket
public Socket createSocket()
Description copied from interface:Service
Returns a newSocket
binding to handle an incoming network connection.- Specified by:
createSocket
in interfaceService
-
createModem
public Modem<?,?> createModem()
-
didBind
public void didBind()
Description copied from interface:Service
Lifecycle callback invoked by the service context after the underlying network listener has bound to a port.
-
didAccept
public void didAccept(Socket socket)
Description copied from interface:Service
Lifecycle callback invoked by the service context after the underlying network listener has accepted a newsocket
connection.
-
didUnbind
public void didUnbind()
Description copied from interface:Service
Lifecycle callback invoked by the service context after the underlying network listener has been unbound.
-
didFail
public void didFail(Throwable error)
Description copied from interface:Service
Lifecycle callback invoked by the service context when the underlying network listener fails by throwing anerror
. The listener will automatically be closed.
-
flowControl
public FlowControl flowControl()
Description copied from interface:FlowContext
Returns the currentFlowControl
state of the underlying network channel.- Specified by:
flowControl
in interfaceFlowContext
-
flowControl
public void flowControl(FlowControl flowControl)
Description copied from interface:FlowContext
Enqueues an atomic replacement of the underlying network channel's flow control state with a newflowControl
.- Specified by:
flowControl
in interfaceFlowContext
-
flowControl
public FlowControl flowControl(FlowModifier flowModifier)
Description copied from interface:FlowContext
Enqueues an atomic modification to the underlying network channel's flow control state by applying aflowModifier
delta.- Specified by:
flowControl
in interfaceFlowContext
-
socketSettings
public SocketSettings socketSettings()
-
localAddress
public InetSocketAddress localAddress()
-
unbind
public void unbind()
-
-