本文整理了Java中io.micronaut.context.ApplicationContext.build()
方法的一些代码示例,展示了ApplicationContext.build()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.build()
方法的具体详情如下:
包路径:io.micronaut.context.ApplicationContext
类名称:ApplicationContext
方法名:build
[英]Build a ApplicationContext.
[中]构建应用程序上下文。
代码示例来源:origin: micronaut-projects/micronaut-core
/**
* Builds a new builder.
*
* @return The {@link ApplicationContextBuilder}
*/
protected @Nonnull ApplicationContextBuilder newApplicationContextBuilder() {
return ApplicationContext.build(Environment.FUNCTION);
}
代码示例来源:origin: io.micronaut.aws/micronaut-function-aws-api-proxy
/**
* constructor.
* @param lambdaContainerEnvironment The environment
* @throws ContainerInitializationException if the container couldn't be started
*/
private MicronautLambdaContainerHandler(LambdaContainerState lambdaContainerEnvironment) throws ContainerInitializationException {
this(lambdaContainerEnvironment, ApplicationContext.build());
}
代码示例来源:origin: micronaut-projects/micronaut-spring
public MicronautApplicationContext() {
this(io.micronaut.context.ApplicationContext.build());
}
代码示例来源:origin: io.micronaut/inject
/**
* Run the {@link ApplicationContext}. This method will instantiate a new {@link ApplicationContext} and
* call {@link #start()}.
*
* @param environments The environments to use
* @return The running {@link ApplicationContext}
*/
static ApplicationContext run(String... environments) {
return build(environments).start();
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Run the {@link ApplicationContext}. This method will instantiate a new {@link ApplicationContext} and
* call {@link #start()}.
*
* @param environments The environments to use
* @return The running {@link ApplicationContext}
*/
static ApplicationContext run(String... environments) {
return build(environments).start();
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Run the {@link BeanContext}. This method will instantiate a new {@link BeanContext} and call {@link #start()}
*
* @param classLoader The classloader to use
* @param environments The environments to use
* @return The running {@link ApplicationContext}
*/
static ApplicationContext run(ClassLoader classLoader, String... environments) {
return build(classLoader, environments).start();
}
代码示例来源:origin: io.micronaut/inject
/**
* Build a {@link ApplicationContext}.
*
* @param mainClass The main class of the application
* @param environments The environment to use
* @return The built, but not yet running {@link ApplicationContext}
*/
static ApplicationContextBuilder build(Class mainClass, String... environments) {
return build(environments)
.mainClass(mainClass);
}
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Build a {@link ApplicationContext}.
*
* @param mainClass The main class of the application
* @param environments The environment to use
* @return The built, but not yet running {@link ApplicationContext}
*/
static ApplicationContextBuilder build(Class mainClass, String... environments) {
return build(environments)
.mainClass(mainClass);
}
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Build a {@link ApplicationContext}.
*
* @param classLoader The classloader to use
* @param environments The environment to use
* @return The built, but not yet running {@link ApplicationContext}
*/
static ApplicationContextBuilder build(ClassLoader classLoader, String... environments) {
return build(environments)
.classLoader(classLoader);
}
代码示例来源:origin: io.micronaut/inject
/**
* Run the {@link BeanContext}. This method will instantiate a new {@link BeanContext} and call {@link #start()}
*
* @param classLoader The classloader to use
* @param environments The environments to use
* @return The running {@link ApplicationContext}
*/
static ApplicationContext run(ClassLoader classLoader, String... environments) {
return build(classLoader, environments).start();
}
代码示例来源:origin: io.micronaut/inject
/**
* Build a {@link ApplicationContext}.
*
* @param classLoader The classloader to use
* @param environments The environment to use
* @return The built, but not yet running {@link ApplicationContext}
*/
static ApplicationContextBuilder build(ClassLoader classLoader, String... environments) {
return build(environments)
.classLoader(classLoader);
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Run the {@link ApplicationContext} with the given type. Returning an instance of the type. Note this method
* should not be used.
* If the {@link ApplicationContext} requires graceful shutdown unless the returned bean takes responsibility for
* shutting down the context.
*
* @param properties Additional properties
* @param environments The environment names
* @return The running {@link ApplicationContext}
*/
static ApplicationContext run(PropertySource properties, String... environments) {
return build(environments)
.propertySources(properties)
.start();
}
代码示例来源:origin: io.micronaut/inject
/**
* Run the {@link ApplicationContext} with the given type. Returning an instance of the type. Note this method
* should not be used.
* If the {@link ApplicationContext} requires graceful shutdown unless the returned bean takes responsibility for
* shutting down the context.
*
* @param properties Additional properties
* @param environments The environment names
* @return The running {@link ApplicationContext}
*/
static ApplicationContext run(PropertySource properties, String... environments) {
return build(environments)
.propertySources(properties)
.start();
}
代码示例来源:origin: micronaut-projects/micronaut-examples
@Override
public void onCreate() {
super.onCreate();
ctx = ApplicationContext.build(MainActivity.class, Environment.ANDROID).start();
registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
代码示例来源:origin: io.micronaut/inject
/**
* Run the {@link ApplicationContext} with the given type. Returning an instance of the type. Note this method
* should not be used.
* If the {@link ApplicationContext} requires graceful shutdown unless the returned bean takes responsibility for
* shutting down the context.
*
* @param type The environment to use
* @param propertySource Additional properties
* @param environments The environment names
* @param <T> The type
* @return The running {@link BeanContext}
*/
static <T extends AutoCloseable> T run(Class<T> type, PropertySource propertySource, String... environments) {
T bean = build(environments)
.mainClass(type)
.propertySources(propertySource)
.start()
.getBean(type);
if (bean != null) {
if (bean instanceof LifeCycle) {
LifeCycle lifeCycle = (LifeCycle) bean;
if (!lifeCycle.isRunning()) {
lifeCycle.start();
}
}
}
return bean;
}
代码示例来源:origin: io.micronaut/micronaut-inject
/**
* Run the {@link ApplicationContext} with the given type. Returning an instance of the type. Note this method
* should not be used.
* If the {@link ApplicationContext} requires graceful shutdown unless the returned bean takes responsibility for
* shutting down the context.
*
* @param type The environment to use
* @param propertySource Additional properties
* @param environments The environment names
* @param <T> The type
* @return The running {@link BeanContext}
*/
static <T extends AutoCloseable> T run(Class<T> type, PropertySource propertySource, String... environments) {
T bean = build(environments)
.mainClass(type)
.propertySources(propertySource)
.start()
.getBean(type);
if (bean != null) {
if (bean instanceof LifeCycle) {
LifeCycle lifeCycle = (LifeCycle) bean;
if (!lifeCycle.isRunning()) {
lifeCycle.start();
}
}
}
return bean;
}
内容来源于网络,如有侵权,请联系作者删除!