Package org.jboss.weld.event
Class FastEvent<T>
- java.lang.Object
-
- org.jboss.weld.event.FastEvent<T>
-
- Type Parameters:
T
- event type
public class FastEvent<T> extends Object
An optimized internal facility for dispatching events.FastEvent eliminates most of the overhead associated with request dispatching by resolving observer methods upfront. It is therefore suitable for cases when certain event is dispatched repeatedly. A FastEvent instance should be created once for a given event type / qualifiers combination and then reused every time a given event is dispatched.
FastEvent provides a subset of functionality provided by
Event
and these additional constraints apply to its usage:- Event type and qualifiers must be known at FastEvent construction time. The actual type of the event object passed to the
fire(Object)
method is not considered for observer method resolution. - Events dispatched using FastEvent are always delivered immediately. If an observer method is transactional it will not be notified
- FastEvent is not serializable
These constraints should always be carefully considered when deciding whether to use FastEvent or not. FastEvent is an internal construct and should not be used by an application.
- Author:
- Jozef Hartinger
-
-
Field Summary
Fields Modifier and Type Field Description protected ResolvedObservers<T>
resolvedObserverMethods
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fire(T event)
static <T> FastEvent<T>
of(Class<T> type, BeanManagerImpl manager, Annotation... qualifiers)
Same asof(Class, BeanManagerImpl, Annotation...)
, just the accessible lenient observer notifier is used for observer method resolutionstatic <T> FastEvent<T>
of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers)
Constructs a new FastEvent instance
-
-
-
Field Detail
-
resolvedObserverMethods
protected final ResolvedObservers<T> resolvedObserverMethods
-
-
Method Detail
-
of
public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, Annotation... qualifiers)
Same asof(Class, BeanManagerImpl, Annotation...)
, just the accessible lenient observer notifier is used for observer method resolution
-
of
public static <T> FastEvent<T> of(Class<T> type, BeanManagerImpl manager, ObserverNotifier notifier, Annotation... qualifiers)
Constructs a new FastEvent instance- Parameters:
type
- the event typemanager
- the bean managernotifier
- the notifier to be used for observer method resolutionqualifiers
- the event qualifiers- Returns:
-
fire
public void fire(T event)
-
-