Class UserEmailEntityListener

java.lang.Object
ch.tocco.nice2.usermanager.impl.UserEmailEntityListener
All Implemented Interfaces:
EntityFacadeListener, CommitListener, EventListener

public class UserEmailEntityListener extends Object implements EntityFacadeListener, CommitListener
Sends an email to the "old" email address if the email field of an User has changed. This listener implements the EntityFacadeListener and CommitListener because it needs to know the old value of the field but must not send the email until the new value was saved. It is not possible to get the old value of the field within an CommitListener why it is necessary to combine this two interfaces. In the hivemodule.xml this listener is registered as EntityFacadeListener. If the email field on an user entity was changed the user plus the old value of the field are set as an attribute to the context of the user entity. Also this listener then will be added as CommitListener to the same context so the email can be send after the value was saved within the afterCommit method where this listener then also will be removed again from the context.
  • Constructor Details

  • Method Details

    • entityChanging

      public void entityChanging(EntityChangedEvent event)
      Description copied from interface: EntityFacadeListener
      Fired when any changes are made to an entity.
      Specified by:
      entityChanging in interface EntityFacadeListener
      Parameters:
      event - The event object.
    • beforeCommit

      public void beforeCommit(Transaction tx)
      Description copied from interface: CommitListener

      Notifies about the point where the transaction is about to be committed.

      This allows further modification of involved entities.

      Specified by:
      beforeCommit in interface CommitListener
      Parameters:
      tx - the transaction in question
    • afterCommit

      public void afterCommit(Context context)
      Description copied from interface: CommitListener

      Notifies about the point where the transaction has been fully committed.

      This allows post processing of the entities involved in the previous commit.

      Specified by:
      afterCommit in interface CommitListener