java.lang.Object
swim.api.agent.AbstractAgent
- All Implemented Interfaces:
Agent
,DownlinkFactory
,LaneFactory
,WarpRef
,Store
,Schedule
,Log
public class AbstractAgent
extends Object
implements Agent, WarpRef, LaneFactory, Schedule, Store, Log
Abstract base class for all
Agents
. This class
provides skeletal Agent
lifecycle callback implementations,
contextual Lane
and Store
creation mechanisms, URI-based
addressability, logging, and scheduling, primarily via delegation to its
internal, immutable AgentContext
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AgentContext
Internal, immutable context that provides contextualLane
andStore
creation mechanisms, URI-based addressability, logging, and scheduling. -
Constructor Summary
ConstructorsConstructorDescriptionCreates anAbstractAgent
instance managed bySwimContext.getAgentContext()
.AbstractAgent
(AgentContext context) Creates anAbstractAgent
instance managed bycontext
. -
Method Summary
Modifier and TypeMethodDescriptionReturns theAgentContext
used to manage thisAgent
.final Value
agentId()
agents()
final Stage
The multi-threaded executionStage
on which thisAgentContext
can run asynchronous operations.Returns the cryptographic cipher suite used by the currently executing link, or null if the currently executing link is not secure, or if not currently executing a link callback.void
close()
void
closeAgent
(String name) void
closeAgent
(Value id) final void
final void
final void
final void
command
(String hostUri, String nodeUri, String laneUri, float prio, Value body, Cont<CommandMessage> cont) final void
final void
final void
final void
final void
final void
final void
final void
final void
final void
final void
final void
final <V> CommandLane<V>
void
Logs a debug-level message.final <V> DemandLane<V>
final <K,
V> DemandMapLane<K, V> void
didClose()
Lifecycle callback invoked immediately after thisAgent
closes.void
Lifecycle callback invoked immediately after thisAgent
throwserror
.void
didLoad()
Lifecycle callback invoked immediately after thisAgent
loads, i.e.void
didOpen()
Lifecycle callback invoked immediately after thisAgent
opens, i.e.void
didStart()
Lifecycle callback invoked immediately after thisAgent
starts.void
didStop()
Lifecycle callback invoked immediately after thisAgent
stops, i.e.void
Lifecycle callback invoked immediately after thisAgent
unloads, i.e.final EventDownlink<Value>
downlink()
final <V> HttpDownlink<V>
final ListDownlink<Value>
final MapDownlink<Value,
Value> final ValueDownlink<Value>
final <I,
O> WsDownlink<I, O> void
Logs an error-level message.void
Logs an fail-level message.final SpatialData<Value,
R2Shape, Value> geospatialData
(String name) final SpatialData<Value,
R2Shape, Value> geospatialData
(Value name) final <K,
V> SpatialLane<K, R2Shape, V> <A extends Agent>
Afinal Lane
final Value
Returns the value ofname
inprops()
.final Value
Returns the value ofkey
inprops()
.final HostRef
final HostRef
final Uri
hostUri()
ThisAgent
'shostUri
.final <V> HttpLane<V>
httpLane()
void
Logs an info-level message.boolean
isSecure()
Returns true if the currently executing link is secure, or false if the currently executing link is not secure, or if not currently executing a link callback.final <L,
K, V> JoinMapLane<L, K, V> final <K,
V> JoinValueLane<K, V> final Lane
lane()
Returns the currently executing lane, or null if not currently executing a lane or link callback.final LaneRef
final LaneRef
final LaneRef
final LaneRef
final Link
link()
Returns the currently executing link, or null if not currently executing a link callback.final <V> ListLane<V>
listLane()
Returns the local internet address of the currently executing link, or null if not currently executing a link callback.Returns the certificates used to authenticate the local end of the currently executing link; returns an empty collection if the currently executing link has no local certificates, or if not currently executing a link callback.Returns the local user identity of the currently executing link, or null if the currently executing link has no local user identity, or if not currently executing a link callback.Returns the principal used to identify the local end of the currently executing link, or null if the currently executing link has no local principal, or if not currently executing a link callback.final <K,
V> MapLane<K, V> mapLane()
final NodeRef
final NodeRef
final NodeRef
final NodeRef
final Uri
nodeUri()
ThisAgent
'snodeUri
.<A extends Agent>
A<A extends Agent>
AopenAgent
(String name, AgentFactory<A> agentFactory) <A extends Agent>
A<A extends Agent>
AopenAgent
(Value id, AgentFactory<A> agentFactory) <A extends Agent>
A<A extends Agent>
AopenAgent
(Value id, Value props, AgentFactory<A> agentFactory) final Lane
final Value
props()
ARecord
that maps every dynamic property innodeUri()
, as defined byAgentRoute.pattern()
, to its value.Returns the remote internet address of the currently executing link, or null if not currently executing a link callback.Returns the certificates used to authenticate the remote end of the currently executing link; returns an empty collection if the currently executing link has no remote certificates, or if not currently executing a link callback.Returns the remote user identity of the currently executing link, or null if the currently executing link has no remote user identity, or if not currently executing a link callback.Returns the principal used to identify the remote end of the currently executing link, or null if the currently executing link has no remote principal, or if not currently executing a link callback.final Schedule
schedule()
TheSchedule
that thisAgent
is bound to.Returns the security protocol used by the currently executing link, or null if the currently executing link is not secure, or if not currently executing a link callback.final TimerRef
setTimer
(long millis, TimerFunction timer) Schedulestimer
to execute aftermillis
milliseconds have elapsed.final <S> SpatialData<Value,
S, Value> spatialData
(String name, Z2Form<S> shapeForm) final <S> SpatialData<Value,
S, Value> spatialData
(Value name, Z2Form<S> shapeForm) final <K,
S, V> SpatialLane<K, S, V> spatialLane
(Z2Form<S> shapeForm) final Stage
stage()
The single-threaded executionStage
on which thisAgentContext
runs its application logic.final <V> SupplyLane<V>
final TimerRef
timer
(TimerFunction timer) Returns an unscheduledTimerRef
bound totimer
, which can later be used to scheduletimer
.void
Logs a trace-level message.final <V> ValueLane<V>
void
Logs a warn-level message.void
Lifecycle callback invoked immediately before thisAgent
closes.void
willLoad()
Lifecycle callback invoked immediately before thisAgent
loads.void
willOpen()
Lifecycle callback invoked immediately before thisAgent
opens.void
Lifecycle callback invoked immediately before thisAgent
starts.void
willStop()
Lifecycle callback invoked immediately before thisAgent
stops.void
Lifecycle callback invoked immediately before thisAgent
unloads.final <I,
O> WsLane<I, O> wsLane()
-
Field Details
-
context
Internal, immutable context that provides contextualLane
andStore
creation mechanisms, URI-based addressability, logging, and scheduling.
-
-
Constructor Details
-
AbstractAgent
Creates anAbstractAgent
instance managed bycontext
. -
AbstractAgent
public AbstractAgent()Creates anAbstractAgent
instance managed bySwimContext.getAgentContext()
.
-
-
Method Details
-
agentContext
Description copied from interface:Agent
Returns theAgentContext
used to manage thisAgent
.- Specified by:
agentContext
in interfaceAgent
-
willOpen
public void willOpen()Description copied from interface:Agent
Lifecycle callback invoked immediately before thisAgent
opens.//@see swim.system.TierBinding#open
-
didOpen
public void didOpen()Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
opens, i.e. before it loads.//@see swim.system.TierBinding#open //@see swim.system.TierBinding#load
-
willLoad
public void willLoad()Description copied from interface:Agent
Lifecycle callback invoked immediately before thisAgent
loads.//@see swim.system.TierBinding#load
-
didLoad
public void didLoad()Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
loads, i.e. before it starts.//@see swim.system.TierBinding#load //@see swim.system.TierBinding#start
-
willStart
public void willStart()Description copied from interface:Agent
Lifecycle callback invoked immediately before thisAgent
starts.//@see swim.system.TierBinding#start
-
didStart
public void didStart()Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
starts.//@see swim.system.TierBinding#start
-
willStop
public void willStop()Description copied from interface:Agent
Lifecycle callback invoked immediately before thisAgent
stops.//@see swim.system.TierBinding#stop
-
didStop
public void didStop()Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
stops, i.e. before it unloads.//@see swim.system.TierBinding#stop //@see swim.system.TierBinding#unload
-
willUnload
public void willUnload()Description copied from interface:Agent
Lifecycle callback invoked immediately before thisAgent
unloads.//@see swim.system.TierBinding#unload
- Specified by:
willUnload
in interfaceAgent
-
didUnload
public void didUnload()Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
unloads, i.e. before it closes.//@see swim.system.TierBinding.unload //@see swim.system.TierBinding.close
-
willClose
public void willClose()Description copied from interface:Agent
Lifecycle callback invoked immediately before thisAgent
closes.//@see swim.system.TierBinding.close
-
didClose
public void didClose()Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
closes.//@see swim.system.TierBinding.close
-
didFail
Description copied from interface:Agent
Lifecycle callback invoked immediately after thisAgent
throwserror
. -
hostUri
ThisAgent
'shostUri
. -
nodeUri
ThisAgent
'snodeUri
. -
agentId
-
props
ARecord
that maps every dynamic property innodeUri()
, as defined byAgentRoute.pattern()
, to its value. An empty result indicates thatnodeUri
contains no dynamic components. -
getProp
Returns the value ofkey
inprops()
. -
getProp
Returns the value ofname
inprops()
. -
schedule
TheSchedule
that thisAgent
is bound to. -
stage
The single-threaded executionStage
on which thisAgentContext
runs its application logic. -
asyncStage
The multi-threaded executionStage
on which thisAgentContext
can run asynchronous operations. -
lane
Returns the currently executing lane, or null if not currently executing a lane or link callback. -
link
Returns the currently executing link, or null if not currently executing a link callback. -
getLane
-
openLane
-
agents
-
getAgent
-
getAgent
-
getAgent
-
openAgent
-
openAgent
-
openAgent
-
openAgent
-
openAgent
-
openAgent
-
closeAgent
-
closeAgent
-
isSecure
public boolean isSecure()Returns true if the currently executing link is secure, or false if the currently executing link is not secure, or if not currently executing a link callback. -
securityProtocol
Returns the security protocol used by the currently executing link, or null if the currently executing link is not secure, or if not currently executing a link callback. -
cipherSuite
Returns the cryptographic cipher suite used by the currently executing link, or null if the currently executing link is not secure, or if not currently executing a link callback. -
localAddress
Returns the local internet address of the currently executing link, or null if not currently executing a link callback. -
localIdentity
Returns the local user identity of the currently executing link, or null if the currently executing link has no local user identity, or if not currently executing a link callback. -
localPrincipal
Returns the principal used to identify the local end of the currently executing link, or null if the currently executing link has no local principal, or if not currently executing a link callback. -
localCertificates
Returns the certificates used to authenticate the local end of the currently executing link; returns an empty collection if the currently executing link has no local certificates, or if not currently executing a link callback. -
remoteAddress
Returns the remote internet address of the currently executing link, or null if not currently executing a link callback. -
remoteIdentity
Returns the remote user identity of the currently executing link, or null if the currently executing link has no remote user identity, or if not currently executing a link callback. -
remotePrincipal
Returns the principal used to identify the remote end of the currently executing link, or null if the currently executing link has no remote principal, or if not currently executing a link callback. -
remoteCertificates
Returns the certificates used to authenticate the remote end of the currently executing link; returns an empty collection if the currently executing link has no remote certificates, or if not currently executing a link callback. -
commandLane
- Specified by:
commandLane
in interfaceLaneFactory
-
demandLane
- Specified by:
demandLane
in interfaceLaneFactory
-
demandMapLane
- Specified by:
demandMapLane
in interfaceLaneFactory
-
httpLane
- Specified by:
httpLane
in interfaceLaneFactory
-
joinMapLane
- Specified by:
joinMapLane
in interfaceLaneFactory
-
joinValueLane
- Specified by:
joinValueLane
in interfaceLaneFactory
-
listLane
- Specified by:
listLane
in interfaceLaneFactory
-
mapLane
- Specified by:
mapLane
in interfaceLaneFactory
-
spatialLane
- Specified by:
spatialLane
in interfaceLaneFactory
-
geospatialLane
- Specified by:
geospatialLane
in interfaceLaneFactory
-
supplyLane
- Specified by:
supplyLane
in interfaceLaneFactory
-
valueLane
- Specified by:
valueLane
in interfaceLaneFactory
-
wsLane
- Specified by:
wsLane
in interfaceLaneFactory
-
listData
-
listData
-
mapData
-
mapData
-
spatialData
- Specified by:
spatialData
in interfaceStore
-
spatialData
- Specified by:
spatialData
in interfaceStore
-
geospatialData
- Specified by:
geospatialData
in interfaceStore
-
geospatialData
- Specified by:
geospatialData
in interfaceStore
-
valueData
-
valueData
-
downlink
- Specified by:
downlink
in interfaceDownlinkFactory
-
downlinkList
- Specified by:
downlinkList
in interfaceDownlinkFactory
-
downlinkMap
- Specified by:
downlinkMap
in interfaceDownlinkFactory
-
downlinkValue
- Specified by:
downlinkValue
in interfaceDownlinkFactory
-
downlinkHttp
- Specified by:
downlinkHttp
in interfaceDownlinkFactory
-
downlinkWs
- Specified by:
downlinkWs
in interfaceDownlinkFactory
-
hostRef
-
hostRef
-
nodeRef
-
nodeRef
-
nodeRef
-
nodeRef
-
laneRef
-
laneRef
-
laneRef
-
laneRef
-
command
-
command
-
command
-
command
-
command
public final void command(Uri nodeUri, Uri laneUri, float prio, Value body, Cont<CommandMessage> cont) -
command
public final void command(String nodeUri, String laneUri, float prio, Value body, Cont<CommandMessage> cont) -
command
-
command
-
command
-
command
-
command
-
command
-
command
-
command
-
command
-
command
-
trace
Description copied from interface:Log
Logs a trace-level message. -
debug
Description copied from interface:Log
Logs a debug-level message. -
info
Description copied from interface:Log
Logs an info-level message. -
warn
Description copied from interface:Log
Logs a warn-level message. -
error
Description copied from interface:Log
Logs an error-level message. -
fail
Description copied from interface:Log
Logs an fail-level message. -
timer
Description copied from interface:Schedule
Returns an unscheduledTimerRef
bound totimer
, which can later be used to scheduletimer
. -
setTimer
Description copied from interface:Schedule
Schedulestimer
to execute aftermillis
milliseconds have elapsed. Returns aTimerRef
that can be used to check the status of, reschedule, and canceltimer
. -
close
public void close()
-