本文整理匯總了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();
}
}