org.entityfs.impl.event
Interface EventManager

All Known Implementing Classes:
DisabledEventManager, EventManagerImpl

public interface EventManager

A file system's event manager is used to fire entity events. Entities that want to stall events can increment the entity manager's hold count (and decrement it again in a finally block). The hold count is a thread local variable.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-core

Method Summary
 void decrementHoldCount()
          Decrement the thread local hold count.
 void fireEvent(EntityEvent<?> ev)
          Fire an entity event.
 int getHoldCount()
          Get the current thread's hold count.
 void incrementHoldCount()
          Increment the thread local hold count for the entity manager.
 boolean isEnabled()
          Are events enabled for this file system?
 

Method Detail

isEnabled

boolean isEnabled()
Are events enabled for this file system?

Returns:
true if events are enabled for this file system.

fireEvent

void fireEvent(EntityEvent<?> ev)
Fire an entity event. If the entity manager's hold count is 0, the event is fired right away. If it is > 0, it is saved and fired when the hold count decreases to 0 again.

Parameters:
ev - The event (contains a reference to the entity that sent it).

incrementHoldCount

void incrementHoldCount()
Increment the thread local hold count for the entity manager. If the hold count is > 0, events are queued up internally and sent when the hold count is decremented to 0 again.

See Also:
decrementHoldCount(), getHoldCount()

decrementHoldCount

void decrementHoldCount()
                        throws IllegalStateException
Decrement the thread local hold count. If the hold count reaches 0, all queued events for the current thread are fired.

Throws:
IllegalStateException - If the hold count already is zero.
See Also:
incrementHoldCount(), getHoldCount()

getHoldCount

int getHoldCount()
Get the current thread's hold count.

Returns:
The current thread's hold count.