io.micronaut.runtime.ApplicationConfiguration Java Examples

The following examples show how to use io.micronaut.runtime.ApplicationConfiguration. 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: GrpcEmbeddedServer.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param applicationContext The application context
 * @param applicationConfiguration The application configuration
 * @param grpcServerConfiguration The GRPC server configuration
 * @param serverBuilder The server builder
 * @param eventPublisher The event publisher
 * @param computeInstanceMetadataResolver The computed instance metadata
 * @param metadataContributors The metadata contributors
 */
@Internal
GrpcEmbeddedServer(
        @Nonnull ApplicationContext applicationContext,
        @Nonnull ApplicationConfiguration applicationConfiguration,
        @Nonnull GrpcServerConfiguration grpcServerConfiguration,
        @Nonnull ServerBuilder<?> serverBuilder,
        @Nonnull ApplicationEventPublisher eventPublisher,
        @Nullable ComputeInstanceMetadataResolver computeInstanceMetadataResolver,
        @Nullable List<ServiceInstanceMetadataContributor> metadataContributors) {
    ArgumentUtils.requireNonNull("applicationContext", applicationContext);
    ArgumentUtils.requireNonNull("applicationConfiguration", applicationConfiguration);
    ArgumentUtils.requireNonNull("grpcServerConfiguration", grpcServerConfiguration);
    this.applicationContext = applicationContext;
    this.configuration = applicationConfiguration;
    this.grpcConfiguration = grpcServerConfiguration;
    this.eventPublisher = eventPublisher;
    this.server = serverBuilder.build();
    this.computeInstanceMetadataResolver = computeInstanceMetadataResolver;
    this.metadataContributors = metadataContributors;
}
 
Example #2
Source File: KafkaConsumerProcessor.java    From micronaut-kafka with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new processor using the given {@link ExecutorService} to schedule consumers on.
 *
 * @param executorService              The executor service
 * @param applicationConfiguration     The application configuration
 * @param beanContext                  The bean context
 * @param defaultConsumerConfiguration The default consumer config
 * @param binderRegistry               The {@link ConsumerRecordBinderRegistry}
 * @param batchBinderRegistry          The {@link BatchConsumerRecordsBinderRegistry}
 * @param serdeRegistry                The {@link org.apache.kafka.common.serialization.Serde} registry
 * @param producerRegistry             The {@link ProducerRegistry}
 * @param exceptionHandler             The exception handler to use
 */
public KafkaConsumerProcessor(
        @Named(TaskExecutors.MESSAGE_CONSUMER) ExecutorService executorService,
        ApplicationConfiguration applicationConfiguration,
        BeanContext beanContext,
        AbstractKafkaConsumerConfiguration defaultConsumerConfiguration,
        ConsumerRecordBinderRegistry binderRegistry,
        BatchConsumerRecordsBinderRegistry batchBinderRegistry,
        SerdeRegistry serdeRegistry,
        ProducerRegistry producerRegistry,
        KafkaListenerExceptionHandler exceptionHandler) {
    this.executorService = executorService;
    this.applicationConfiguration = applicationConfiguration;
    this.beanContext = beanContext;
    this.defaultConsumerConfiguration = defaultConsumerConfiguration;
    this.binderRegistry = binderRegistry;
    this.batchBinderRegistry = batchBinderRegistry;
    this.serdeRegistry = serdeRegistry;
    this.executorScheduler = Schedulers.from(executorService);
    this.producerRegistry = producerRegistry;
    this.exceptionHandler = exceptionHandler;
}
 
Example #3
Source File: GrpcEmbeddedServer.java    From micronaut-grpc with Apache License 2.0 6 votes vote down vote up
/**
 * Default constructor.
 * @param applicationContext The application context
 * @param applicationConfiguration The application configuration
 * @param grpcServerConfiguration The GRPC server configuration
 * @param serverBuilder The server builder
 * @param eventPublisher The event publisher
 * @param computeInstanceMetadataResolver The computed instance metadata
 * @param metadataContributors The metadata contributors
 */
@Internal
GrpcEmbeddedServer(
        @Nonnull ApplicationContext applicationContext,
        @Nonnull ApplicationConfiguration applicationConfiguration,
        @Nonnull GrpcServerConfiguration grpcServerConfiguration,
        @Nonnull ServerBuilder<?> serverBuilder,
        @Nonnull ApplicationEventPublisher eventPublisher,
        @Nullable ComputeInstanceMetadataResolver computeInstanceMetadataResolver,
        @Nullable List<ServiceInstanceMetadataContributor> metadataContributors) {
    ArgumentUtils.requireNonNull("applicationContext", applicationContext);
    ArgumentUtils.requireNonNull("applicationConfiguration", applicationConfiguration);
    ArgumentUtils.requireNonNull("grpcServerConfiguration", grpcServerConfiguration);
    this.applicationContext = applicationContext;
    this.configuration = applicationConfiguration;
    this.grpcConfiguration = grpcServerConfiguration;
    this.eventPublisher = eventPublisher;
    this.server = serverBuilder.build();
    this.computeInstanceMetadataResolver = computeInstanceMetadataResolver;
    this.metadataContributors = metadataContributors;
}
 
Example #4
Source File: AWSParameterStoreConfigClient.java    From micronaut-aws with Apache License 2.0 5 votes vote down vote up
/**
 * Initialize @Singleton.
 *
 * @param awsConfiguration                    your aws configuration credentials
 * @param awsParameterStoreConfiguration      configuration for the parameter store
 * @param applicationConfiguration            the application configuration
 * @param route53ClientDiscoveryConfiguration configuration for route53 service discovery, if you are using this (not required)
 * @throws SdkClientException If the aws sdk client could not be created
 */
AWSParameterStoreConfigClient(
        AWSClientConfiguration awsConfiguration,
        AWSParameterStoreConfiguration awsParameterStoreConfiguration,
        ApplicationConfiguration applicationConfiguration,
        @Nullable Route53ClientDiscoveryConfiguration route53ClientDiscoveryConfiguration) throws SdkClientException {
    this.awsConfiguration = awsConfiguration;
    this.awsParameterStoreConfiguration = awsParameterStoreConfiguration;
    this.client = AWSSimpleSystemsManagementAsyncClient.asyncBuilder().withClientConfiguration(awsConfiguration.getClientConfiguration()).build();
    this.serviceId = (route53ClientDiscoveryConfiguration != null ? route53ClientDiscoveryConfiguration.getServiceId() : applicationConfiguration.getName()).orElse(null);
}
 
Example #5
Source File: AbstractKafkaStreamsConfiguration.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
/**
 * Shared initialization.
 *
 * @param applicationConfiguration The application config
 * @param environment The env
 * @param config The config to be initialized
 */
protected void init(ApplicationConfiguration applicationConfiguration, Environment environment, Properties config) {
    // set the default application id
    String applicationName = applicationConfiguration.getName().orElse(Environment.DEFAULT_NAME);
    config.putIfAbsent(StreamsConfig.APPLICATION_ID_CONFIG, applicationName);

    if (environment.getActiveNames().contains(Environment.TEST)) {
        String tmpDir = System.getProperty("java.io.tmpdir");
        if (StringUtils.isNotEmpty(tmpDir)) {
            if (new File(tmpDir, applicationName).mkdirs()) {
                config.putIfAbsent(StreamsConfig.STATE_DIR_CONFIG, tmpDir);
            }
        }
    }
}
 
Example #6
Source File: KafkaStreamsConfiguration.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a new {@link KafkaStreamsConfiguration} for the given defaults.
 *
 * @param streamName The stream name
 * @param defaultConfiguration The default configuration
 * @param applicationConfiguration The application configuration
 * @param environment The environment
 */
public KafkaStreamsConfiguration(
        @Parameter String streamName,
        KafkaDefaultConfiguration defaultConfiguration,
        ApplicationConfiguration applicationConfiguration,
        Environment environment) {
    super(defaultConfiguration);
    Properties config = getConfig();
    String propertyKey = PREFIX + '.' + NameUtils.hyphenate(streamName, true);
    config.putAll(environment.getProperty(propertyKey, Properties.class).orElseGet(Properties::new));
    init(applicationConfiguration, environment, config);
}
 
Example #7
Source File: DefaultKafkaStreamsConfiguration.java    From micronaut-kafka with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a new {@link KafkaStreamsConfiguration} for the given defaults.
 *
 * @param defaultConfiguration The default configuration
 * @param applicationConfiguration The application configuration
 * @param environment The environment
 */
public DefaultKafkaStreamsConfiguration(KafkaDefaultConfiguration defaultConfiguration,
                                        ApplicationConfiguration applicationConfiguration,
                                        Environment environment) {
    super(defaultConfiguration);
    Properties config = getConfig();
    config.putAll(defaultConfiguration.getConfig());
    init(applicationConfiguration, environment, config);
}
 
Example #8
Source File: GrpcEmbeddedServer.java    From micronaut-grpc with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationConfiguration getApplicationConfiguration() {
    return this.configuration;
}
 
Example #9
Source File: InsuranceAgentJWTClaimsSetGenerator.java    From micronaut-microservices-poc with Apache License 2.0 4 votes vote down vote up
public InsuranceAgentJWTClaimsSetGenerator(TokenConfiguration tokenConfiguration,
                                           @Nullable JwtIdGenerator jwtIdGenerator,
                                           @Nullable ClaimsAudienceProvider claimsAudienceProvider,
                                           @Nullable ApplicationConfiguration applicationConfiguration) {
    super(tokenConfiguration, jwtIdGenerator, claimsAudienceProvider, applicationConfiguration);
}
 
Example #10
Source File: GrpcEmbeddedServer.java    From micronaut-grpc with Apache License 2.0 4 votes vote down vote up
@Override
public ApplicationConfiguration getApplicationConfiguration() {
    return this.configuration;
}