io.micronaut.context.annotation.EachBean Java Examples
The following examples show how to use
io.micronaut.context.annotation.EachBean.
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: StandardSkillFactory.java From micronaut-aws with Apache License 2.0 | 5 votes |
/** * @param alexaSkillConfiguration Alexa Skill Configuration * @return An Alexa Skill using the {@link AlexaSkillBuilder} and the {@link SkillBuilderProvider} bean. */ @EachBean(AlexaSkillConfiguration.class) public Skill createSkill(@Parameter AlexaSkillConfiguration alexaSkillConfiguration) { AlexaSkill alexaSkill = alexaSkillBuilder.buildSkill(skillBuilderProvider.getSkillBuilder(), alexaSkillConfiguration); if (alexaSkill instanceof Skill) { return ((Skill) alexaSkill); } return null; }
Example #2
Source File: DatasourceFactory.java From micronaut-sql with Apache License 2.0 | 5 votes |
/** * Method to wire up all the HikariCP connections based on the {@link DatasourceConfiguration}. * If a {@link MeterRegistry} bean exists then the registry will be added to the datasource. * * @param datasourceConfiguration A {@link DatasourceConfiguration} * @return A {@link HikariUrlDataSource} */ @Context @EachBean(DatasourceConfiguration.class) public DataSource dataSource(DatasourceConfiguration datasourceConfiguration) { HikariUrlDataSource ds = new HikariUrlDataSource(datasourceConfiguration); addMeterRegistry(ds); dataSources.add(ds); return ds; }
Example #3
Source File: DatasourceFactory.java From micronaut-sql with Apache License 2.0 | 5 votes |
/** * @param datasourceConfiguration A {@link DatasourceConfiguration} * @return An Apache Tomcat {@link DataSource} */ @Context @EachBean(DatasourceConfiguration.class) public DataSource dataSource(DatasourceConfiguration datasourceConfiguration) { org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(datasourceConfiguration); dataSources.add(ds); return ds; }
Example #4
Source File: DatasourceFactory.java From micronaut-sql with Apache License 2.0 | 5 votes |
/** * Method to create a metadata object that allows pool value lookup for each datasource object. * * @param dataSource The datasource * @return a {@link TomcatDataSourcePoolMetadata} */ @EachBean(DataSource.class) @Requires(beans = {DatasourceConfiguration.class}) public TomcatDataSourcePoolMetadata tomcatPoolDataSourceMetadataProvider( DataSource dataSource) { TomcatDataSourcePoolMetadata dataSourcePoolMetadata = null; DataSource resolved = dataSourceResolver.resolve(dataSource); if (resolved instanceof org.apache.tomcat.jdbc.pool.DataSource) { dataSourcePoolMetadata = new TomcatDataSourcePoolMetadata((org.apache.tomcat.jdbc.pool.DataSource) resolved); } return dataSourcePoolMetadata; }
Example #5
Source File: DatasourceFactory.java From micronaut-sql with Apache License 2.0 | 5 votes |
/** * Method to get a PoolDataSource from the {@link DatasourceConfiguration}. * * @param datasourceConfiguration A {@link DatasourceConfiguration} * @return A {@link PoolDataSource} */ @Context @EachBean(DatasourceConfiguration.class) public PoolDataSource dataSource(DatasourceConfiguration datasourceConfiguration) { PoolDataSource ds = datasourceConfiguration.delegate; dataSources.add(ds); return ds; }
Example #6
Source File: StandardSkillFactory.java From micronaut-aws with Apache License 2.0 | 4 votes |
/** * @param alexaSkillConfiguration Alexa Skill Configuration * @return An Alexa Skill using the {@link AlexaSkillBuilder} and the {@link SkillBuilderProvider} bean. */ @EachBean(AlexaSkillConfiguration.class) public AlexaSkill createStandardAlexaSkill(@Parameter AlexaSkillConfiguration alexaSkillConfiguration) { return alexaSkillBuilder.buildSkill(skillBuilderProvider.getSkillBuilder(), alexaSkillConfiguration); }
Example #7
Source File: JooqConfigurationFactory.java From micronaut-sql with Apache License 2.0 | 4 votes |
/** * Creates jOOQ {@link Configuration}. * It will configure it with available jOOQ provider beans with the same qualifier. * * @param name The data source name * @param dataSource The {@link DataSource} * @param transactionProvider The transaction provider * @param settings The settings * @param executorProvider The executor provider * @param recordMapperProvider The record mapper provider * @param recordUnmapperProvider The record unmapper provider * @param metaProvider The metadata provider * @param ctx The {@link ApplicationContext} * @return A {@link Configuration} */ @EachBean(DataSource.class) public Configuration jooqConfiguration( @Parameter String name, DataSource dataSource, @Parameter @Nullable TransactionProvider transactionProvider, @Parameter @Nullable Settings settings, @Parameter @Nullable ExecutorProvider executorProvider, @Parameter @Nullable RecordMapperProvider recordMapperProvider, @Parameter @Nullable RecordUnmapperProvider recordUnmapperProvider, @Parameter @Nullable MetaProvider metaProvider, ApplicationContext ctx ) { DefaultConfiguration configuration = new DefaultConfiguration(); JooqConfigurationProperties properties = ctx.findBean(JooqConfigurationProperties.class, Qualifiers.byName(name)) .orElseGet(JooqConfigurationProperties::new); DataSourceResolver dataSourceResolver = ctx.findBean(DataSourceResolver.class).orElse(DataSourceResolver.DEFAULT); configuration.setSQLDialect(properties.determineSqlDialect(dataSourceResolver.resolve(dataSource))); configuration.setDataSource(dataSource); if (transactionProvider != null) { configuration.setTransactionProvider(transactionProvider); } if (settings != null) { configuration.setSettings(settings); } if (executorProvider != null) { configuration.setExecutorProvider(executorProvider); } if (recordMapperProvider != null) { configuration.setRecordMapperProvider(recordMapperProvider); } if (recordUnmapperProvider != null) { configuration.setRecordUnmapperProvider(recordUnmapperProvider); } if (metaProvider != null) { configuration.setMetaProvider(metaProvider); } configuration.setExecuteListenerProvider(ctx.getBeansOfType(ExecuteListenerProvider.class, Qualifiers.byName(name)) .toArray(new ExecuteListenerProvider[0])); configuration.setRecordListenerProvider(ctx.getBeansOfType(RecordListenerProvider.class, Qualifiers.byName(name)) .toArray(new RecordListenerProvider[0])); configuration.setVisitListenerProvider(ctx.getBeansOfType(VisitListenerProvider.class, Qualifiers.byName(name)) .toArray(new VisitListenerProvider[0])); configuration.setTransactionListenerProvider(ctx.getBeansOfType(TransactionListenerProvider.class, Qualifiers.byName(name)) .toArray(new TransactionListenerProvider[0])); configuration.setDiagnosticsListenerProvider(ctx.getBeansOfType(DiagnosticsListenerProvider.class, Qualifiers.byName(name)) .toArray(new DiagnosticsListenerProvider[0])); return configuration; }
Example #8
Source File: JooqConfigurationFactory.java From micronaut-sql with Apache License 2.0 | 2 votes |
/** * Created {@link DSLContext} based on {@link Configuration}. * * @param configuration The {@link Configuration} * @return A {@link DSLContext} */ @EachBean(Configuration.class) public DSLContext dslContext(Configuration configuration) { return new DefaultDSLContext(configuration); }
Example #9
Source File: KafkaStreamsFactory.java From micronaut-kafka with Apache License 2.0 | 2 votes |
/** * Exposes the {@link ConfiguredStreamBuilder} as a bean. * * @param configuration The configuration * @return The streams builder */ @EachBean(AbstractKafkaStreamsConfiguration.class) ConfiguredStreamBuilder streamsBuilder(AbstractKafkaStreamsConfiguration<?, ?> configuration) { return new ConfiguredStreamBuilder(configuration.getConfig()); }