Single Service

This example demonstrates four ways of signaling that would surround the execution of code – from low to high-level signaling styles.

package io.opensignals.services.samples;

import io.opensignals.services.Services.*;

import static io.opensignals.services.Services.Orientation.EMIT;
import static io.opensignals.services.Services.Signal.*;
import static io.opensignals.services.Services.*;

final class SingleService {

  private static final Name S1 =
    name ( "com" )
      .name ( "acme" )
      .name ( "service" )
      .name ( "one" );

  public static void main (
    final String[] args
  ) {

    final Context context =
      context ();

    final Service s1 =
      context
        .service (
          S1
        );

    s1.emit ( START );
    s1.emit (
      SUCCEED,
      STOP
    );

    s1.start ( EMIT );
    s1.succeed ( EMIT )
      .stop ( EMIT );

    s1.start ();
    s1.succeed ()
      .stop ();

    execute (
      s1,
      () -> {
      }
    );

  }

}