Tabnine Logo
Bootique
Code IndexAdd Tabnine to your IDE (free)

How to use
Bootique
in
io.bootique

Best Java code snippets using io.bootique.Bootique (Showing top 20 results out of 315)

origin: bootique/bootique

/**
 * A generic main method that auto-loads available modules and runs Bootique stack. Useful for apps that don't
 * care to customize their "main()".
 *
 * @param args app arguments passed by the shell.
 * @since 0.17
 */
public static void main(String[] args) {
  Bootique.app(args).autoLoadModules().exec().exit();
}
origin: bootique/bootique

/**
 * Creates and returns an instance of {@link BQRuntime} that contains all Bootique services, commands, etc.
 * This method is only needed if you are managing Bootique execution sequence manually. Normally you'd be using
 * {@link #exec()} method instead of this method.
 *
 * @return a new {@link BQRuntime} instance that contains all Bootique services, commands, etc.
 * @since 0.13
 */
public BQRuntime createRuntime() {
  Injector injector = createInjector();
  return createRuntime(injector);
}
origin: bootique/bootique

protected BQTestRuntimeBuilder(String[] args) {
  //exclude system variables and properties by setting the properties
  final HashMap<String, String> properties = new HashMap<>();
  properties.put(EXCLUDE_SYSTEM_PROPERTIES, "true");
  properties.put(EXCLUDE_SYSTEM_VARIABLES, "true");
  this.properties = properties;
  this.bootique = Bootique.app(args).module(createPropertiesProvider());
}
origin: bootique/bootique

  Thread shutdownThread = createJVMShutdownHook();
  Runtime.getRuntime().addShutdownHook(shutdownThread);
  try {
    o = createRuntime().run();
    shutdown(shutdownManager, bootLogger);
    Runtime.getRuntime().removeShutdownHook(shutdownThread);
  o = processExceptions(ce.getCause(), ce);
} catch (ProvisionException pe) {
      .map(Message::getCause)
      .orElse(null);
  o = processExceptions(cause, pe);
} catch (Throwable th) {
  o = processExceptions(th, th);
    bootLogger.stderr(String.format("Error running command '%s': %s", getArgsAsString(), o.getMessage()), o.getException());
  } else {
    bootLogger.stderr(String.format("Error running command '%s'", getArgsAsString()), o.getException());
origin: io.sarl/io.sarl.lang.sarlc

/** Create the compiler runtime.
 *
 * @param args the command line arguments.
 * @return the runtime.
 */
@SuppressWarnings("static-method")
protected BQRuntime createRuntime(String... args) {
  SARLStandaloneSetup.doPreSetup();
  final BQRuntime runtime = Bootique.app(args).autoLoadModules().createRuntime();
  SARLStandaloneSetup.doPostSetup(runtime.getInstance(Injector.class));
  return runtime;
}
origin: bootique/bootique

/**
 * Adds a Module generated by the provider. Provider may optionally specify
 * that the Module overrides services in some other Module.
 *
 * @param moduleProvider a provider of Module and override spec.
 * @return this instance of test runtime builder.
 */
public T module(BQModuleProvider moduleProvider) {
  bootique.module(moduleProvider);
  return (T) this;
}
origin: bootique/bootique

/**
 * Starts a builder of Bootique runtime, initializing it with provided command-line arguments.
 *
 * @param args command-line arguments.
 * @return Bootique object that can be customized and then executed as an app via {@link #exec()} method.
 * @since 0.17
 */
public static Bootique app(Collection<String> args) {
  if (args == null) {
    args = Collections.emptyList();
  }
  return app(BootiqueUtils.toArray(Objects.requireNonNull(args)));
}
origin: bootique/bootique

/**
 * The main build method that creates and returns a {@link BQRuntime}.
 *
 * @return a new instance of {@link BQRuntime} configured in this builder.
 */
public BQRuntime createRuntime() {
  BQRuntime runtime = bootique.createRuntime();
  runtimes.add(runtime);
  return runtime;
}
origin: bootique/bootique

Injector createInjector() {
  DeferredModulesSource modulesSource = new DeferredModulesSource();
  Collection<BQModule> bqModules = new ArrayList<>();
  // note that 'moduleMetadata' is invalid at this point; it will be initialized later in this method, which
  // is safe to do, as it won't be used until the Injector is created by the method caller.
  bqModules.add(coreModuleProvider(modulesSource).moduleBuilder().build());
  BootiqueUtils.moduleProviderDependencies(builderProviders())
      .forEach(p -> bqModules.add(p.moduleBuilder().build()));
  if (autoLoadModules) {
    autoLoadedProviders().forEach(p -> bqModules.add(p.moduleBuilder().build()));
  }
  // now that all modules are collected, finish 'moduleMetadata' initialization
  modulesSource.init(bqModules);
  // convert to Guice modules respecting overrides, etc.
  Collection<Module> modules = new RuntimeModuleMerger(bootLogger).toGuiceModules(bqModules);
  return Guice.createInjector(modules);
}
origin: bootique/bootique

/**
 * Instructs Bootique to load any modules available on classpath that expose {@link io.bootique.BQModuleProvider}
 * provider. Auto-loaded modules will be used in default configuration. Factories within modules will of course be
 * configured dynamically from YAML.
 *
 * @return this instance of test runtime builder.
 */
public T autoLoadModules() {
  bootique.autoLoadModules();
  return (T) this;
}
origin: bootique/bootique

/**
 * Appends extra values to the test CLI arguments.
 *
 * @param args extra args to pass to Bootique.
 * @return this instance of test runtime builder.
 */
public T args(String... args) {
  bootique.args(args);
  return (T) this;
}
origin: bootique/bootique

/**
 * Starts a builder of Bootique runtime.
 *
 * @param args command-line arguments.
 * @return Bootique object that can be customized and then executed as an app via {@link #exec()} method.
 */
public static Bootique app(String... args) {
  if (args == null) {
    args = new String[0];
  }
  return new Bootique(args);
}
origin: bootique/bootique

/**
 * @param bootLogger custom BootLogger to use for a given runtime.
 * @return this instance of test runtime builder.
 * @since 0.23
 */
public T bootLogger(BootLogger bootLogger) {
  bootique.bootLogger(bootLogger);
  return (T) this;
}
origin: io.bootique/bootique

  Thread shutdownThread = createJVMShutdownHook();
  Runtime.getRuntime().addShutdownHook(shutdownThread);
  try {
    o = createRuntime().run();
    shutdown(shutdownManager, bootLogger);
    Runtime.getRuntime().removeShutdownHook(shutdownThread);
  o = processExceptions(ce.getCause(), ce);
} catch (ProvisionException pe) {
  o = processExceptions(pe.getCause(), pe);
} catch (Throwable th) {
  o = processExceptions(th, th);
    bootLogger.stderr(String.format("Error running command '%s': %s", getArgsAsString(), o.getMessage()), o.getException());
  } else {
    bootLogger.stderr(String.format("Error running command '%s'", getArgsAsString()), o.getException());
origin: bootique/bootique

/**
 * @param moduleType custom Module class to add to Bootique DI runtime.
 * @return this instance of test runtime builder.
 * @see #autoLoadModules()
 */
public T module(Class<? extends Module> moduleType) {
  bootique.module(moduleType);
  return (T) this;
}
origin: io.bootique/bootique

/**
 * Starts a builder of Bootique runtime, initializing it with provided
 * command-line arguments.
 *
 * @param args command-line arguments.
 * @return Bootique object that can be customized and then executed as an
 * app via {@link #exec()} method.
 * @since 0.17
 */
public static Bootique app(Collection<String> args) {
  if (args == null) {
    args = Collections.emptyList();
  }
  return app(BootiqueUtils.toArray(Objects.requireNonNull(args)));
}
origin: bootique/bootique

/**
 * Creates runtime without starting it. Can be started via {@link BQDaemonTestFactory#start(BQRuntime)}.
 *
 * @return newly created managed runtime.
 * @since 0.23
 */
public BQRuntime createRuntime() {
  BQRuntime runtime = bootique.createRuntime();
  // wrap in BQRuntimeDaemon to handle thread pool shutdown and startup checks.
  BQRuntimeDaemon testRuntime =
      new BQRuntimeDaemon(runtime, startupCheck, startupTimeout, startupTimeoutTimeUnit);
  runtimes.put(runtime, testRuntime);
  return runtime;
}
origin: io.bootique/bootique

Injector createInjector() {
  DeferredModulesSource modulesSource = new DeferredModulesSource();
  Collection<BQModule> bqModules = new ArrayList<>();
  // note that 'moduleMetadata' is invalid at this point; it will be initialized later in this method, which
  // is safe to do, as it won't be used until the Injector is created by the method caller.
  bqModules.add(coreModuleProvider(modulesSource).moduleBuilder().build());
  BootiqueUtils.moduleProviderDependencies(builderProviders())
      .forEach(p -> bqModules.add(p.moduleBuilder().build()));
  if (autoLoadModules) {
    autoLoadedProviders().forEach(p -> bqModules.add(p.moduleBuilder().build()));
  }
  // now that all modules are collected, finish 'moduleMetadata' initialization
  modulesSource.init(bqModules);
  // convert to Guice modules respecting overrides, etc.
  Collection<Module> modules = new RuntimeModuleMerger(bootLogger).toGuiceModules(bqModules);
  return Guice.createInjector(modules);
}
origin: bootique/bootique

/**
 * Appends extra values to the test CLI arguments.
 *
 * @param args extra args to pass to Bootique.
 * @return this instance of test runtime builder.
 */
public T args(Collection<String> args) {
  bootique.args(args);
  return (T) this;
}
origin: io.bootique/bootique

/**
 * Starts a builder of Bootique runtime.
 *
 * @param args command-line arguments.
 * @return Bootique object that can be customized and then executed as an
 * app via {@link #exec()} method.
 */
public static Bootique app(String... args) {
  if (args == null) {
    args = new String[0];
  }
  return new Bootique(args);
}
io.bootiqueBootique

Javadoc

A main launcher class of Bootique. You may use this class as the main class to start the app. Or you may write your own main method as follows:
 
public static void main(String[] args) { 
Bootique.app(args).modules(...).exec().exit(); 
} 
or
 
public static void main(String[] args) { 
Bootique.app(args).autoLoadModules().exec().exit(); 
} 

Most used methods

  • app
    Starts a builder of Bootique runtime.
  • autoLoadModules
    Instructs Bootique to load any modules available on class-path that expose BQModuleProvider provider
  • createRuntime
  • module
  • <init>
  • args
    Appends extra values to Bootique CLI arguments.
  • autoLoadedProviders
  • bootLogger
    Optionally overrides Bootique's BootLogger.
  • builderProviders
  • coreModuleProvider
  • createBootLogger
  • createInjector
  • createBootLogger,
  • createInjector,
  • createJVMShutdownHook,
  • createModule,
  • createShutdownManager,
  • exec,
  • getArgsAsString,
  • modules,
  • override,
  • processExceptions

Popular in Java

  • Reading from database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSharedPreferences (Context)
  • getContentResolver (Context)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now