Class EventHandler

java.lang.Object
ch.autumo.beetroot.crud.EventHandler

public class EventHandler extends Object
CRUD event handler. Don't add CRUD handlers as listeners; this wouldn't be a good idea!
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
  • Method Details

    • getInstance

      public static EventHandler getInstance()
      Get event handler (singleton).
      Returns:
      event handler
    • addCreateListener

      public void addCreateListener(Class<?> entityClass, CreateListener listener)
      Add a create listener for create notifications for a specific entity.
      Parameters:
      entityClass - entity
      listener - create listener
    • addUpdateListener

      public void addUpdateListener(Class<?> entityClass, UpdateListener listener)
      Add an update listener for update notifications for a specific entity.
      Parameters:
      entityClass - entity
      listener - update listener
    • addDeleteListener

      public void addDeleteListener(Class<?> entityClass, DeleteListener listener)
      Add a delete listener for delete notifications for a specific entity.
      Parameters:
      entityClass - entity
      listener - delete listener
    • notifyAfterCreate

      public void notifyAfterCreate(Class<?> entityClass, int id)
      Notify create listeners for after-create and specific entity.
      Parameters:
      entityClass - entity
      id - id
    • notifyBeforeUpdate

      public boolean notifyBeforeUpdate(Class<?> entityClass, int id)
      Notify update listeners for before-update and specific entity. Every called listener can abort the update!
      Parameters:
      entityClass - entity
      id - id
      Returns:
      true, if update should be aborted, otherwise false
    • notifyAfterUpdate

      public void notifyAfterUpdate(Class<?> entityClass, int id)
      Notify update listeners for after-update and specific entity.
      Parameters:
      entityClass - entity
      id - id
    • notifyBeforeDelete

      public boolean notifyBeforeDelete(Class<?> entityClass, int id)
      Notify delete listeners for before-delete and specific entity. Every called listener can abort the deletion!
      Parameters:
      entityClass - entity
      id - id
      Returns:
      true, if deletion should be aborted, otherwise false