Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * JBoss, Home of Professional Open Source
   * Copyright 2013, Red Hat, Inc., and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 package org.jboss.weld.event;
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 javax.enterprise.event.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(java.lang.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.

<T> event type
Jozef Hartinger
 public class FastEvent<T> {

Same as of(java.lang.Class,org.jboss.weld.manager.BeanManagerImpl,java.lang.annotation.Annotation[]), just the accessible lenient observer notifier is used for observer method resolution
     public static <T> FastEvent<T> of(Class<T> typeBeanManagerImpl managerAnnotation... qualifiers) {
         return of(typemanagermanager.getAccessibleLenientObserverNotifier(), qualifiers);

Constructs a new FastEvent instance

type the event type
manager the bean manager
notifier the notifier to be used for observer method resolution
qualifiers the event qualifiers
     public static <T> FastEvent<T> of(Class<T> typeBeanManagerImpl managerObserverNotifier notifierAnnotation... qualifiers) {
         ResolvedObservers<T> resolvedObserverMethods = notifier.<T> resolveObserverMethods(notifier.buildEventResolvable(typequalifiers));
         if (resolvedObserverMethods.isMetadataRequired()) {
             EventMetadata metadata = new EventMetadataImpl(typenullqualifiers);
             CurrentEventMetadata metadataService = manager.getServices().get(CurrentEventMetadata.class);
             return new FastEventWithMetadataPropagation<T>(resolvedObserverMethodsmetadatametadataService);
         } else {
             return new FastEvent<T>(resolvedObserverMethods);
     private final ResolvedObservers<T> resolvedObserverMethods;
     private FastEvent(ResolvedObservers<T> resolvedObserverMethods) {
         this. = resolvedObserverMethods;
     public void fire(T event) {
         for (ObserverMethod<? super T> observer : .getImmediateObservers()) {
     private static class FastEventWithMetadataPropagation<T> extends FastEvent<T> {
         private final EventMetadata metadata;
        private final CurrentEventMetadata metadataService;
        private FastEventWithMetadataPropagation(ResolvedObservers<T> resolvedObserverMethodsEventMetadata metadata,
                CurrentEventMetadata metadataService) {
            this. = metadata;
            this. = metadataService;
        public void fire(T event) {
            try {
            } finally {
New to GrepCode? Check out our FAQ X