public class TransactionMessageBus
extends java.lang.Object
TransactionListenerI instances and orchestrates the dispatch
of transaction-related events.
This class serves as a central message bus with two primary responsibilities:
TransactionListenerI| Constructor and Description |
|---|
TransactionMessageBus()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the message bus and releases resources.
|
void |
consumeAfterSetMessage(SetValueEventI changeEvent)
Consumes a change event and queues a corresponding virtual message for listeners.
|
static void |
consumeScriptedAttributeChange(SetValueEventI changeEvent)
Static helper to bridge scripted attribute changes into the message bus.
|
boolean |
createAfterAddMessage(BO bo,
AttributeI attribute,
BO addedBO)
Creates and queues a virtual event indicating an element has been added to a many-relation attribute.
|
boolean |
createAfterRemoveMessage(BO bo,
AttributeI attribute,
BO removedBO)
Creates and queues a virtual event indicating an element has been removed from a many-relation attribute.
|
boolean |
createAfterSetMessage(BO bo,
AttributeI attribute,
java.lang.Object newValue)
Creates and queues a new change message for setting a scalar or n-1 relation.
|
boolean |
createAfterSetMessage(BO bo,
AttributeI attribute,
java.lang.Object newValue,
java.lang.Object oldValue) |
void |
disableSynchronousEventsForUnittests()
Disables synchronous event dispatching.
|
void |
enableSynchronousEventsForUnittests()
Enables synchronous event dispatching (for Unit Tests).
|
boolean |
enqueueProc(BOProc proc)
Enqueues a single BOProc and triggers processing.
|
boolean |
enqueueProcs(java.util.List<BOProc> procs)
Enqueues a list of BOProcs.
|
void |
fireCheckPoint()
Triggers the checkpoint event on all registered listeners.
|
void |
forceResumeFiringNewProcs()
Forcefully ignores previous pause requests from any source and re-enables event firing.
|
boolean |
isAcceptingMessages()
Determines if the bus is currently operational.
|
boolean |
isEventFiringPaused()
Checks if the notification system is currently paused.
|
static void |
killNewProcsRunner()
Stops the background thread responsible for processing events.
|
void |
newProcSync()
Blocks until the event backlog is cleared and all listeners have been informed.
|
void |
notifyFiredProcWaits()
Notifies threads waiting on the backlog lock.
|
void |
notifyTransactionListeners()
Notifies listeners of pending changes.
|
void |
pauseFiringNewProcs()
Pauses notifications for all consumers.
|
void |
registerListener(de.ipcon.db.core.TransactionListenerI l)
Registers a listener to receive notification on new changes from this point forward.
|
void |
removeAllListeners()
Removes all registered listeners.
|
void |
resumeFiringNewProcs()
Decrements the pause counter and resumes firing of new procs if the counter reaches zero.
|
void |
unregisterListener(de.ipcon.db.core.TransactionListenerI l)
Unregisters a listener, preventing it from receiving further notifications.
|
public void close()
This method clears the listeners map and the event queue, effectively stopping any further event processing or notifications.
public boolean isEventFiringPaused()
If this returns true but isAcceptingMessages() is also true,
messages will be queued and delayed until messaging resumes.
true if notification of listeners has been explicitly paused; false otherwise.public void pauseFiringNewProcs()
This supports re-entrancy: multiple calls to this method require an equal number
of resumeFiringNewProcs() calls to re-enable firing.
public void resumeFiringNewProcs()
Will directly trigger a notification flush if firing is successfully resumed and listeners are available.
public void forceResumeFiringNewProcs()
Use with caution: This overrides nested pause locks.
public static void killNewProcsRunner()
This should only be called if a classloader is disposed of or during application shutdown.
public void registerListener(de.ipcon.db.core.TransactionListenerI l)
l - The listener to register (must be non-null).public void unregisterListener(de.ipcon.db.core.TransactionListenerI l)
l - The listener to remove (must be non-null).public void removeAllListeners()
public void notifyTransactionListeners()
public void fireCheckPoint()
Iterates through all listeners and calls their TransactionListenerI.checkPoint() method.
Exceptions thrown by individual listeners are caught and logged to ensure that
notification continues for other listeners.
public void newProcSync()
java.lang.IllegalStateException - if firing new procs is currently paused.public void notifyFiredProcWaits()
This is used to signal methods like newProcSync() that the event queue
processing cycle has completed or the queue state has changed.
public boolean isAcceptingMessages()
true if this message bus can consume and notify listeners.public void enableSynchronousEventsForUnittests()
public void disableSynchronousEventsForUnittests()
public static void consumeScriptedAttributeChange(SetValueEventI changeEvent)
This method calls consumeAfterSetMessage(SetValueEventI) on the MessageBus
associated with the BO's loading transaction. It is the default callback for
ScriptedAttribute changes, capable of handling BOs from cascaded InstrumentedSchemas.
changeEvent - The event detailing the attribute change.public void consumeAfterSetMessage(SetValueEventI changeEvent)
This method determines whether the event represents a value set, an addition, or a removal, and delegates to the appropriate creation method.
changeEvent - The event containing details about the change (BO, attribute, value).
Must not be null.public boolean createAfterSetMessage(BO bo, AttributeI attribute, java.lang.Object newValue)
Contract: If newValue is provided, attribute is mandatory.
Otherwise, both are currently optional (though providing them is best practice).
bo - The BO which was changed virtually. Must be non-null.attribute - The nullable attribute that was changed. While this method doesn't validate
if the attribute is truly virtual, it is intended for virtual attributes.
(Persistent attributes generate procs automatically via the transaction).newValue - The new value to put into the notification. Can be null if the value
isn't available directly and the up-to-date value must be fetched by the view.oldValue - A nullable and optional old value to include in the event.
Provide this only if readily available, as it is often ignored by listeners.true if the message has been queued; false if queuing failed.public boolean createAfterSetMessage(BO bo, AttributeI attribute, java.lang.Object newValue, java.lang.Object oldValue)
public boolean createAfterAddMessage(BO bo, AttributeI attribute, BO addedBO)
This method is a convenience wrapper that delegates to createAfterManyChangeMessage(BO, AttributeI, BO, boolean)
with the isAdded flag set to true.
bo - The owner BO.attribute - The relation attribute.addedBO - The business object that was added to the relation.true if the message was successfully created and queued; false otherwise.public boolean createAfterRemoveMessage(BO bo, AttributeI attribute, BO removedBO)
This method is a convenience wrapper that delegates to createAfterManyChangeMessage(BO, AttributeI, BO, boolean)
with the isAdded flag set to false.
bo - The owner BO.attribute - The relation attribute.removedBO - The business object that was removed from the relation.true if the message was successfully created and queued; false otherwise.public boolean enqueueProc(BOProc proc)
Note: This will not fill the queue if there are no listeners, or if the proc trigger is not running (e.g. in a headless environment).
proc - The proc to put into the virtual queue. Must be non-null.true if the proc has been queued, false otherwise.public boolean enqueueProcs(java.util.List<BOProc> procs)
procs - The list of procs to queue.true if successful.Copyright © 2000-2026 OAshi S.à r.l. All Rights Reserved.