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

com.remondis.limbus.events.EventMulticasterFactory Maven / Gradle / Ivy

Go to download

Module for a datastructure that allows to multicast method invocations to subscribers.

There is a newer version: 3.1.0
Show newest version
package com.remondis.limbus.events;

import com.remondis.limbus.utils.Lang;
import com.remondis.limbus.utils.ReflectionUtil;

/**
 * Factory to create {@link EventMulticaster} instances.
 *
 * @author schuettec
 *
 */
public class EventMulticasterFactory {

  /**
   * Creates an {@link EventMulticaster} for the specified subscriber type. The {@link EventMulticaster} created will
   * forward thrown exceptions from subscribers. Note: An exception aborts the notifaction of further
   * subscribers.
   *
   * @param subscriberType
   *        The subscriber interface.
   *
   * @return Returns the {@link EventMulticaster}.
   */
  public static  EventMulticaster create(Class subscriberType) {
    Lang.denyNull("subscriber type", subscriberType);
    ReflectionUtil.denyNotInterface(subscriberType);

    MulticastHandler handler = new MulticastHandler(subscriberType);
    return handler;
  }

}