io.dropwizard.Application.initialize()方法的使用及代码示例

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

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

Application.initialize介绍

[英]Initializes the application bootstrap.
[中]初始化应用程序引导。

代码示例

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

getApplication().initialize(bootstrap);

代码示例来源: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: palantir/atlasdb

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

代码示例来源: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: 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);
}

代码示例来源: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: org.testeditor.web/org.testeditor.web.dropwizard

@Override
public void initialize(final Bootstrap<T> bootstrap) {
 super.initialize(bootstrap);
 this.initializeInjection(bootstrap);
}

代码示例来源:origin: Symantec/hendrix

@Override
public void initialize(Bootstrap<AppConfig> bootstrap) {
  bootstrap.addBundle(new SwaggerBundle<AppConfig>() {
    @Override
    protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(AppConfig configuration) {
      SwaggerBundleConfiguration config = new SwaggerBundleConfiguration();
      config.setLicense("The Apache Software License, Version 2.0");
      config.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.txt");
      config.setTitle("Hendrix API");
      config.setResourcePackage("io.symcpe.hendrix.api.rest");
      config.setDescription(
          "Hendrix API is allows CRUD operations for Rules, Tenants and Templates in Hendrix");
      return config;
    }
  });
  super.initialize(bootstrap);
}

代码示例来源:origin: hortonworks/streamline

@Override
public void initialize(Bootstrap<StreamlineConfiguration> bootstrap) {
  bootstrap.addBundle(new AssetsBundle("/assets", "/", "index.html", "static"));
  super.initialize(bootstrap);
}

代码示例来源:origin: xvik/dropwizard-guicey

private void startIfRequired() {
  if (command != null) {
    return;
  }
  try {
    application = newApplication();
    final Bootstrap<C> bootstrap = new Bootstrap<C>(application) {
      @Override
      public void run(final C configuration, final Environment environment) throws Exception {
        GuiceyAppRule.this.configuration = configuration;
        GuiceyAppRule.this.environment = environment;
        super.run(configuration, environment);
      }
    };
    application.initialize(bootstrap);
    startCommand(bootstrap);
  } catch (Exception e) {
    throw new IllegalStateException("Failed to start test environment", e);
  }
}

代码示例来源:origin: ru.vyarus/dropwizard-guicey

private void startIfRequired() {
  if (command != null) {
    return;
  }
  try {
    application = newApplication();
    final Bootstrap<C> bootstrap = new Bootstrap<C>(application) {
      @Override
      public void run(final C configuration, final Environment environment) throws Exception {
        GuiceyAppRule.this.configuration = configuration;
        GuiceyAppRule.this.environment = environment;
        super.run(configuration, environment);
      }
    };
    application.initialize(bootstrap);
    startCommand(bootstrap);
  } catch (Exception e) {
    throw new IllegalStateException("Failed to start test environment", e);
  }
}

代码示例来源:origin: com.hortonworks.registries/registry-webservice

@Override
public void initialize(Bootstrap<RegistryConfiguration> bootstrap) {
  // always deploy UI on /ui. If there is no other filter like Confluent etc, redirect / to /ui
  bootstrap.addBundle(new AssetsBundle("/assets", "/ui", "index.html", "static"));
  bootstrap.addBundle(new SwaggerBundle<RegistryConfiguration>() {
    @Override
    protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(RegistryConfiguration registryConfiguration) {
      return registryConfiguration.getSwaggerBundleConfiguration();
    }
  });
  super.initialize(bootstrap);
}

代码示例来源:origin: hortonworks/registry

@Override
public void initialize(Bootstrap<RegistryConfiguration> bootstrap) {
  // always deploy UI on /ui. If there is no other filter like Confluent etc, redirect / to /ui
  bootstrap.addBundle(new AssetsBundle("/assets", "/ui", "index.html", "static"));
  bootstrap.addBundle(new SwaggerBundle<RegistryConfiguration>() {
    @Override
    protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(RegistryConfiguration registryConfiguration) {
      return registryConfiguration.getSwaggerBundleConfiguration();
    }
  });
  super.initialize(bootstrap);
}

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

@Override
public void initialize(Bootstrap<C> bootstrap) {
  if (configurationBridge != null) {
    bootstrap.setConfigurationFactoryFactory(new BridgedConfigurationFactoryFactory<C>(configurationBridge));
  }
  // Swaps the default FileConfigurationSourceProvider
  bootstrap.setConfigurationSourceProvider(new ClasspathConfigurationSourceProvider());
  dropwizardApplication.initialize(bootstrap);
}

代码示例来源:origin: olacabs/fabric

@Override
public void initialize(final Bootstrap<ManagerConfig> bootstrap) {
  super.initialize(bootstrap);
  bootstrap.addBundle(new EnvironmentVariableInterpolationBundle());
  bootstrap.addBundle(hibernate);
  bootstrap.addBundle(swaggerBundle);
}

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

getApplication().initialize(bootstrap);
final Command command = commandInstantiator.apply(application);

代码示例来源:origin: openstack/monasca-common

private void startIfRequired() {
 if (jettyServer != null) {
  return;
 }
 try {
  application = newApplication();
  final Bootstrap<C> bootstrap = new Bootstrap<C>(application) {
   @Override
   public void run(C configuration, Environment environment) throws Exception {
    environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
     @Override
     public void serverStarted(Server server) {
      jettyServer = server;
     }
    });
    AbstractAppTest.this.configuration = configuration;
    AbstractAppTest.this.environment = environment;
    super.run(configuration, environment);
   }
  };
  application.initialize(bootstrap);
  final ServerCommand<C> command = new ServerCommand<>(application);
  final Namespace namespace = new Namespace(ImmutableMap.<String, Object>of("file", configPath));
  command.run(bootstrap, namespace);
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: mesosphere/dcos-cassandra-service

@Override
public void initialize(Bootstrap<MutableSchedulerConfiguration> bootstrap) {
 super.initialize(bootstrap);
 StrSubstitutor strSubstitutor = new StrSubstitutor(new EnvironmentVariableLookup(false));
 strSubstitutor.setEnableSubstitutionInVariables(true);
 bootstrap.addBundle(new Java8Bundle());
 bootstrap.setConfigurationSourceProvider(
  new SubstitutingSourceProvider(
   bootstrap.getConfigurationSourceProvider(),
   strSubstitutor));
}

代码示例来源:origin: mesosphere/dcos-cassandra-service

@Override
public void initialize(Bootstrap<CassandraExecutorConfiguration> bootstrap) {
  super.initialize(bootstrap);
  bootstrap.addBundle(new Java8Bundle());
  bootstrap.setConfigurationSourceProvider(
      new SubstitutingSourceProvider(
          bootstrap.getConfigurationSourceProvider(),
          new StrSubstitutor(
              new EnvironmentVariableLookup(false))));
}

代码示例来源:origin: epam/DLab

@Override
public void initialize(Bootstrap<SelfServiceApplicationConfiguration> bootstrap) {
  super.initialize(bootstrap);
  bootstrap.addBundle(new MultiPartBundle());
  bootstrap.addBundle(new AssetsBundle("/webapp/dist", "/", "index.html"));
  bootstrap.addBundle(new TemplateConfigBundle(
      new TemplateConfigBundleConfiguration().fileIncludePath(ServiceUtils.getConfPath())
  ));
}

相关文章