Esempio n. 1
0
  /**
   * Returns required attachment value from deployment unit.
   *
   * @param <A> expected value
   * @param unit deployment unit
   * @param key attachment key
   * @return required attachment
   * @throws IllegalStateException if attachment value is null
   */
  public static <A> A getRequiredAttachment(final DeploymentUnit unit, final AttachmentKey<A> key) {
    final A value = unit.getAttachment(key);
    if (value == null) {
      ASHelper.LOGGER.error("Cannot find attachment in deployment unit: " + key);
      throw new IllegalStateException();
    }

    return value;
  }