Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2007-2012 Sonatype, Inc. All rights reserved.
  *
  * This program is licensed to you under the Apache License Version 2.0,
  * and you may not use this file except in compliance with the Apache License Version 2.0.
  * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */
package org.sonatype.sisu.goodies.eventbus.internal;
A Guava org.sonatype.sisu.goodies.eventbus.internal.guava.EventBus that differs from default one by dispatching events as they appear (is re-entrant). Guava will queue up all event and dispatch them in the order they were posted, without re-entrance.

Since:
1.5
@Named("reentrant")
    extends DefaultGuavaEventBus
{

  
List of events for the current thread to dispatch
  protected void enqueueEvent(final Object eventfinal EventHandler handler) {
    if (.get() == null) {
    }
    .get().add(new EventWithHandler(eventhandler));
  }
  protected void dispatchQueuedEvents() {
    final List<EventWithHandlereventWithHandlers = .get();
    if (eventWithHandlers != null) {
      .remove();
      for (final EventWithHandler eventWithHandler : eventWithHandlers) {
        dispatch(eventWithHandler.eventeventWithHandler.handler);
      }
    }
  }
  public String toString() {
    return "Reentrant Guava EventBus";
  }
New to GrepCode? Check out our FAQ X