Package com.atlassian.crowd.core.event
Class TransactionAwareEventPublisher
java.lang.Object
com.atlassian.crowd.core.event.DelegatingMultiEventPublisher
com.atlassian.crowd.core.event.TransactionAwareEventPublisher
- All Implemented Interfaces:
MultiEventPublisher,com.atlassian.event.api.EventListenerRegistrar,com.atlassian.event.api.EventPublisher
public class TransactionAwareEventPublisher
extends DelegatingMultiEventPublisher
implements com.atlassian.event.api.EventPublisher, MultiEventPublisher
Delays publishing any events if a transaction is active, until that transaction commits.
Events not published in transaction are unaffected. If the active transaction is rolled back, the events are not published.
Note that any transactional operations done in afterCommit(), need to be wrapped in a PROPAGATION_REQUIRES_NEW transaction,
(see TransactionSynchronization.afterCommit()). This is guaranteed by
TransactionAwareEventDispatcher
Since publishing an event during a transaction causes a TransactionSynchronization
to be registered for cases where many events are sent at once, it makes sense to use publishAll(Collection), to wrap them
in a single TransactionSynchronization, as transaction performance degrades notably with the number of distinct synchronizations registered.
-
Field Summary
Fields inherited from class com.atlassian.crowd.core.event.DelegatingMultiEventPublisher
delegate -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidpublishAll(Collection<Object> events) Publish events that will be consumed by their respective registered listeners.Methods inherited from class com.atlassian.crowd.core.event.DelegatingMultiEventPublisher
register, unregister, unregisterAllMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.atlassian.event.api.EventListenerRegistrar
register, unregister, unregisterAll
-
Method Details
-
publish
- Specified by:
publishin interfacecom.atlassian.event.api.EventPublisher- Overrides:
publishin classDelegatingMultiEventPublisher
-
publishAll
Description copied from interface:MultiEventPublisherPublish events that will be consumed by their respective registered listeners. This should be equivalent with callingEventPublisher.publish(Object)for every event in the collection.- Specified by:
publishAllin interfaceMultiEventPublisher- Overrides:
publishAllin classDelegatingMultiEventPublisher
-