java.lang.Object
it.rebirthproject.ufoeb.architecture.eventbus.EventBusBuilder

public final class EventBusBuilder extends Object
A builder which can be used to create an EventBus
  • Field Details

    • queueLength

      private Integer queueLength
      The length of the infrastructure internal queues used by the EventBusInfrastructure. Basically the length is important for the commandQueryMessageQueue of the BusMemoryStateManager to avoid the block of the BusMemoryStateManager and should be calculated correctly depending on the pressure of the application that uses the bus (posts speed, number of posting threads, and so on). The default number of workers is 100.
    • numberOfWorkers

      private Integer numberOfWorkers
      The number of internal workers used by the EventBus behind the scenes to process posted events and notify listeners. The default number of workers is 1.
    • safeRegistrationsListNeeded

      private boolean safeRegistrationsListNeeded
      This parameter ensures that workers gets an unmodifiable Registration's list. For best performance leave this parameter to false (default) and avoid to register/unregister listeners at runtime time. Otherwise, set it to true.
    • listenerSuperclassInheritance

      private boolean listenerSuperclassInheritance
      This parameter should be used when you want to use inheritance over a listener and all its superclasses. Enabling it will let the bus look for all listeners' methods considering also all their superclasses methods. The default value is to look for only the listener's class methods.
    • useLambdaFactoryInsteadOfStandardReflection

      private boolean useLambdaFactoryInsteadOfStandardReflection
      This parameter should be used when you want to use spped up listener's methods call. Instead the standard reflection getMethod() workers will use the method handler created by the lambdafactory getMethodHandler(). Very useful when listener's methods are not time consuming. Anyway beware that MethodHandles.lookup() does not work with modules and with java 9> when a listener class is located in a different module than the eventbus's one. So basically this will work always with java 8. And with java 9> when you do not use modules, for example in an application. If you want to create a library with java 9> that uses the ufoeventbus then you must use the default method. For more informations see https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/invoke/MethodHandles.Lookup.html
    • throwNoListenerAnnotationException

      private boolean throwNoListenerAnnotationException
      If a registering listener does not have any Listen annotated method or, in case of event inheritance enabled, also its super classes or interfaces does not have any Listen annotated method, then an EventBusException is thrown.
    • throwNoRegistrationsWarning

      private boolean throwNoRegistrationsWarning
      Sets the bus to log warnings when no registration is found for a specific event. If not set, no warning will be printed to the log. This is useful to debug application.

      Example:

       Event E is posted to the bus but no Listener is registered to listen to it.
       

    • throwNotValidMethodException

      private boolean throwNotValidMethodException
      if set then an EventBusException is thrown when an invalid Listen annotated method is found in a Listener.

      The method must be defined using the following rules:

      1. The method must be public and not static
      2. The method must have only one parameter that represents the listened event

    • eventInheritancePolicy

      private InheritancePolicy eventInheritancePolicy
      The events InheritancePolicy used by the eventbus. The default value for the inheritance policy is NoEventInheritancePolicy
      See Also:
    • inheritancePackageFrontierPath

      private String inheritancePackageFrontierPath
      The #inheritancePackageFrontierPath is used to stop the iteration over classes while using event inheritance. If a class belongs to the set package then the iteration stops. This parameter must be used only when event inheritance policy is enabled otherwise it is useless even if set.

      Example:

       Class A extends class B and is defined under x.y.z java package
       Class B is defined under x.y java package
       inheritancePackageFrontierPath is defined to x.y,z
      Then the iteration will stop when it reaches class A without iterating on its parent class.

      See Also:
    • verboseLogging

      private boolean verboseLogging
      Boolean attribute used to enable or disable verbose logging
  • Constructor Details

    • EventBusBuilder

      public EventBusBuilder()
  • Method Details