Skip to content

Commit

Permalink
Expose RunnableApp
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Jun 24, 2024
1 parent 81e6589 commit 98334f4
Showing 1 changed file with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,28 +264,23 @@ public final AppConfiguration<T> createConfiguration() {
}

/**
* Create a new {@code ConfiguredApp} that will be executed according to the given config.
*
* @param app app to configure.
* @param configuration configuration for app
* @return {@code ConfiguredApp}
*/
protected abstract CA createConfiguredApp(final A app, AppConfiguration<T> configuration);

/**
* Configure application when running in debug mode. By default, Log4j2 log level is configured to debug for
* {@code com.bakdata} and the applications package.
* Create a new {@code RunnableApp}
* @return {@code RunnableApp}
*/
protected void configureDebug() {
Configurator.setLevel("com.bakdata", Level.DEBUG);
Configurator.setLevel(this.getClass().getPackageName(), Level.DEBUG);
public final RunnableApp createRunnableApp() {
final ExecutableApp<R, ?, O> app = this.createExecutableApp(false);
final Optional<O> executionOptions = this.createExecutionOptions();
final R runner = executionOptions.map(app::createRunner).orElseGet(app::createRunner);
final RunnableApp runnableApp = new RunnableApp(app, runner);
this.activeApps.add(runnableApp);
return runnableApp;
}

/**
* Create a new {@code CleanableApp}
* @return {@code CleanableApp}
*/
protected final CleanableApp createCleanableApp() {
public final CleanableApp createCleanableApp() {
final ExecutableApp<R, CR, O> executableApp = this.createExecutableApp(true);
final CR cleanUpRunner = executableApp.createCleanUpRunner();
final CleanableApp cleanableApp = new CleanableApp(executableApp, cleanUpRunner);
Expand All @@ -294,16 +289,21 @@ protected final CleanableApp createCleanableApp() {
}

/**
* Create a new {@code RunnableApp}
* @return {@code RunnableApp}
* Create a new {@code ConfiguredApp} that will be executed according to the given config.
*
* @param app app to configure.
* @param configuration configuration for app
* @return {@code ConfiguredApp}
*/
protected final RunnableApp createRunnableApp() {
final ExecutableApp<R, ?, O> app = this.createExecutableApp(false);
final Optional<O> executionOptions = this.createExecutionOptions();
final R runner = executionOptions.map(app::createRunner).orElseGet(app::createRunner);
final RunnableApp runnableApp = new RunnableApp(app, runner);
this.activeApps.add(runnableApp);
return runnableApp;
protected abstract CA createConfiguredApp(final A app, AppConfiguration<T> configuration);

/**
* Configure application when running in debug mode. By default, Log4j2 log level is configured to debug for
* {@code com.bakdata} and the applications package.
*/
protected void configureDebug() {
Configurator.setLevel("com.bakdata", Level.DEBUG);
Configurator.setLevel(this.getClass().getPackageName(), Level.DEBUG);
}

private void startApplication() {
Expand All @@ -328,7 +328,7 @@ private interface Stoppable {
}

@RequiredArgsConstructor
protected class CleanableApp implements AutoCloseable, Stoppable {
public class CleanableApp implements AutoCloseable, Stoppable {
private final @NonNull ExecutableApp<?, ?, ?> app;
@Getter
private final @NonNull CR cleanUpRunner;
Expand All @@ -346,7 +346,7 @@ public void stop() {
}

@RequiredArgsConstructor
protected class RunnableApp implements AutoCloseable, Stoppable {
public class RunnableApp implements AutoCloseable, Stoppable {
private final @NonNull ExecutableApp<?, ?, ?> app;
@Getter
private final @NonNull R runner;
Expand Down

0 comments on commit 98334f4

Please sign in to comment.