- 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 allAgents. This class provides skeletalAgentlifecycle callback implementations, contextualLaneandStorecreation mechanisms, URI-based addressability, logging, and scheduling, primarily via delegation to its internal, immutableAgentContext.
-
-
Field Summary
Fields Modifier and Type Field Description protected AgentContextcontextInternal, immutable context that provides contextualLaneandStorecreation mechanisms, URI-based addressability, logging, and scheduling.
-
Constructor Summary
Constructors Constructor Description AbstractAgent()Creates anAbstractAgentinstance managed bySwimContext.getAgentContext().AbstractAgent(AgentContext context)Creates anAbstractAgentinstance managed bycontext.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AgentContextagentContext()Returns theAgentContextused to manage thisAgent.ValueagentId()FingerTrieSeq<Agent>agents()StageasyncStage()The multi-threaded executionStageon which thisAgentContextcan run asynchronous operations.StringcipherSuite()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.voidclose()voidcloseAgent(String name)voidcloseAgent(Value id)voidcommand(String nodeUri, String laneUri, float prio, Value body)voidcommand(String nodeUri, String laneUri, float prio, Value body, Cont<CommandMessage> cont)voidcommand(String hostUri, String nodeUri, String laneUri, float prio, Value body)voidcommand(String hostUri, String nodeUri, String laneUri, float prio, Value body, Cont<CommandMessage> cont)voidcommand(String hostUri, String nodeUri, String laneUri, Value body)voidcommand(String hostUri, String nodeUri, String laneUri, Value body, Cont<CommandMessage> cont)voidcommand(String nodeUri, String laneUri, Value body)voidcommand(String nodeUri, String laneUri, Value body, Cont<CommandMessage> cont)voidcommand(Uri nodeUri, Uri laneUri, float prio, Value body)voidcommand(Uri nodeUri, Uri laneUri, float prio, Value body, Cont<CommandMessage> cont)voidcommand(Uri nodeUri, Uri laneUri, Value body)voidcommand(Uri nodeUri, Uri laneUri, Value body, Cont<CommandMessage> cont)voidcommand(Uri hostUri, Uri nodeUri, Uri laneUri, float prio, Value body)voidcommand(Uri hostUri, Uri nodeUri, Uri laneUri, float prio, Value body, Cont<CommandMessage> cont)voidcommand(Uri hostUri, Uri nodeUri, Uri laneUri, Value body)voidcommand(Uri hostUri, Uri nodeUri, Uri laneUri, Value body, Cont<CommandMessage> cont)<V> CommandLane<V>commandLane()voiddebug(Object message)Logs a debug-level message.<V> DemandLane<V>demandLane()<K,V>
DemandMapLane<K,V>demandMapLane()voiddidClose()Lifecycle callback invoked immediately after thisAgentcloses.voiddidFail(Throwable error)Lifecycle callback invoked immediately after thisAgentthrowserror.voiddidLoad()Lifecycle callback invoked immediately after thisAgentloads, i.e.voiddidOpen()Lifecycle callback invoked immediately after thisAgentopens, i.e.voiddidStart()Lifecycle callback invoked immediately after thisAgentstarts.voiddidStop()Lifecycle callback invoked immediately after thisAgentstops, i.e.voiddidUnload()Lifecycle callback invoked immediately after thisAgentunloads, i.e.EventDownlink<Value>downlink()<V> HttpDownlink<V>downlinkHttp()ListDownlink<Value>downlinkList()MapDownlink<Value,Value>downlinkMap()ValueDownlink<Value>downlinkValue()<I,O>
WsDownlink<I,O>downlinkWs()voiderror(Object message)Logs an error-level message.voidfail(Object message)Logs an fail-level message.SpatialData<Value,R2Shape,Value>geospatialData(String name)SpatialData<Value,R2Shape,Value>geospatialData(Value name)<K,V>
SpatialLane<K,R2Shape,V>geospatialLane()<A extends Agent>
AgetAgent(Class<A> agentClass)AgentgetAgent(String name)AgentgetAgent(Value id)LanegetLane(Uri laneUri)ValuegetProp(String name)Returns the value ofnameinprops().ValuegetProp(Value key)Returns the value ofkeyinprops().HostRefhostRef(String hostUri)HostRefhostRef(Uri hostUri)UrihostUri()ThisAgent'shostUri.<V> HttpLane<V>httpLane()voidinfo(Object message)Logs an info-level message.booleanisSecure()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.<L,K,V>
JoinMapLane<L,K,V>joinMapLane()<K,V>
JoinValueLane<K,V>joinValueLane()Lanelane()Returns the currently executing lane, or null if not currently executing a lane or link callback.LaneReflaneRef(String nodeUri, String laneUri)LaneReflaneRef(String hostUri, String nodeUri, String laneUri)LaneReflaneRef(Uri nodeUri, Uri laneUri)LaneReflaneRef(Uri hostUri, Uri nodeUri, Uri laneUri)Linklink()Returns the currently executing link, or null if not currently executing a link callback.ListData<Value>listData(String name)ListData<Value>listData(Value name)<V> ListLane<V>listLane()InetSocketAddresslocalAddress()Returns the local internet address of the currently executing link, or null if not currently executing a link callback.Collection<Certificate>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.IdentitylocalIdentity()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.PrincipallocalPrincipal()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.MapData<Value,Value>mapData(String name)MapData<Value,Value>mapData(Value name)<K,V>
MapLane<K,V>mapLane()NodeRefnodeRef(String nodeUri)NodeRefnodeRef(String hostUri, String nodeUri)NodeRefnodeRef(Uri nodeUri)NodeRefnodeRef(Uri hostUri, Uri nodeUri)UrinodeUri()ThisAgent'snodeUri.<A extends Agent>
AopenAgent(String name, Class<A> agentClass)<A extends Agent>
AopenAgent(String name, AgentFactory<A> agentFactory)<A extends Agent>
AopenAgent(Value id, Class<A> agentClass)<A extends Agent>
AopenAgent(Value id, AgentFactory<A> agentFactory)<A extends Agent>
AopenAgent(Value id, Value props, Class<A> agentClass)<A extends Agent>
AopenAgent(Value id, Value props, AgentFactory<A> agentFactory)LaneopenLane(Uri laneUri, Lane lane)Valueprops()ARecordthat maps every dynamic property innodeUri(), as defined byAgentRoute.pattern(), to its value.InetSocketAddressremoteAddress()Returns the remote internet address of the currently executing link, or null if not currently executing a link callback.Collection<Certificate>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.IdentityremoteIdentity()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.PrincipalremotePrincipal()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.Scheduleschedule()TheSchedulethat thisAgentis bound to.StringsecurityProtocol()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.TimerRefsetTimer(long millis, TimerFunction timer)Schedulestimerto execute aftermillismilliseconds have elapsed.<S> SpatialData<Value,S,Value>spatialData(String name, Z2Form<S> shapeForm)<S> SpatialData<Value,S,Value>spatialData(Value name, Z2Form<S> shapeForm)<K,S,V>
SpatialLane<K,S,V>spatialLane(Z2Form<S> shapeForm)Stagestage()The single-threaded executionStageon which thisAgentContextruns its application logic.<V> SupplyLane<V>supplyLane()TimerReftimer(TimerFunction timer)Returns an unscheduledTimerRefbound totimer, which can later be used to scheduletimer.voidtrace(Object message)Logs a trace-level message.ValueData<Value>valueData(String name)ValueData<Value>valueData(Value name)<V> ValueLane<V>valueLane()voidwarn(Object message)Logs a warn-level message.voidwillClose()Lifecycle callback invoked immediately before thisAgentcloses.voidwillLoad()Lifecycle callback invoked immediately before thisAgentloads.voidwillOpen()Lifecycle callback invoked immediately before thisAgentopens.voidwillStart()Lifecycle callback invoked immediately before thisAgentstarts.voidwillStop()Lifecycle callback invoked immediately before thisAgentstops.voidwillUnload()Lifecycle callback invoked immediately before thisAgentunloads.<I,O>
WsLane<I,O>wsLane()
-
-
-
Field Detail
-
context
protected final AgentContext context
Internal, immutable context that provides contextualLaneandStorecreation mechanisms, URI-based addressability, logging, and scheduling.
-
-
Constructor Detail
-
AbstractAgent
public AbstractAgent(AgentContext context)
Creates anAbstractAgentinstance managed bycontext.
-
AbstractAgent
public AbstractAgent()
Creates anAbstractAgentinstance managed bySwimContext.getAgentContext().
-
-
Method Detail
-
agentContext
public AgentContext agentContext()
Description copied from interface:AgentReturns theAgentContextused to manage thisAgent.- Specified by:
agentContextin interfaceAgent
-
willOpen
public void willOpen()
Description copied from interface:AgentLifecycle callback invoked immediately before thisAgentopens.//@see swim.runtime.TierBinding#open
-
didOpen
public void didOpen()
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentopens, i.e. before it loads.//@see swim.runtime.TierBinding#open //@see swim.runtime.TierBinding#load
-
willLoad
public void willLoad()
Description copied from interface:AgentLifecycle callback invoked immediately before thisAgentloads.//@see swim.runtime.TierBinding#load
-
didLoad
public void didLoad()
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentloads, i.e. before it starts.//@see swim.runtime.TierBinding#load //@see swim.runtime.TierBinding#start
-
willStart
public void willStart()
Description copied from interface:AgentLifecycle callback invoked immediately before thisAgentstarts.//@see swim.runtime.TierBinding#start
-
didStart
public void didStart()
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentstarts.//@see swim.runtime.TierBinding#start
-
willStop
public void willStop()
Description copied from interface:AgentLifecycle callback invoked immediately before thisAgentstops.//@see swim.runtime.TierBinding#stop
-
didStop
public void didStop()
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentstops, i.e. before it unloads.//@see swim.runtime.TierBinding#stop //@see swim.runtime.TierBinding#unload
-
willUnload
public void willUnload()
Description copied from interface:AgentLifecycle callback invoked immediately before thisAgentunloads.//@see swim.runtime.TierBinding#unload
- Specified by:
willUnloadin interfaceAgent
-
didUnload
public void didUnload()
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentunloads, i.e. before it closes.//@see swim.runtime.TierBinding.unload //@see swim.runtime.TierBinding.close
-
willClose
public void willClose()
Description copied from interface:AgentLifecycle callback invoked immediately before thisAgentcloses.//@see swim.runtime.TierBinding.close
-
didClose
public void didClose()
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentcloses.//@see swim.runtime.TierBinding.close
-
didFail
public void didFail(Throwable error)
Description copied from interface:AgentLifecycle callback invoked immediately after thisAgentthrowserror.
-
hostUri
public final Uri hostUri()
ThisAgent'shostUri.
-
nodeUri
public final Uri nodeUri()
ThisAgent'snodeUri.
-
agentId
public final Value agentId()
-
props
public final Value props()
ARecordthat maps every dynamic property innodeUri(), as defined byAgentRoute.pattern(), to its value. An empty result indicates thatnodeUricontains no dynamic components.
-
stage
public final Stage stage()
The single-threaded executionStageon which thisAgentContextruns its application logic.
-
asyncStage
public final Stage asyncStage()
The multi-threaded executionStageon which thisAgentContextcan run asynchronous operations.
-
lane
public final Lane lane()
Returns the currently executing lane, or null if not currently executing a lane or link callback.
-
link
public final Link link()
Returns the currently executing link, or null if not currently executing a link callback.
-
agents
public FingerTrieSeq<Agent> agents()
-
openAgent
public <A extends Agent> A openAgent(Value id, Value props, AgentFactory<A> agentFactory)
-
openAgent
public <A extends Agent> A openAgent(Value id, AgentFactory<A> agentFactory)
-
openAgent
public <A extends Agent> A openAgent(String name, AgentFactory<A> agentFactory)
-
closeAgent
public void closeAgent(Value id)
-
closeAgent
public void closeAgent(String name)
-
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
public String 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
public String 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
public InetSocketAddress localAddress()
Returns the local internet address of the currently executing link, or null if not currently executing a link callback.
-
localIdentity
public Identity 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
public Principal 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
public Collection<Certificate> 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
public InetSocketAddress remoteAddress()
Returns the remote internet address of the currently executing link, or null if not currently executing a link callback.
-
remoteIdentity
public Identity 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
public Principal 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
public Collection<Certificate> 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
public final <V> CommandLane<V> commandLane()
- Specified by:
commandLanein interfaceLaneFactory
-
demandLane
public final <V> DemandLane<V> demandLane()
- Specified by:
demandLanein interfaceLaneFactory
-
demandMapLane
public final <K,V> DemandMapLane<K,V> demandMapLane()
- Specified by:
demandMapLanein interfaceLaneFactory
-
httpLane
public final <V> HttpLane<V> httpLane()
- Specified by:
httpLanein interfaceLaneFactory
-
joinMapLane
public final <L,K,V> JoinMapLane<L,K,V> joinMapLane()
- Specified by:
joinMapLanein interfaceLaneFactory
-
joinValueLane
public final <K,V> JoinValueLane<K,V> joinValueLane()
- Specified by:
joinValueLanein interfaceLaneFactory
-
listLane
public final <V> ListLane<V> listLane()
- Specified by:
listLanein interfaceLaneFactory
-
mapLane
public final <K,V> MapLane<K,V> mapLane()
- Specified by:
mapLanein interfaceLaneFactory
-
spatialLane
public final <K,S,V> SpatialLane<K,S,V> spatialLane(Z2Form<S> shapeForm)
- Specified by:
spatialLanein interfaceLaneFactory
-
geospatialLane
public final <K,V> SpatialLane<K,R2Shape,V> geospatialLane()
- Specified by:
geospatialLanein interfaceLaneFactory
-
supplyLane
public final <V> SupplyLane<V> supplyLane()
- Specified by:
supplyLanein interfaceLaneFactory
-
valueLane
public final <V> ValueLane<V> valueLane()
- Specified by:
valueLanein interfaceLaneFactory
-
wsLane
public final <I,O> WsLane<I,O> wsLane()
- Specified by:
wsLanein interfaceLaneFactory
-
spatialData
public final <S> SpatialData<Value,S,Value> spatialData(Value name, Z2Form<S> shapeForm)
- Specified by:
spatialDatain interfaceStore
-
spatialData
public final <S> SpatialData<Value,S,Value> spatialData(String name, Z2Form<S> shapeForm)
- Specified by:
spatialDatain interfaceStore
-
geospatialData
public final SpatialData<Value,R2Shape,Value> geospatialData(Value name)
- Specified by:
geospatialDatain interfaceStore
-
geospatialData
public final SpatialData<Value,R2Shape,Value> geospatialData(String name)
- Specified by:
geospatialDatain interfaceStore
-
downlink
public final EventDownlink<Value> downlink()
- Specified by:
downlinkin interfaceDownlinkFactory
-
downlinkList
public final ListDownlink<Value> downlinkList()
- Specified by:
downlinkListin interfaceDownlinkFactory
-
downlinkMap
public final MapDownlink<Value,Value> downlinkMap()
- Specified by:
downlinkMapin interfaceDownlinkFactory
-
downlinkValue
public final ValueDownlink<Value> downlinkValue()
- Specified by:
downlinkValuein interfaceDownlinkFactory
-
downlinkHttp
public final <V> HttpDownlink<V> downlinkHttp()
- Specified by:
downlinkHttpin interfaceDownlinkFactory
-
downlinkWs
public final <I,O> WsDownlink<I,O> downlinkWs()
- Specified by:
downlinkWsin interfaceDownlinkFactory
-
command
public final void command(Uri hostUri, Uri nodeUri, Uri laneUri, float prio, Value body, Cont<CommandMessage> cont)
-
command
public final void command(String hostUri, String nodeUri, String laneUri, float prio, Value body, Cont<CommandMessage> cont)
-
command
public final void command(Uri hostUri, Uri nodeUri, Uri laneUri, Value body, Cont<CommandMessage> cont)
-
command
public final void command(String hostUri, String nodeUri, String laneUri, Value body, Cont<CommandMessage> cont)
-
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
public final void command(Uri nodeUri, Uri laneUri, Value body, Cont<CommandMessage> cont)
-
command
public final void command(String nodeUri, String laneUri, Value body, Cont<CommandMessage> cont)
-
command
public final void command(String hostUri, String nodeUri, String laneUri, float prio, Value body)
-
trace
public void trace(Object message)
Description copied from interface:LogLogs a trace-level message.
-
debug
public void debug(Object message)
Description copied from interface:LogLogs a debug-level message.
-
info
public void info(Object message)
Description copied from interface:LogLogs an info-level message.
-
warn
public void warn(Object message)
Description copied from interface:LogLogs a warn-level message.
-
error
public void error(Object message)
Description copied from interface:LogLogs an error-level message.
-
fail
public void fail(Object message)
Description copied from interface:LogLogs an fail-level message.
-
timer
public final TimerRef timer(TimerFunction timer)
Description copied from interface:ScheduleReturns an unscheduledTimerRefbound totimer, which can later be used to scheduletimer.
-
setTimer
public final TimerRef setTimer(long millis, TimerFunction timer)
Description copied from interface:ScheduleSchedulestimerto execute aftermillismilliseconds have elapsed. Returns aTimerRefthat can be used to check the status of, reschedule, and canceltimer.
-
-