Class DefaultEventStudio

  • All Implemented Interfaces:
    EventStudio

    public class DefaultEventStudio
    extends java.lang.Object
    implements EventStudio
    Default implementation of EventStudio. It doesn't enforce a Singleton pattern and it's up to the user to decide how to use it and how many EventStudio the application needs. A singleton implementation with lazy initialization is provided with StaticStudio where the typical usage is:
     
     import static org.eventstudio.StaticStudio.eventStudio;
     
     public class Foo{
         void doSomethingAndNotify(){
            .....
            eventStudio.broadcast(new ImFinished(), "station");
         } 
     }
     
     

    Hidden Station: The hidden station is a pre-built station with "hidden.station" name that is used to hide the station abstraction. Helper method are provided by DefaultEventStudio where the station name parameter is missing from the parameters list and the HIDDEN_STATION is used, providing a more traditional event bus pub/sub pattern.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> void add​(java.lang.Class<T> eventClass, Listener<T> listener)
      Adds a Listener to the hidden station listening for the given event class, hiding the station abstraction.
      <T> void add​(java.lang.Class<T> eventClass, Listener<T> listener, int priority, ReferenceStrength strength)
      Adds a Listener (with the given priority and strength ) to the hidden station listening for the given event class, hiding the station abstraction.
      <T> void add​(java.lang.Class<T> eventClass, Listener<T> listener, java.lang.String station)
      Adds the given Listener, listening for the given event class, to the given station using default priority(0) ad default strength ReferenceStrength.STRONG.
      <T> void add​(java.lang.Class<T> eventClass, Listener<T> listener, java.lang.String station, int priority, ReferenceStrength strength)
      Adds the given Listener, listening for the given event class, to the given station using the given priority (low values mean higher priority) and strength.
      <T> void add​(Listener<T> listener)
      Adds a Listener to the hidden station, hiding the station abstraction.
      <T> void add​(Listener<T> listener, int priority, ReferenceStrength strength)
      Adds a Listener (with the given priority and strength ) to the hidden station, hiding the station abstraction.
      <T> void add​(Listener<T> listener, java.lang.String station)
      Adds the given Listener to the given station using default priority(0) ad default strength ReferenceStrength.STRONG.
      <T> void add​(Listener<T> listener, java.lang.String station, int priority, ReferenceStrength strength)
      Adds the given Listener to the given station using the given priority (low values mean higher priority) and strength.
      void addAnnotatedListeners​(java.lang.Object bean)
      Discovers annotated method on the the given bean and adds them as Listeners
      void broadcast​(java.lang.Object event)
      Boradcast the event to the hidden station
      void broadcast​(java.lang.Object event, java.lang.String station)
      Broadcasts the given event to the given station.
      void broadcastToEveryStation​(java.lang.Object event)
      Broadcasts the given event to every station.
      void clear()
      Clears the hidden station
      void clear​(java.lang.String station)
      Clear the given station removing the whole station from the EventStudio which means that Listeners and Supervisor will not be notified anymore.
      <T> boolean remove​(java.lang.Class<T> eventClass, Listener<T> listener)
      Removes the given listener listening on the given event, from the hidden station, hiding the station abstraction.
      <T> boolean remove​(java.lang.Class<T> eventClass, Listener<T> listener, java.lang.String station)
      Removes the first occurrence of the given Listener listening for the given event, from the given station
      <T> boolean remove​(Listener<T> listener)
      Removes the given listener from the hidden station, hiding the station abstraction.
      <T> boolean remove​(Listener<T> listener, java.lang.String station)
      Removes the first occurrence of the given Listener from the given station.
      void supervisor​(Supervisor supervisor)
      Adds a Supervisor to the hidden station, hiding the station abstraction.
      void supervisor​(Supervisor supervisor, java.lang.String station)
      Sets a Supervisor for the given station.
      • Methods inherited from class java.lang.Object

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

      • HIDDEN_STATION

        public static final java.lang.String HIDDEN_STATION
        A reserved station name that is used to hide the station abstraction. Using the provided helper methods the station concept remains totally hidden and EventStudio can be used as a more traditional Event Bus with pub/sub pattern.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultEventStudio

        public DefaultEventStudio()