All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xapi.util.impl.RemovesMultiHandlers Maven / Gradle / Ivy

Go to download

This module exists solely to package all other gwt modules into a single uber jar. This makes deploying to non-mavenized targets much easier. Of course, you would be wise to inherit your dependencies individually; the uber jar is intended for projects like collide, which have complex configuration, and adding many jars would be a pain.

The newest version!
package xapi.util.impl;

import xapi.collect.api.Fifo;
import xapi.collect.impl.SimpleFifo;
import xapi.util.api.RemovalHandler;

/**
 * Handy wrapper class for bundling multiple RemovesHandlers into a single callback.
 *
 * Most often used to combie multiple RemovalHandler objects into a single returned object.
 *
 * @author James X. Nelson ([email protected], @james)
 *
 */
public class RemovesMultiHandlers implements RemovalHandler{

  private final Fifo handles;
  public RemovesMultiHandlers() {
    // we by default use the simple, concurrent fifo, to avoid dependency
    // on the injection library too early in our module structure
    handles = new SimpleFifo();
  }

  @Override
  public void remove() {
    while(!handles.isEmpty()){
      RemovalHandler handle = handles.take();
      handle.remove();
    }
  }
  /**
   * Push a handler onto our callback stack
   *
   * @param handle - Handler to be called on remove
   * @return - this, for chaining
   */
  public RemovesMultiHandlers addHandler(RemovalHandler handle){
    handles.give(handle);
    return this;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy