- java.lang.Object
-
- swim.api.agent.AbstractAgent
-
- All Implemented Interfaces:
Agent,DataFactory,DownlinkFactory,LaneFactory,SwimRef,swim.concurrent.Schedule,swim.util.Log
public class AbstractAgent extends Object implements Agent, LaneFactory, DataFactory, SwimRef, swim.util.Log, swim.concurrent.Schedule
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 <A extends Agent>
AaddTrait(String name, Class<A> agentClass)<A extends Agent>
AaddTrait(String name, AgentFactory<A> agentFactory)<A extends Agent>
AaddTrait(swim.structure.Value props, Class<A> agentClass)<A extends Agent>
AaddTrait(swim.structure.Value props, AgentFactory<A> agentFactory)AgentContextagentContext()Returns theAgentContextused to manage thisAgent.AgentType<?>agentType()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()voidcommand(String nodeUri, String laneUri, float prio, swim.structure.Value body)voidcommand(String hostUri, String nodeUri, String laneUri, float prio, swim.structure.Value body)voidcommand(String hostUri, String nodeUri, String laneUri, swim.structure.Value body)voidcommand(String nodeUri, String laneUri, swim.structure.Value body)voidcommand(swim.uri.Uri nodeUri, swim.uri.Uri laneUri, float prio, swim.structure.Value body)voidcommand(swim.uri.Uri nodeUri, swim.uri.Uri laneUri, swim.structure.Value body)voidcommand(swim.uri.Uri hostUri, swim.uri.Uri nodeUri, swim.uri.Uri laneUri, float prio, swim.structure.Value body)voidcommand(swim.uri.Uri hostUri, swim.uri.Uri nodeUri, swim.uri.Uri laneUri, swim.structure.Value body)<V> CommandLane<V>commandLane()voiddebug(Object 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<swim.structure.Value>downlink()<V> HttpDownlink<V>downlinkHttp()ListDownlink<swim.structure.Value>downlinkList()MapDownlink<swim.structure.Value,swim.structure.Value>downlinkMap()ValueDownlink<swim.structure.Value>downlinkValue()voiderror(Object message)SpatialData<swim.structure.Value,swim.math.R2Shape,swim.structure.Value>geospatialData(String name)SpatialData<swim.structure.Value,swim.math.R2Shape,swim.structure.Value>geospatialData(swim.structure.Value name)<K,V>
SpatialLane<K,swim.math.R2Shape,V>geospatialLane()swim.structure.ValuegetProp(String name)Returns the value ofnameinprops().swim.structure.ValuegetProp(swim.structure.Value key)Returns the value ofkeyinprops().<A extends Agent>
AgetTrait(Class<A> agentClass)<A extends Agent>
AgetTrait(String name)<A extends Agent>
AgetTrait(swim.structure.Value props)HostRefhostRef(String hostUri)HostRefhostRef(swim.uri.Uri hostUri)swim.uri.UrihostUri()ThisAgent'shostUri.voidinfo(Object 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(swim.uri.Uri nodeUri, swim.uri.Uri laneUri)LaneReflaneRef(swim.uri.Uri hostUri, swim.uri.Uri nodeUri, swim.uri.Uri laneUri)Linklink()Returns the currently executing link, or null if not currently executing a link callback.ListData<swim.structure.Value>listData(String name)ListData<swim.structure.Value>listData(swim.structure.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<swim.structure.Value,swim.structure.Value>mapData(String name)MapData<swim.structure.Value,swim.structure.Value>mapData(swim.structure.Value name)<K,V>
MapLane<K,V>mapLane()NodeRefnodeRef(String nodeUri)NodeRefnodeRef(String hostUri, String nodeUri)NodeRefnodeRef(swim.uri.Uri nodeUri)NodeRefnodeRef(swim.uri.Uri hostUri, swim.uri.Uri nodeUri)swim.uri.UrinodeUri()ThisAgent'snodeUri.swim.structure.Valueprops()ARecordthat maps every dynamic property innodeUri(), as defined by{@code agentType().route()}, 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.voidremoveTrait(String name)voidremoveTrait(swim.structure.Value props)swim.concurrent.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.swim.concurrent.TimerRefsetTimer(long millis, swim.concurrent.TimerFunction timer)<S> SpatialData<swim.structure.Value,S,swim.structure.Value>spatialData(String name, swim.math.Z2Form<S> shapeForm)<S> SpatialData<swim.structure.Value,S,swim.structure.Value>spatialData(swim.structure.Value name, swim.math.Z2Form<S> shapeForm)<K,S,V>
SpatialLane<K,S,V>spatialLane(swim.math.Z2Form<S> shapeForm)swim.concurrent.Stagestage()TheStagethat thisAgentis bound to.<V> SupplyLane<V>supplyLane()swim.concurrent.TimerReftimer(swim.concurrent.TimerFunction timer)voidtrace(Object message)swim.collections.FingerTrieSeq<Agent>traits()ValueData<swim.structure.Value>valueData(String name)ValueData<swim.structure.Value>valueData(swim.structure.Value name)<V> ValueLane<V>valueLane()voidwarn(Object 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.
-
-
-
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 swim.uri.Uri hostUri()
ThisAgent'shostUri.
-
nodeUri
public final swim.uri.Uri nodeUri()
ThisAgent'snodeUri.
-
props
public final swim.structure.Value props()
ARecordthat maps every dynamic property innodeUri(), as defined by{@code agentType().route()}, to its value. An empty result indicates thatnodeUricontains no dynamic components.
-
getProp
public final swim.structure.Value getProp(swim.structure.Value key)
Returns the value ofkeyinprops().
-
getProp
public final swim.structure.Value getProp(String name)
Returns the value ofnameinprops().
-
schedule
public final swim.concurrent.Schedule schedule()
TheSchedulethat thisAgentis bound to.
-
stage
public final swim.concurrent.Stage stage()
TheStagethat thisAgentis bound to.
-
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.
-
traits
public swim.collections.FingerTrieSeq<Agent> traits()
-
getTrait
public <A extends Agent> A getTrait(swim.structure.Value props)
-
addTrait
public <A extends Agent> A addTrait(swim.structure.Value props, AgentFactory<A> agentFactory)
-
addTrait
public <A extends Agent> A addTrait(String name, AgentFactory<A> agentFactory)
-
removeTrait
public void removeTrait(swim.structure.Value props)
-
removeTrait
public void removeTrait(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
-
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(swim.math.Z2Form<S> shapeForm)
- Specified by:
spatialLanein interfaceLaneFactory
-
geospatialLane
public final <K,V> SpatialLane<K,swim.math.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
-
listData
public final ListData<swim.structure.Value> listData(swim.structure.Value name)
- Specified by:
listDatain interfaceDataFactory
-
listData
public final ListData<swim.structure.Value> listData(String name)
- Specified by:
listDatain interfaceDataFactory
-
mapData
public final MapData<swim.structure.Value,swim.structure.Value> mapData(swim.structure.Value name)
- Specified by:
mapDatain interfaceDataFactory
-
mapData
public final MapData<swim.structure.Value,swim.structure.Value> mapData(String name)
- Specified by:
mapDatain interfaceDataFactory
-
spatialData
public final <S> SpatialData<swim.structure.Value,S,swim.structure.Value> spatialData(swim.structure.Value name, swim.math.Z2Form<S> shapeForm)
- Specified by:
spatialDatain interfaceDataFactory
-
spatialData
public final <S> SpatialData<swim.structure.Value,S,swim.structure.Value> spatialData(String name, swim.math.Z2Form<S> shapeForm)
- Specified by:
spatialDatain interfaceDataFactory
-
geospatialData
public final SpatialData<swim.structure.Value,swim.math.R2Shape,swim.structure.Value> geospatialData(swim.structure.Value name)
- Specified by:
geospatialDatain interfaceDataFactory
-
geospatialData
public final SpatialData<swim.structure.Value,swim.math.R2Shape,swim.structure.Value> geospatialData(String name)
- Specified by:
geospatialDatain interfaceDataFactory
-
valueData
public final ValueData<swim.structure.Value> valueData(swim.structure.Value name)
- Specified by:
valueDatain interfaceDataFactory
-
valueData
public final ValueData<swim.structure.Value> valueData(String name)
- Specified by:
valueDatain interfaceDataFactory
-
downlink
public final EventDownlink<swim.structure.Value> downlink()
- Specified by:
downlinkin interfaceDownlinkFactory
-
downlinkList
public final ListDownlink<swim.structure.Value> downlinkList()
- Specified by:
downlinkListin interfaceDownlinkFactory
-
downlinkMap
public final MapDownlink<swim.structure.Value,swim.structure.Value> downlinkMap()
- Specified by:
downlinkMapin interfaceDownlinkFactory
-
downlinkValue
public final ValueDownlink<swim.structure.Value> downlinkValue()
- Specified by:
downlinkValuein interfaceDownlinkFactory
-
downlinkHttp
public final <V> HttpDownlink<V> downlinkHttp()
- Specified by:
downlinkHttpin interfaceDownlinkFactory
-
hostRef
public final HostRef hostRef(swim.uri.Uri hostUri)
-
nodeRef
public final NodeRef nodeRef(swim.uri.Uri hostUri, swim.uri.Uri nodeUri)
-
nodeRef
public final NodeRef nodeRef(swim.uri.Uri nodeUri)
-
laneRef
public final LaneRef laneRef(swim.uri.Uri hostUri, swim.uri.Uri nodeUri, swim.uri.Uri laneUri)
-
laneRef
public final LaneRef laneRef(swim.uri.Uri nodeUri, swim.uri.Uri laneUri)
-
command
public final void command(swim.uri.Uri hostUri, swim.uri.Uri nodeUri, swim.uri.Uri laneUri, float prio, swim.structure.Value body)
-
command
public final void command(String hostUri, String nodeUri, String laneUri, float prio, swim.structure.Value body)
-
command
public final void command(swim.uri.Uri hostUri, swim.uri.Uri nodeUri, swim.uri.Uri laneUri, swim.structure.Value body)
-
command
public final void command(String hostUri, String nodeUri, String laneUri, swim.structure.Value body)
-
command
public final void command(swim.uri.Uri nodeUri, swim.uri.Uri laneUri, float prio, swim.structure.Value body)
-
command
public final void command(String nodeUri, String laneUri, float prio, swim.structure.Value body)
-
command
public final void command(swim.uri.Uri nodeUri, swim.uri.Uri laneUri, swim.structure.Value body)
-
trace
public void trace(Object message)
- Specified by:
tracein interfaceswim.util.Log
-
debug
public void debug(Object message)
- Specified by:
debugin interfaceswim.util.Log
-
info
public void info(Object message)
- Specified by:
infoin interfaceswim.util.Log
-
warn
public void warn(Object message)
- Specified by:
warnin interfaceswim.util.Log
-
error
public void error(Object message)
- Specified by:
errorin interfaceswim.util.Log
-
timer
public final swim.concurrent.TimerRef timer(swim.concurrent.TimerFunction timer)
- Specified by:
timerin interfaceswim.concurrent.Schedule
-
setTimer
public final swim.concurrent.TimerRef setTimer(long millis, swim.concurrent.TimerFunction timer)- Specified by:
setTimerin interfaceswim.concurrent.Schedule
-
-