Module aeonics.core

Class Origin

  • Direct Known Subclasses:
    HttpServer, Origin.Basic, Origin.Scheduled

    public abstract class Origin
    extends Item<Origin.Type>
    This class represents the Origin of data. It is the starting point of a data flow.

    For each mew message, you should call the Origin.Type.emit(Message, String) method to inject data in the system, which will transfer the message according to the related topics.

    This class offers an incomplete Origin.Template that defines the relationship with Topic. You should thus extend this template in your implementation.

    There are two recommended ways to create your own item inline (without creating a full class). The first method allows to provide the data collector function and registers automatically the template in the factory and the instance in the registry:

     Origin.Type item = new Origin() { } // <-- note the '{ }' to create a new anonymous class
         
         // specify which variant to use
         .target(Origin.Background.class)
         .creator(Origin.Background::new)
         
         .template() // <-- create the template and register it in the factory
         
         // add all your template documentation
         .summary("Does something")
         
         .create() // <-- create an instance of the entity and register it in the registry
         
         // set the processing function
         .<Origin.Background>cast()
         .run(() -> { })
     

    If you need more control over the behavior such as private member variables or multiple methods, then you need to declare a custom entity end register it before calling the template method:

     public static class MyEntity extends Origin.Type {
         private void start() { }
         public void stop() { }
     }
     
     Origin.Type item = new Origin() { } // <-- note the '{ }' to create a new anonymous class
         
         // register the custom entity before calling the template
         .target(MyEntity.class)
         .creator(MyEntity::new)
         
         .template() // <-- create the template and register it in the factory
         
         // add all your template documentation
         .summary("Do something")
         
         .create(); // <-- create an instance of the entity and register it in the registry
     
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Origin.Background
      This class represents a data Origin that runs in the background in order to collect data and inject it in the system.
      static class  Origin.Basic
      This class represents a basic data Origin that has no predefined behavior.
      static class  Origin.NetworkClient
      This class represents a data Origin that connects to a remote network endpoint to fetch data.
      static class  Origin.NetworkServer
      This class represents a data Origin that listens for network data.
      static class  Origin.Scheduled
      This class represents a data Origin that is activated at regular interval.
      static class  Origin.Template
      Superclass template for actions
      static class  Origin.Type
      Superclass for all origin entities.
    • Constructor Summary

      Constructors 
      Constructor Description
      Origin()  
    • Constructor Detail

      • Origin

        public Origin()
    • Method Detail

      • defaultTarget

        protected java.lang.Class<? extends Origin.Type> defaultTarget()
        Description copied from class: Item
        Returns the default target entity type. This method should be implemented by subclasses to specify the target entity type.
        Specified by:
        defaultTarget in class Item<Origin.Type>
        Returns:
        the default target entity type
      • defaultCreator

        protected java.util.function.Supplier<? extends Origin.Type> defaultCreator()
        Description copied from class: Item
        Returns the default target entity creator. This method should be implemented by subclasses to specify the entity creator.
        Specified by:
        defaultCreator in class Item<Origin.Type>
        Returns:
        the default target entity creator
      • category

        protected java.lang.Class<? extends Origin> category()
        Description copied from class: Item
        Returns the target entity category. This method should be implemented by subclasses to specify the entity category.
        Specified by:
        category in class Item<Origin.Type>
        Returns:
        the target entity category
      • template

        public Origin.Template template()
        Description copied from class: Item
        Returns the template to build the target entity.

        This method should ultimately be used to provide the final entity template. Although, it may also provide a partial template that subclassed may complement.

        Overrides:
        template in class Item<Origin.Type>
        Returns:
        the matching entity template