Class TimeProviderAgent

  • All Implemented Interfaces:
    ITimeService

    public class TimeProviderAgent
    extends java.lang.Object
    implements ITimeService
    The time provider periodically sends out time values to all subscribers. For simplicity, the agent implements the time service itself.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.Map<SubscriptionIntermediateFuture<java.lang.String>,​java.text.DateFormat> subscriptions
      The subscriptions to be informed about the time.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void body​(IInternalAccess ia)
      Due to annotation, called once after agent is initialized.
      IFuture<java.lang.String> getLocation()
      Get the location of the platform, where the time service runs.
      static void main​(java.lang.String[] args)
      Start a Jadex platform and the TimeProviderAgent.
      ISubscriptionIntermediateFuture<java.lang.String> subscribe​(java.text.DateFormat format)
      Subscribe to the time service.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • subscriptions

        protected java.util.Map<SubscriptionIntermediateFuture<java.lang.String>,​java.text.DateFormat> subscriptions
        The subscriptions to be informed about the time.
    • Constructor Detail

      • TimeProviderAgent

        public TimeProviderAgent()
    • Method Detail

      • getLocation

        public IFuture<java.lang.String> getLocation()
        Get the location of the platform, where the time service runs. The location is a constant value for each service, therefore it can be cached and no future is needed.
        Specified by:
        getLocation in interface ITimeService
      • subscribe

        public ISubscriptionIntermediateFuture<java.lang.String> subscribe​(java.text.DateFormat format)
        Subscribe to the time service. Every couple of seconds, a string with the current time will be sent to the subscriber.
        Specified by:
        subscribe in interface ITimeService
      • body

        public void body​(IInternalAccess ia)
        Due to annotation, called once after agent is initialized. The internal access parameter is optional and is injected automatically.
      • main

        public static void main​(java.lang.String[] args)
        Start a Jadex platform and the TimeProviderAgent.