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

io.github.qsy7.examples.logging.LoggingExampleCommandLineHandler Maven / Gradle / Ivy

There is a newer version: 0.3.3
Show newest version
// Generated by delombok at Fri Apr 08 15:03:16 EDT 2022
package io.github.qsy7.examples.logging;

import io.github.qsy7.heartbeat.Heartbeatable;
import io.github.qsy7.heartbeat.annotation.Heartbeat;
import io.github.qsy7.inject.cli.service.CommandLineHandler;
import io.github.qsy7.logging.annotation.NonLoggable;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import javax.inject.Inject;

public class LoggingExampleCommandLineHandler implements CommandLineHandler, Heartbeatable {
  protected int i = 0;

  //  @Inject
  //  public LoggingExampleCommandLineHandler(
  //      @Property(CommandLineHandlerShutdownTimeout.class) int shutdownTimeoutInSeconds) {
  //    super(shutdownTimeoutInSeconds);
  //  }
  @Heartbeat
  @Override
  public void run(String... arguments) {
    while (true) {
      i++;
      if (i == 4) {
        throw new IllegalStateException("This is a test of the emergency broadcast system ...");
      }
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }

  // test if non-loggable annotation works, yes
  @NonLoggable
  @Override
  public void onHeartbeat() {
  }

  @Override
  public Duration getHeartbeatInterval() {
    return Duration.of(1, ChronoUnit.SECONDS);
  }

  @Inject
  @java.lang.SuppressWarnings("all")
  public LoggingExampleCommandLineHandler() {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy