io.micronaut.context.event.BeanCreatedEvent Java Examples
The following examples show how to use
io.micronaut.context.event.BeanCreatedEvent.
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: AlternativeMigrationRunner.java From micronaut-flyway with Apache License 2.0 | 6 votes |
@Override public FlywayConfigurationProperties onCreated(BeanCreatedEvent<FlywayConfigurationProperties> event) { FlywayConfigurationProperties config = event.getBean(); String name = config.getNameQualifier(); if (config.isEnabled()) { if (config.hasAlternativeDatabaseConfiguration()) { DataSource dataSource = new DriverDataSource(Thread.currentThread().getContextClassLoader(), null, config.getUrl(), config.getUser(), config.getPassword()); run(config, dataSource); } else { if (!applicationContext.containsBean(DataSource.class, Qualifiers.byName(name))) { if (LOG.isDebugEnabled()) { LOG.debug("* Flyway bean not created for identifier [" + name + "] because no data source was found with a named qualifier of the same name."); } } } } return config; }
Example #2
Source File: DataSourceMigrationRunner.java From micronaut-flyway with Apache License 2.0 | 6 votes |
@Override public DataSource onCreated(BeanCreatedEvent<DataSource> event) { DataSource dataSource = dataSourceResolver.resolve(event.getBean()); if (event.getBeanDefinition() instanceof NameResolver) { ((NameResolver) event.getBeanDefinition()) .resolveName() .ifPresent(name -> { applicationContext .findBean(FlywayConfigurationProperties.class, Qualifiers.byName(name)) .ifPresent(flywayConfig -> run(flywayConfig, dataSource)); }); } return dataSource; }
Example #3
Source File: HibernateMetricsBinder.java From micronaut-sql with Apache License 2.0 | 6 votes |
@Override public EntityManagerFactory onCreated(BeanCreatedEvent<EntityManagerFactory> event) { EntityManagerFactory entityManagerFactory = event.getBean(); String sessionFactoryName = event.getBeanIdentifier().getName(); MeterRegistry meterRegistry = meterRegistryProvider.get(); if (entityManagerFactory instanceof SessionFactory) { HibernateMetrics.monitor( meterRegistry, (SessionFactory) entityManagerFactory, sessionFactoryName, tags ); } return entityManagerFactory; }
Example #4
Source File: HibernateJCacheManagerBinder.java From micronaut-sql with Apache License 2.0 | 5 votes |
@Override public JpaConfiguration onCreated(BeanCreatedEvent<JpaConfiguration> event) { JpaConfiguration jpaConfiguration = event.getBean(); Map<String, Object> jpaProperties = jpaConfiguration.getProperties(); jpaProperties.put(ConfigSettings.CACHE_MANAGER, cacheManager); return jpaConfiguration; }
Example #5
Source File: PhysicalNamingStrategyConfiguration.java From micronaut-data with Apache License 2.0 | 5 votes |
@Override public JpaConfiguration onCreated(BeanCreatedEvent<JpaConfiguration> event) { JpaConfiguration jpaConfiguration = event.getBean(); jpaConfiguration.getProperties().putIfAbsent( AvailableSettings.PHYSICAL_NAMING_STRATEGY, physicalNamingStrategy ); return jpaConfiguration; }
Example #6
Source File: TransactionAwareDataSource.java From micronaut-data with Apache License 2.0 | 5 votes |
@Override public DataSource onCreated(BeanCreatedEvent<DataSource> event) { final BeanIdentifier beanIdentifier = event.getBeanIdentifier(); String name = beanIdentifier.getName(); if (name.equalsIgnoreCase("primary")) { name = "default"; } this.qualifier = name; return new DataSourceProxy(event.getBean()); }
Example #7
Source File: GormMigrationRunner.java From micronaut-flyway with Apache License 2.0 | 5 votes |
@Override public HibernateDatastore onCreated(BeanCreatedEvent<HibernateDatastore> event) { HibernateDatastore hibernateDatastore = event.getBean(); hibernateDatastore.getConnectionSources().forEach(connectionSource -> { String qualifier = connectionSource.getName(); DataSource dataSource = ((HibernateConnectionSource) connectionSource).getDataSource(); applicationContext .findBean(FlywayConfigurationProperties.class, Qualifiers.byName(qualifier)) .ifPresent(flywayConfig -> run(flywayConfig, dataSource)); }); return hibernateDatastore; }
Example #8
Source File: ObjectMapperBeanEventListener.java From micronaut-microservices-poc with Apache License 2.0 | 5 votes |
@Override public ObjectMapper onCreated(BeanCreatedEvent<ObjectMapper> event) { final ObjectMapper mapper = event.getBean(); mapper.registerModule(new JavaTimeModule()); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); return mapper; }
Example #9
Source File: AbstractKafkaMetrics.java From micronaut-kafka with Apache License 2.0 | 5 votes |
/** * Method to add a default metric reporter if not otherwise defined. * * @param event The event for bean created of type AbstractKafkaConfiguration * @param kafkaMetricsReporterClassName The class name to use for kafka metrics registration * @return The bean */ T addKafkaMetrics(BeanCreatedEvent<T> event, String kafkaMetricsReporterClassName) { Properties props = event.getBean().getConfig(); if (!props.containsKey(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG)) { props.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG, kafkaMetricsReporterClassName); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Adding kafka property:value of %s:%s", ProducerConfig.METRIC_REPORTER_CLASSES_CONFIG, kafkaMetricsReporterClassName)); } } return event.getBean(); }
Example #10
Source File: DataSourceTransactionManagerFactory.java From micronaut-sql with Apache License 2.0 | 5 votes |
@Override public DataSource onCreated(BeanCreatedEvent<DataSource> event) { DataSource dataSource = event.getBean(); if (dataSource instanceof TransactionAwareDataSourceProxy) { return dataSource; } else { return new TransactionAwareDataSourceProxy(dataSource); } }
Example #11
Source File: GoogleJacksonConfiguration.java From micronaut-gcp with Apache License 2.0 | 5 votes |
@Override public JacksonConfiguration onCreated(BeanCreatedEvent<JacksonConfiguration> event) { JacksonConfiguration jacksonConfiguration = event.getBean(); jacksonConfiguration.setModuleScan(false); jacksonConfiguration.setBeanIntrospectionModule(true); return jacksonConfiguration; }
Example #12
Source File: S3ClientBuilderListener.java From micronaut-aws with Apache License 2.0 | 5 votes |
@Override public S3ClientBuilder onCreated(BeanCreatedEvent<S3ClientBuilder> event) { S3ClientBuilder builder = event.getBean(); builder.overrideConfiguration(ClientOverrideConfiguration.builder().retryPolicy(RetryMode.LEGACY).build()); return builder; }
Example #13
Source File: ObjectMapperCustomizer.java From micronaut-gcp with Apache License 2.0 | 5 votes |
@Override public ObjectMapper onCreated(BeanCreatedEvent<ObjectMapper> event) { ObjectMapper objectMapper = event.getBean(); // register modules manually objectMapper.registerModule(new JavaTimeModule()); objectMapper.registerModule(new Jdk8Module()); return objectMapper; }
Example #14
Source File: SpringAwareListener.java From micronaut-spring with Apache License 2.0 | 4 votes |
@Override public Object onCreated(BeanCreatedEvent<Object> event) { final Object bean = event.getBean(); return onBeanCreated(bean); }
Example #15
Source File: ServerBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ServerBuilder<?> onCreated(BeanCreatedEvent<ServerBuilder<?>> event) { final ServerBuilder<?> builder = event.getBean(); builder.maxInboundMessageSize(1024); return builder; }
Example #16
Source File: ManagedChannelBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ManagedChannelBuilder<?> onCreated(BeanCreatedEvent<ManagedChannelBuilder<?>> event) { final ManagedChannelBuilder<?> channelBuilder = event.getBean(); channelBuilder.maxInboundMessageSize(1024); return channelBuilder; }
Example #17
Source File: ServerBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ServerBuilder<?> onCreated(BeanCreatedEvent<ServerBuilder<?>> event) { final ServerBuilder<?> builder = event.getBean(); builder.maxInboundMessageSize(1024); return builder; }
Example #18
Source File: ManagedChannelBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ManagedChannelBuilder<?> onCreated(BeanCreatedEvent<ManagedChannelBuilder<?>> event) { final ManagedChannelBuilder<?> channelBuilder = event.getBean(); channelBuilder.maxInboundMessageSize(1024); return channelBuilder; }
Example #19
Source File: BraveKafkaConsumerTracingInstrumentation.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Override public Consumer<?, ?> onCreated(BeanCreatedEvent<Consumer<?, ?>> event) { return kafkaTracing.consumer(event.getBean()); }
Example #20
Source File: BraveKafkaProducerTracingInstrumentation.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Override public Producer<?, ?> onCreated(BeanCreatedEvent<Producer<?, ?>> event) { return kafkaTracing.producer(event.getBean()); }
Example #21
Source File: KafkaConsumerTracingInstrumentation.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Override public Consumer<?, ?> onCreated(BeanCreatedEvent<Consumer<?, ?>> event) { final Consumer<?, ?> consumer = event.getBean(); return new TracingKafkaConsumer<>(consumer, tracerProvider.get()); }
Example #22
Source File: KafkaProducerTracingInstrumentation.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Override public Producer<?, ?> onCreated(BeanCreatedEvent<Producer<?, ?>> event) { final Producer<?, ?> kafkaProducer = event.getBean(); return new TracingKafkaProducer<>(kafkaProducer, tracerProvider.get()); }
Example #23
Source File: KafkaProducerMetrics.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Override public AbstractKafkaProducerConfiguration onCreated(BeanCreatedEvent<AbstractKafkaProducerConfiguration> event) { beanLocator.findBean(MeterRegistry.class).ifPresent(METER_REGISTRIES::add); return addKafkaMetrics(event, ProducerKafkaMetricsReporter.class.getName()); }
Example #24
Source File: KafkaConsumerMetrics.java From micronaut-kafka with Apache License 2.0 | 4 votes |
@Override public AbstractKafkaConsumerConfiguration onCreated(BeanCreatedEvent<AbstractKafkaConsumerConfiguration> event) { beanLocator.findBean(MeterRegistry.class).ifPresent(METER_REGISTRIES::add); return addKafkaMetrics(event, ConsumerKafkaMetricsReporter.class.getName()); }
Example #25
Source File: ManagedChannelBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ManagedChannelBuilder<?> onCreated(BeanCreatedEvent<ManagedChannelBuilder<?>> event) { final ManagedChannelBuilder<?> channelBuilder = event.getBean(); channelBuilder.maxInboundMessageSize(1024); return channelBuilder; }
Example #26
Source File: ServerBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ServerBuilder<?> onCreated(BeanCreatedEvent<ServerBuilder<?>> event) { final ServerBuilder<?> builder = event.getBean(); builder.maxInboundMessageSize(1024); return builder; }
Example #27
Source File: ManagedChannelBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ManagedChannelBuilder<?> onCreated(BeanCreatedEvent<ManagedChannelBuilder<?>> event) { final ManagedChannelBuilder<?> channelBuilder = event.getBean(); channelBuilder.maxInboundMessageSize(1024); return channelBuilder; }
Example #28
Source File: ServerBuilderListener.java From micronaut-grpc with Apache License 2.0 | 4 votes |
@Override public ServerBuilder<?> onCreated(BeanCreatedEvent<ServerBuilder<?>> event) { final ServerBuilder<?> builder = event.getBean(); builder.maxInboundMessageSize(1024); return builder; }