コード例 #1
0
  /**
   * @return null means that the default payload factories will be used; this is handled within
   *     IsisTransaction.
   */
  private static PublishingPayloadFactoryForAction newPayloadFactory(final Action action) {
    if (action == null) {
      return null;
    }
    final Class<? extends PublishingPayloadFactoryForAction> payloadFactoryClass =
        action.publishingPayloadFactory();
    if (payloadFactoryClass == null) {
      return null;
    }

    try {
      return payloadFactoryClass.newInstance();
    } catch (final InstantiationException e) {
      return null;
    } catch (final IllegalAccessException e) {
      return null;
    }
  }
コード例 #2
0
  public static PublishedActionFacet create(
      final Action action, final IsisConfiguration configuration, final FacetHolder holder) {

    final Publishing publishing = action != null ? action.publishing() : Publishing.AS_CONFIGURED;

    switch (publishing) {
      case AS_CONFIGURED:
        final PublishActionsConfiguration setting =
            PublishActionsConfiguration.parse(configuration);
        switch (setting) {
          case NONE:
            return null;
          case IGNORE_SAFE:
            final ActionSemanticsFacet actionSemanticsFacet =
                holder.getFacet(ActionSemanticsFacet.class);
            if (actionSemanticsFacet == null) {
              throw new IllegalStateException("Require ActionSemanticsFacet in order to process");
            }

            if (actionSemanticsFacet.value().isSafeInNature()) {
              return null;
            }
            // else fall through
          default:
            final PublishingPayloadFactoryForAction publishingPayloadFactory =
                newPayloadFactory(action);
            return action != null
                ? new PublishedActionFacetForActionAnnotation(publishingPayloadFactory, holder)
                : new PublishedActionFacetFromConfiguration(publishingPayloadFactory, holder);
        }
      case DISABLED:
        return null;
      case ENABLED:
        return new PublishedActionFacetForActionAnnotation(newPayloadFactory(action), holder);
    }
    return null;
  }