Module swim.api

Class AbstractAgent

    • Field Detail

      • context

        protected final AgentContext context
        Internal, immutable context that provides contextual Lane and Store creation mechanisms, URI-based addressability, logging, and scheduling.
    • Constructor Detail

      • AbstractAgent

        public AbstractAgent​(AgentContext context)
        Creates an AbstractAgent instance managed by context.
    • Method Detail

      • willOpen

        public void willOpen()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately before this Agent opens.

        //@see swim.runtime.TierBinding#open

        Specified by:
        willOpen in interface Agent
      • didOpen

        public void didOpen()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent opens, i.e. before it loads.

        //@see swim.runtime.TierBinding#open //@see swim.runtime.TierBinding#load

        Specified by:
        didOpen in interface Agent
      • willLoad

        public void willLoad()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately before this Agent loads.

        //@see swim.runtime.TierBinding#load

        Specified by:
        willLoad in interface Agent
      • didLoad

        public void didLoad()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent loads, i.e. before it starts.

        //@see swim.runtime.TierBinding#load //@see swim.runtime.TierBinding#start

        Specified by:
        didLoad in interface Agent
      • willStart

        public void willStart()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately before this Agent starts.

        //@see swim.runtime.TierBinding#start

        Specified by:
        willStart in interface Agent
      • didStart

        public void didStart()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent starts.

        //@see swim.runtime.TierBinding#start

        Specified by:
        didStart in interface Agent
      • willStop

        public void willStop()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately before this Agent stops.

        //@see swim.runtime.TierBinding#stop

        Specified by:
        willStop in interface Agent
      • didStop

        public void didStop()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent stops, i.e. before it unloads.

        //@see swim.runtime.TierBinding#stop //@see swim.runtime.TierBinding#unload

        Specified by:
        didStop in interface Agent
      • willUnload

        public void willUnload()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately before this Agent unloads.

        //@see swim.runtime.TierBinding#unload

        Specified by:
        willUnload in interface Agent
      • didUnload

        public void didUnload()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent unloads, i.e. before it closes.

        //@see swim.runtime.TierBinding.unload //@see swim.runtime.TierBinding.close

        Specified by:
        didUnload in interface Agent
      • willClose

        public void willClose()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately before this Agent closes.

        //@see swim.runtime.TierBinding.close

        Specified by:
        willClose in interface Agent
      • didClose

        public void didClose()
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent closes.

        //@see swim.runtime.TierBinding.close

        Specified by:
        didClose in interface Agent
      • didFail

        public void didFail​(Throwable error)
        Description copied from interface: Agent
        Lifecycle callback invoked immediately after this Agent throws error.
        Specified by:
        didFail in interface Agent
      • hostUri

        public final Uri hostUri()
        This Agent's hostUri.
      • nodeUri

        public final Uri nodeUri()
        This Agent's nodeUri.
      • agentId

        public final Value agentId()
      • props

        public final Value props()
        A Record that maps every dynamic property in nodeUri(), as defined by AgentRoute.pattern(), to its value. An empty result indicates that nodeUri contains no dynamic components.
      • getProp

        public final Value getProp​(Value key)
        Returns the value of key in props().
      • getProp

        public final Value getProp​(String name)
        Returns the value of name in props().
      • schedule

        public final Schedule schedule()
        The Schedule that this Agent is bound to.
      • stage

        public final Stage stage()
        The single-threaded execution Stage on which this AgentContext runs its application logic.
      • asyncStage

        public final Stage asyncStage()
        The multi-threaded execution Stage on which this AgentContext can 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.
      • getLane

        public final Lane getLane​(Uri laneUri)
      • openLane

        public final Lane openLane​(Uri laneUri,
                                   Lane lane)
      • getAgent

        public <A extends Agent> A getAgent​(Class<A> agentClass)
      • openAgent

        public <A extends Agent> A openAgent​(Value id,
                                             Value props,
                                             Class<A> agentClass)
      • openAgent

        public <A extends Agent> A openAgent​(Value id,
                                             Class<A> agentClass)
      • openAgent

        public <A extends Agent> A openAgent​(String name,
                                             Class<A> agentClass)
      • 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.
      • command

        public final void command​(Uri hostUri,
                                  Uri nodeUri,
                                  Uri laneUri,
                                  float prio,
                                  Value body)
        Specified by:
        command in interface WarpRef
      • command

        public final void command​(Uri hostUri,
                                  Uri nodeUri,
                                  Uri laneUri,
                                  Value body)
        Specified by:
        command in interface WarpRef
      • command

        public final void command​(Uri nodeUri,
                                  Uri laneUri,
                                  float prio,
                                  Value body)
        Specified by:
        command in interface WarpRef
      • command

        public final void command​(Uri nodeUri,
                                  Uri laneUri,
                                  Value body)
        Specified by:
        command in interface WarpRef
      • trace

        public void trace​(Object message)
        Description copied from interface: Log
        Logs a trace-level message.
        Specified by:
        trace in interface Log
      • debug

        public void debug​(Object message)
        Description copied from interface: Log
        Logs a debug-level message.
        Specified by:
        debug in interface Log
      • info

        public void info​(Object message)
        Description copied from interface: Log
        Logs an info-level message.
        Specified by:
        info in interface Log
      • warn

        public void warn​(Object message)
        Description copied from interface: Log
        Logs a warn-level message.
        Specified by:
        warn in interface Log
      • error

        public void error​(Object message)
        Description copied from interface: Log
        Logs an error-level message.
        Specified by:
        error in interface Log
      • fail

        public void fail​(Object message)
        Description copied from interface: Log
        Logs an fail-level message.
        Specified by:
        fail in interface Log
      • timer

        public final TimerRef timer​(TimerFunction timer)
        Description copied from interface: Schedule
        Returns an unscheduled TimerRef bound to timer, which can later be used to schedule timer.
        Specified by:
        timer in interface Schedule
      • setTimer

        public final TimerRef setTimer​(long millis,
                                       TimerFunction timer)
        Description copied from interface: Schedule
        Schedules timer to execute after millis milliseconds have elapsed. Returns a TimerRef that can be used to check the status of, reschedule, and cancel timer.
        Specified by:
        setTimer in interface Schedule
      • close

        public void close()
        Specified by:
        close in interface WarpRef