Class AnnotatedMethodInvokingEntityEventListener

  • All Implemented Interfaces:
    io.micronaut.core.order.Ordered, EntityEventListener<java.lang.Object>, java.util.EventListener

    @Singleton
    public class AnnotatedMethodInvokingEntityEventListener
    extends java.lang.Object
    implements EntityEventListener<java.lang.Object>
    Event listener that allows invoking methods defined on entities and annotated with an event annotation such as PrePersist.
    Since:
    2.3.0
    Author:
    graemerocher
    • Constructor Detail

      • AnnotatedMethodInvokingEntityEventListener

        public AnnotatedMethodInvokingEntityEventListener()
    • Method Detail

      • supports

        public boolean supports​(RuntimePersistentEntity<java.lang.Object> entity,
                                java.lang.Class<? extends java.lang.annotation.Annotation> eventType)
        Description copied from interface: EntityEventListener
        Allows including or excluding a listener for a specific entity.
        Specified by:
        supports in interface EntityEventListener<java.lang.Object>
        Parameters:
        entity - The entity
        eventType - The event type
        Returns:
        True if it is supported
      • prePersist

        public boolean prePersist​(@NonNull
                                  EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A pre-persist hook. Implementors can return false to evict the operation.
        Specified by:
        prePersist in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object
        Returns:
        A boolean value indicating whether to proceed with the operation.
      • postPersist

        public void postPersist​(@NonNull
                                EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A post-persist hook. Executed once the object has been persisted.
        Specified by:
        postPersist in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object
      • postLoad

        public void postLoad​(@NonNull
                             EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A post-load hook. Executed once the object has been persisted.
        Specified by:
        postLoad in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object
      • preRemove

        public boolean preRemove​(@NonNull
                                 EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A pre-remove hook. Implementors can return false to evict the operation.
        Specified by:
        preRemove in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object
        Returns:
        A boolean value indicating whether to proceed with the operation.
      • postRemove

        public void postRemove​(@NonNull
                               EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A post-remove hook. Executed once the object has been removed.
        Specified by:
        postRemove in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object
      • preUpdate

        public boolean preUpdate​(@NonNull
                                 EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A pre-update hook. Implementors can return false to evict the operation.
        Specified by:
        preUpdate in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object
        Returns:
        A boolean value indicating whether to proceed with the operation.
      • postUpdate

        public void postUpdate​(@NonNull
                               EntityEventContext<java.lang.Object> context)
        Description copied from interface: EntityEventListener
        A post-update hook. Executed once the object has been updated.
        Specified by:
        postUpdate in interface EntityEventListener<java.lang.Object>
        Parameters:
        context - The context object