io.micronaut.context.ApplicationContextBuilder Java Examples

The following examples show how to use io.micronaut.context.ApplicationContextBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 6 votes vote down vote up
/**
 * constructor.
 *
 * @param lambdaContainerEnvironment The container environment
 * @param applicationContextBuilder  The context builder
 * @throws ContainerInitializationException if the container couldn't be started
 */
private MicronautLambdaContainerHandler(
        LambdaContainerState lambdaContainerEnvironment,
        ApplicationContextBuilder applicationContextBuilder) throws ContainerInitializationException {
    super(
            AwsProxyRequest.class,
            AwsProxyResponse.class,
            new MicronautRequestReader(lambdaContainerEnvironment),
            new MicronautResponseWriter(lambdaContainerEnvironment),
            new AwsProxySecurityContextWriter(),
            new MicronautAwsProxyExceptionHandler(lambdaContainerEnvironment)

    );
    ArgumentUtils.requireNonNull("applicationContextBuilder", applicationContextBuilder);
    this.lambdaContainerEnvironment = lambdaContainerEnvironment;
    this.applicationContextBuilder = applicationContextBuilder;
    initialize();
}
 
Example #2
Source File: HttpFunction.java    From micronaut-gcp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected ApplicationContextBuilder newApplicationContextBuilder() {
    final ApplicationContextBuilder builder = super.newApplicationContextBuilder();
    builder.deduceEnvironment(false);
    builder.environments(Environment.FUNCTION, Environment.GOOGLE_COMPUTE);
    return builder;
}
 
Example #3
Source File: GoogleFunctionInitializer.java    From micronaut-gcp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected ApplicationContextBuilder newApplicationContextBuilder() {
    ApplicationContextBuilder builder = super.newApplicationContextBuilder();
    builder.deduceEnvironment(false);
    builder.environments(Environment.GOOGLE_COMPUTE);
    return builder;
}
 
Example #4
Source File: AlexaFunction.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a new builder.
 *
 * @return The {@link ApplicationContextBuilder}
 */
@SuppressWarnings("unchecked")
@NonNull
protected ApplicationContextBuilder newApplicationContextBuilder() {
    return ApplicationContext.build(Environment.FUNCTION, MicronautLambdaContext.ENVIRONMENT_LAMBDA, AlexaEnvironment.ENV_ALEXA)
            .eagerInitSingletons(true)
            .eagerInitConfiguration(true);
}
 
Example #5
Source File: AbstractMicronautLambdaRuntime.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
/**
 * @param args command line arguments
 * @return An {@link ApplicationContextBuilder} with the command line arguments as a property source and the environment set to lambda
 */
public ApplicationContextBuilder createApplicationContextBuilderWithArgs(String... args) {
    CommandLine commandLine = CommandLine.parse(args);
    return ApplicationContext.build()
            .environments(MicronautLambdaContext.ENVIRONMENT_LAMBDA)
            .propertySources(new CommandLinePropertySource(commandLine));
}
 
Example #6
Source File: MicronautRequestStreamHandler.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected ApplicationContextBuilder newApplicationContextBuilder() {
    return super.newApplicationContextBuilder()
            .environments(ENVIRONMENT_LAMBDA)
            .eagerInitSingletons(true)
            .eagerInitConfiguration(true);
}
 
Example #7
Source File: MicronautRequestHandler.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Nonnull
@Override
protected ApplicationContextBuilder newApplicationContextBuilder() {
    return super.newApplicationContextBuilder()
            .environments(ENVIRONMENT_LAMBDA)
            .eagerInitSingletons(true)
            .eagerInitConfiguration(true);
}
 
Example #8
Source File: MicronautLambdaHandler.java    From micronaut-aws with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor.
 * @param applicationContextBuilder Application Context Builder
 * @throws ContainerInitializationException thrown intializing {@link MicronautLambdaHandler}
 */
public MicronautLambdaHandler(ApplicationContextBuilder applicationContextBuilder) throws ContainerInitializationException {
    this.handler = new MicronautLambdaContainerHandler(applicationContextBuilder);
}
 
Example #9
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 2 votes vote down vote up
/**
 * Default constructor.
 *
 * @param applicationContextBuilder The context builder
 * @throws ContainerInitializationException The exception
 */
public MicronautLambdaContainerHandler(ApplicationContextBuilder applicationContextBuilder) throws ContainerInitializationException {
    this(new LambdaContainerState(), applicationContextBuilder);
}
 
Example #10
Source File: MicronautLambdaContainerHandler.java    From micronaut-aws with Apache License 2.0 2 votes vote down vote up
/**
 * Gets a new {@link MicronautLambdaContainerHandler} should be called exactly once.
 *
 * @param builder The builder to customize the context creation
 * @return The {@link MicronautLambdaContainerHandler}
 * @throws ContainerInitializationException if the container couldn't be started
 * @deprecated Use {@link #MicronautLambdaContainerHandler(ApplicationContextBuilder)} instead
 */
@Deprecated
public static MicronautLambdaContainerHandler getAwsProxyHandler(ApplicationContextBuilder builder) throws ContainerInitializationException {
    ArgumentUtils.requireNonNull("builder", builder);
    return new MicronautLambdaContainerHandler(new LambdaContainerState(), builder);
}
 
Example #11
Source File: MicronautApplicationContext.java    From micronaut-spring with Apache License 2.0 2 votes vote down vote up
/**
 * Customization constructor.
 * @param contextBuilder The context builder
 */
public MicronautApplicationContext(ApplicationContextBuilder contextBuilder) {
    this.micronautContext = contextBuilder.build();
}