io.micronaut.context.annotation.Context Java Examples

The following examples show how to use io.micronaut.context.annotation.Context. 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: DatasourceFactory.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #2
Source File: DatasourceFactory.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * @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 #3
Source File: DatasourceFactory.java    From micronaut-sql with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #4
Source File: LazyAnnotationMapper.java    From micronaut-spring with Apache License 2.0 5 votes vote down vote up
@Override
protected List<AnnotationValue<?>> mapInternal(AnnotationValue<Annotation> annotation, VisitorContext visitorContext) {
    final boolean lazy = annotation.getValue(Boolean.class).orElse(true);
    if (!lazy) {
        return Collections.singletonList(
                AnnotationValue.builder(Context.class).build()
        );
    }
    return Collections.emptyList();
}