io.dropwizard.Application类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中io.dropwizard.Application类的一些代码示例,展示了Application类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application类的具体详情如下:
包路径:io.dropwizard.Application
类名称:Application

Application介绍

[英]The base class for Dropwizard applications. Because the default constructor will be inherited by all subclasses, {BootstrapLogging.bootstrap()} will always be invoked. The log level used during the bootstrap process can be configured by {Application} subclasses by overriding {#bootstrapLogLevel}.
[中]Dropwizard应用程序的基类。因为默认构造函数将被所有子类继承,{bootstraploging.bootstrap()}将始终被调用。引导过程中使用的日志级别可以由{Application}子类通过重写{#bootstrapploglevel}来配置。

代码示例

代码示例来源:origin: dropwizard/dropwizard

getApplication().initialize(bootstrap);

代码示例来源:origin: dropwizard/dropwizard

/**
 * A constructor to allow reuse of the server command as a different name
 * @param application the application using this command
 * @param name the argument name to invoke this command
 * @param description a summary of what the command does
 */
protected ServerCommand(final Application<T> application, final String name, final String description) {
  super(application, name, description);
  this.configurationClass = application.getConfigurationClass();
}

代码示例来源:origin: dropwizard/dropwizard

@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
  final Environment environment = new Environment(bootstrap.getApplication().getName(),
                          bootstrap.getObjectMapper(),
                          bootstrap.getValidatorFactory(),
                          bootstrap.getMetricRegistry(),
                          bootstrap.getClassLoader(),
                          bootstrap.getHealthCheckRegistry());
  configuration.getMetricsFactory().configure(environment.lifecycle(),
                        bootstrap.getMetricRegistry());
  configuration.getServerFactory().configure(environment);
  bootstrap.run(configuration, environment);
  application.run(configuration, environment);
  run(environment, namespace, configuration);
}

代码示例来源:origin: dropwizard/dropwizard

/**
 * Parses command-line arguments and runs the application. Call this method from a {@code public
 * static void main} entry point in your application.
 *
 * @param arguments the command-line arguments
 * @throws Exception if something goes wrong
 */
public void run(String... arguments) throws Exception {
  final Bootstrap<T> bootstrap = new Bootstrap<>(this);
  addDefaultCommands(bootstrap);
  initialize(bootstrap);
  // Should be called after initialize to give an opportunity to set a custom metric registry
  bootstrap.registerMetrics();
  final Cli cli = new Cli(new JarLocation(getClass()), bootstrap, System.out, System.err);
  if (!cli.run(arguments)) {
    // only exit if there's an error running the command
    onFatalError();
  }
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) throws IOException {
  Weld weld = new Weld();
  WeldContainer container = weld.initialize();
  Application application = container.instance().select(Application.class).get();
  application.run();
  weld.shutdown();
}

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("unchecked")
public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception {
  final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap;
  configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(),
                    bootstrap.getConfigurationSourceProvider(),
                    bootstrap.getValidatorFactory().getValidator(),
                    namespace.getString("file"),
                    getConfigurationClass(),
                    bootstrap.getObjectMapper());
  try {
    if (configuration != null) {
      configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(),
                            bootstrap.getApplication().getName());
    }
    run(bootstrap, namespace, configuration);
  } finally {
    if (!asynchronous) {
      cleanup();
    }
  }
}

代码示例来源:origin: org.sonatype.goodies.dropwizard/dropwizard-support-core

/**
 * Invoked on fatal error before shutdown.
 */
@Override
protected void onFatalError() {
 log.error("Fatal error detected; shutting down");
 super.onFatalError();
}

代码示例来源:origin: io.dropwizard/dropwizard-core

/**
 * Parses command-line arguments and runs the application. Call this method from a {@code public
 * static void main} entry point in your application.
 *
 * @param arguments the command-line arguments
 * @throws Exception if something goes wrong
 */
public void run(String... arguments) throws Exception {
  final Bootstrap<T> bootstrap = new Bootstrap<>(this);
  addDefaultCommands(bootstrap);
  initialize(bootstrap);
  // Should be called after initialize to give an opportunity to set a custom metric registry
  bootstrap.registerMetrics();
  final Cli cli = new Cli(new JarLocation(getClass()), bootstrap, System.out, System.err);
  if (!cli.run(arguments)) {
    // only exit if there's an error running the command
    onFatalError();
  }
}

代码示例来源:origin: rvs-fluid-it/wizard-in-a-box

@Override
public void run(C configuration,
        Environment environment) throws Exception {
  dropwizardEnvironment = environment;
  dropwizardApplication.run(configuration, environment);
}

代码示例来源:origin: rvs-fluid-it/wizard-in-a-box

@Override
public String getName() {
  return dropwizardApplication.getName() + "-war";
}

代码示例来源:origin: palantir/atlasdb

@Override
public void initialize(Bootstrap<TimelockBenchmarkServerConfig> bootstrap) {
  bootstrap.getObjectMapper().registerModule(new Jdk8Module());
  bootstrap.getObjectMapper().registerSubtypes(NonBlockingFileAppenderFactory.class);
  super.initialize(bootstrap);
}

代码示例来源:origin: dropwizard/dropwizard

public CheckCommand(Application<T> application) {
  super("check", "Parses and validates the configuration file");
  this.configurationClass = application.getConfigurationClass();
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args){
  Application app = Application.getInstance();
  app.run();
}

代码示例来源:origin: io.dropwizard/dropwizard-core

@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
  final Environment environment = new Environment(bootstrap.getApplication().getName(),
                          bootstrap.getObjectMapper(),
                          bootstrap.getValidatorFactory().getValidator(),
                          bootstrap.getMetricRegistry(),
                          bootstrap.getClassLoader(),
                          bootstrap.getHealthCheckRegistry());
  configuration.getMetricsFactory().configure(environment.lifecycle(),
                        bootstrap.getMetricRegistry());
  configuration.getServerFactory().configure(environment);
  bootstrap.run(configuration, environment);
  application.run(configuration, environment);
  run(environment, namespace, configuration);
}

代码示例来源:origin: io.dropwizard/dropwizard-core

@Override
@SuppressWarnings("unchecked")
public void run(Bootstrap<?> wildcardBootstrap, Namespace namespace) throws Exception {
  final Bootstrap<T> bootstrap = (Bootstrap<T>) wildcardBootstrap;
  configuration = parseConfiguration(bootstrap.getConfigurationFactoryFactory(),
                    bootstrap.getConfigurationSourceProvider(),
                    bootstrap.getValidatorFactory().getValidator(),
                    namespace.getString("file"),
                    getConfigurationClass(),
                    bootstrap.getObjectMapper());
  try {
    if (configuration != null) {
      configuration.getLoggingFactory().configure(bootstrap.getMetricRegistry(),
                            bootstrap.getApplication().getName());
    }
    run(bootstrap, namespace, configuration);
  } finally {
    if (!asynchronous) {
      cleanup();
    }
  }
}

代码示例来源:origin: palantir/atlasdb

@Override
public void initialize(Bootstrap<TimeLockServerConfiguration> bootstrap) {
  MetricRegistry metricRegistry = SharedMetricRegistries
      .getOrCreate("AtlasDbTest" + UUID.randomUUID().toString());
  TaggedMetricRegistry taggedMetricRegistry = new DefaultTaggedMetricRegistry();
  bootstrap.setMetricRegistry(metricRegistry);
  bootstrap.getObjectMapper().registerSubtypes(NonBlockingFileAppenderFactory.class);
  bootstrap.getObjectMapper().registerModule(new Jdk8Module());
  super.initialize(bootstrap);
}

代码示例来源:origin: dropwizard/dropwizard

@Override
@SuppressWarnings("unchecked")
public final void initialize(Bootstrap<?> bootstrap) {
  final Class<T> klass = (Class<T>) bootstrap.getApplication().getConfigurationClass();
  bootstrap.addCommand(new DbCommand<>(name(), this, klass, getMigrationsFileName()));
}

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
  Injector injector = Guice.createInjector(new GuiceModule())
  Application app = injector.getInstance(Application.class);
  app.run();
}

代码示例来源:origin: org.lwapp/lwapp-dropwizard-core

@Override
public String getName() {
  return StringUtils.defaultString(applicationServerConfig.getCoreConfiguration().getApplicationName(), super.getName());
}

代码示例来源:origin: palantir/atlasdb

@Override
public void initialize(Bootstrap<TimelockBenchmarkClientConfig> bootstrap) {
  MetricRegistry metricRegistry = MetricRegistries.createWithHdrHistogramReservoirs();
  bootstrap.setMetricRegistry(metricRegistry);
  bootstrap.getObjectMapper().registerModule(new Jdk8Module());
  bootstrap.getObjectMapper().registerSubtypes(NonBlockingFileAppenderFactory.class);
  super.initialize(bootstrap);
}

相关文章