本文整理汇总了Java中io.dropwizard.Application类的典型用法代码示例。如果您正苦于以下问题:Java Application类的具体用法?Java Application怎么用?Java Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Application类属于io.dropwizard包,在下文中一共展示了Application类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newApplication
import io.dropwizard.Application; //导入依赖的package包/类
@Override public Application<ServerConfiguration> newApplication() {
return new ServerMain("outland.feature.server") {
@Override
protected List<Module> addModules(
ServerConfiguration configuration, Environment environment) {
return Lists.newArrayList(
new ServerModule(configuration),
new HystrixModule(),
new RedisModule(configuration.redis),
new DynamoDbModule(configuration.aws),
new AuthModule(configuration.auth),
new TestFeatureServiceModule(),
new TestGroupModule()
);
}
};
}
示例2: renderReport
import io.dropwizard.Application; //导入依赖的package包/类
/**
* Renders configuration tree report according to provided config.
* By default report padded left with one tab. Subtrees are always padded with empty lines for better
* visibility.
*
* @param config tree rendering config
* @return rendered tree
*/
@Override
public String renderReport(final ContextTreeConfig config) {
final Set<Class<?>> scopes = service.getActiveScopes();
final TreeNode root = new TreeNode("APPLICATION");
renderScopeContent(config, root, Application.class);
renderSpecialScope(config, scopes, root, "BUNDLES LOOKUP", GuiceyBundleLookup.class);
renderSpecialScope(config, scopes, root, "DROPWIZARD BUNDLES", Bundle.class);
renderSpecialScope(config, scopes, root, "CLASSPATH SCAN", ClasspathScanner.class);
final StringBuilder res = new StringBuilder().append(Reporter.NEWLINE).append(Reporter.NEWLINE);
root.render(res);
return res.toString();
}
示例3: processBundles
import io.dropwizard.Application; //导入依赖的package包/类
/**
* Process initially registered and all transitive bundles.
* <ul>
* <li>Executing initial bundles (registered in {@link ru.vyarus.dropwizard.guice.GuiceBundle}
* and by bundle lookup)</li>
* <li>During execution bundles may register other bundles (through {@link GuiceyBootstrap})</li>
* <li>Execute registered bundles and repeat from previous step until no new bundles registered</li>
* </ul>
* Bundles duplicates are checked by type: only one bundle instance may be registered.
*
* @param context bundles context
* @param configuration configuration object
* @param environment environment object
* @param application application instance
*/
public static void processBundles(final ConfigurationContext context,
final Configuration configuration, final Environment environment,
final Application application) {
final List<GuiceyBundle> bundles = context.getBundles();
final List<Class<? extends GuiceyBundle>> installedBundles = Lists.newArrayList();
final GuiceyBootstrap guiceyBootstrap = new GuiceyBootstrap(
context, bundles, configuration, environment, application);
// iterating while no new bundles registered
while (!bundles.isEmpty()) {
final List<GuiceyBundle> processingBundles = Lists.newArrayList(BundleSupport.removeDuplicates(bundles));
bundles.clear();
for (GuiceyBundle bundle : removeTypes(processingBundles, installedBundles)) {
final Class<? extends GuiceyBundle> bundleType = bundle.getClass();
Preconditions.checkState(!installedBundles.contains(bundleType),
"State error: duplicate bundle '%s' registration", bundleType.getName());
context.setScope(bundleType);
bundle.initialize(guiceyBootstrap);
installedBundles.add(bundleType);
context.closeScope();
}
}
}
示例4: registerInjector
import io.dropwizard.Application; //导入依赖的package包/类
/**
* Used internally to register application specific injector.
*
* @param application application instance
* @param injector injector instance
* @return managed object, which must be registered to remove injector on application stop
*/
public static Managed registerInjector(final Application application, final Injector injector) {
Preconditions.checkNotNull(application, "Application instance required");
Preconditions.checkArgument(!INJECTORS.containsKey(application),
"Injector already registered for application %s", application.getClass().getName());
INJECTORS.put(application, injector);
return new Managed() {
@Override
public void start() throws Exception {
// not used
}
@Override
public void stop() throws Exception {
INJECTORS.remove(application);
}
};
}
示例5: setup
import io.dropwizard.Application; //导入依赖的package包/类
public void setup(
Class<? extends Application<TestConfiguration>> applicationClass,
String configPath, ConfigOverride... configOverrides) {
dropwizardTestSupport = new DropwizardTestSupport<>(applicationClass,
ResourceHelpers.resourceFilePath(configPath), configOverrides);
dropwizardTestSupport.before();
}
示例6: configure
import io.dropwizard.Application; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void configure() {
bind(environment).to(Environment.class);
bind(environment.healthChecks()).to(HealthCheckRegistry.class);
bind(environment.lifecycle()).to(LifecycleEnvironment.class);
bind(environment.metrics()).to(MetricRegistry.class);
bind(environment.getValidator()).to(Validator.class);
bind(configuration).to(bootstrap.getApplication().getConfigurationClass()).to(Configuration.class);
bind(environment.getObjectMapper()).to(ObjectMapper.class);
bind(bootstrap.getApplication()).to((Class) bootstrap.getApplication().getClass()).to(Application.class);
}
示例7: configure
import io.dropwizard.Application; //导入依赖的package包/类
@Override
protected void configure() {
bind(application);
bind(application).to(Application.class);
bind(environment);
bind(environment.getObjectMapper());
bind(environment.metrics());
bind(environment.getValidator());
}
示例8: TLSTruststoreTestCommand
import io.dropwizard.Application; //导入依赖的package包/类
public TLSTruststoreTestCommand(Application<T> application) {
this(
application,
"truststoretest",
"Runs GET request against HTTPS secured URL with provided truststore"
);
}
示例9: before
import io.dropwizard.Application; //导入依赖的package包/类
@Override
protected void before() throws Throwable {
Application application = applicationClass.newInstance();
Method method = applicationClass.getMethod("main", String[].class);
String[] params = null;
method.invoke(null, (Object) params);
}
示例10: DropWizardServer
import io.dropwizard.Application; //导入依赖的package包/类
DropWizardServer(T builtConfig,
Bootstrap<T> bootstrap,
Application<T> application,
Environment environment,
Server jettyServer,
MetricRegistry metricRegistry) {
this.builtConfig = builtConfig;
this.bootstrap = bootstrap;
this.application = application;
this.environment = environment;
this.jettyServer = jettyServer;
this.metricRegistry = metricRegistry;
}
示例11: DropWizardServer
import io.dropwizard.Application; //导入依赖的package包/类
DropWizardServer(T builtConfig,
Bootstrap<T> bootstrap,
Application<T> application,
Environment environment,
Server jettyServer,
MetricRegistry metricRegistry)
{
this.builtConfig = builtConfig;
this.bootstrap = bootstrap;
this.application = application;
this.environment = environment;
this.jettyServer = jettyServer;
this.metricRegistry = metricRegistry;
}
示例12: GuiceyBootstrap
import io.dropwizard.Application; //导入依赖的package包/类
public GuiceyBootstrap(final ConfigurationContext context, final List<GuiceyBundle> iterationBundles,
final Configuration configuration, final Environment environment,
final Application application) {
this.context = context;
this.iterationBundles = iterationBundles;
this.configuration = configuration;
this.environment = environment;
this.application = application;
}
示例13: GuiceyAppRule
import io.dropwizard.Application; //导入依赖的package包/类
public GuiceyAppRule(final Class<? extends Application<C>> applicationClass,
@Nullable final String configPath,
final ConfigOverride... configOverrides) {
this.applicationClass = applicationClass;
this.configPath = configPath;
for (ConfigOverride configOverride : configOverrides) {
configOverride.addToSystemProperties();
}
}
示例14: newApplication
import io.dropwizard.Application; //导入依赖的package包/类
protected Application<C> newApplication() {
try {
return applicationClass.newInstance();
} catch (Exception e) {
throw new IllegalStateException("Failed to instantiate application", e);
}
}
示例15: AbstractAppTest
import io.dropwizard.Application; //导入依赖的package包/类
public AbstractAppTest(Class<? extends Application<C>> applicationClass, String configPath,
ConfigOverride... configOverrides) {
this.applicationClass = applicationClass;
this.configPath = configPath;
for (ConfigOverride configOverride : configOverrides) {
configOverride.addToSystemProperties();
}
}