Package ch.tocco.nice2.usermanager.impl
Class UserEmailEntityListener
java.lang.Object
ch.tocco.nice2.usermanager.impl.UserEmailEntityListener
- All Implemented Interfaces:
EntityFacadeListener
,CommitListener
,EventListener
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 Summary
ConstructorDescriptionUserEmailEntityListener
(MailFactory mailFactory, EmailTemplateLoadService emailTemplateLoadService, L10N l10N, org.slf4j.Logger log) -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterCommit
(Context context) Notifies about the point where the transaction has been fully committed.void
Notifies about the point where the transaction is about to be committed.void
entityChanging
(EntityChangedEvent event) Fired when any changes are made to an entity.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.util.CommitListener
afterFlush, priority
Methods inherited from interface ch.tocco.nice2.persist.core.api.entity.events.EntityFacadeListener
entityCreating, entityDeleting, entityReceivedValues, entityRelationChanging, handleSessionOnlyEntity
-
Constructor Details
-
UserEmailEntityListener
public UserEmailEntityListener(MailFactory mailFactory, EmailTemplateLoadService emailTemplateLoadService, L10N l10N, org.slf4j.Logger log)
-
-
Method Details
-
entityChanging
Description copied from interface:EntityFacadeListener
Fired when any changes are made to an entity.- Specified by:
entityChanging
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
beforeCommit
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 interfaceCommitListener
- Parameters:
tx
- the transaction in question
-
afterCommit
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 interfaceCommitListener
-