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

kz.greetgo.scheduling.context.SchedulerContextOnFile Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package kz.greetgo.scheduling.context;

import kz.greetgo.scheduling.ExceptionCatcher;
import kz.greetgo.scheduling.ThrowableCatcher;

import java.io.File;

public class SchedulerContextOnFile implements SchedulerContext {

  private final ContentStore configContent, errorContent;

  public SchedulerContextOnFile(File file) {
    configContent = new ContentStoreInFile(file);
    errorContent = new ContentStoreInFile(new File(file.getPath() + ".error"));
  }

  @Override
  public ContentStore configContent() {
    return configContent;
  }

  @Override
  public ContentStore configError() {
    return errorContent;
  }

  public ExceptionCatcher exceptionCatcher = null;

  public ThrowableCatcher throwableCatcher = new ThrowableCatcher() {
    @Override
    public void catchThrowable(Throwable throwable) {
      throwable.printStackTrace();
    }
  };

  @Override
  public ExceptionCatcher exceptionCatcher() {
    return exceptionCatcher;
  }

  @Override
  public ThrowableCatcher throwableCatcher() {
    return throwableCatcher;
  }

  @Override
  public String machineId() {
    return null;
  }

  public void makeExceptionCatcherThroughThrowableCatcher() {
    exceptionCatcher = new ExceptionCatcher() {
      @Override
      public void catchException(Exception e) {
        throwableCatcher.catchThrowable(e);
      }
    };
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy