Inherits Runnable.
static< PRODUCER_TYPE > PRODUCER_TYPE | bind (PRODUCER_TYPE producer, Object...consumers) throws IllegalArgumentException |
static< PRODUCER_TYPE > PRODUCER_TYPE | unbind (PRODUCER_TYPE producer, Object...consumers) throws IllegalArgumentException |
static< PRODUCER_TYPE > PRODUCER_TYPE | fire (PRODUCER_TYPE producer, Object event, String...tags) throws IllegalArgumentException |
static void | disable () |
static boolean | isDisabled () |
static void | enable () throws IllegalStateException |
static void | registerStrategy (EventHandlerStrategy strategy) |
static ExecutorService | getExecutorService () |
static void | setExecutorService (ExecutorService executorService) |
static ErrorHandler | getErrorHandler () |
static void | setErrorHandler (ErrorHandler errorHandler) throws IllegalArgumentException |
void | run () |
The most important class for events-on-fire.
For a detailed usage description see Usage on Google Project Hosting.
All references to producers and consumers in this class are weak, unless otherwise noted. Any producer or consumer will get garbage collected, if there is no reference to it outside this class. All checks will be made on identity instead of equality.
|
static |
Binds the specified consumer / listener to the specified instance of class of a producer. The producer may either be an instance or a class reference.
Object.class
reference, then the consumer get notified by all events it can handle).
|
static |
Disables events from the current thread.
Make sure to call the enable method by using a finally block! Multiple calls to disable, increase a counter and it is necessary to call enable as often as you have called disable.
|
static |
Enables events from the current thread.
It is wise to place call to this method within a finally block. Multiple calls to disable, increase a counter and it is necessary to call enable as often as you have called disable.
IllegalStateException | if events from the current thread are not disabled |
|
static |
Fires the specified event from the specified instance of a producer. Notifies all consumers that are either directly bonded to the producer or that are bonded to the class, any sub-class or any interface of the producer.
Calls the appropriate } public void handleEvent(* event) method of all consumers. Does nothing, if events are disabled for the current thread. Does nothing, if there are no consumers bonded to the producer.
producer | the producer, mandatory |
event | the event, mandatory |
tags,optional,can | be checked against tags in annotations |
IllegalArgumentException | if the producer or the event is null |
|
static |
Returns the error handler, the DefaultErrorHandler if not specified.
|
static |
Returns the executor service for event handler that are executed using pooled threads. The default value is a fixed thread pool using a maximum of 4 threads.
|
static |
Returns true if events from the current thread are disabled.
|
static |
Registers a strategy for event handlers. The strategy decides for a method of a consumer, whether it is capable of handling events or not. By default there exist strategies for following annotations: EventHandler, PooledEventHandler and SwingEventHandler.
strategy | the strategy, never null |
void org.qscript.eventsonfire.Events.run | ( | ) |
Worker for pending actions. There is no need to call this method.
|
static |
Sets the error handler.
errorHandler | the error handler, mandatory |
IllegalArgumentException | if the error handler is null |
|
static |
Sets the executor service for event handlers that are executed using pooled threads.
executorService | the executor service, mandatory |
IllegalArgumentException | if the executor service is null |
|
static |
Unbinds the specified consumer from the specified instance or class of a producer. The producer may either be an instance or a class reference.
Object.class
reference, then the consumer get unbonded from all producers). Does nothing if the objects are not bonded.
producer | the instance or class of a producer, mandatory |
consumers | one or more consumers / listeners, mandatory |
IllegalArgumentException | if the producer or the consumers are null |