当前位置: 首页>>代码示例>>Java>>正文


Java DataSourceDefinition类代码示例

本文整理汇总了Java中javax.annotation.sql.DataSourceDefinition的典型用法代码示例。如果您正苦于以下问题:Java DataSourceDefinition类的具体用法?Java DataSourceDefinition怎么用?Java DataSourceDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataSourceDefinition类属于javax.annotation.sql包,在下文中一共展示了DataSourceDefinition类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createDelegate

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
private DataSource createDelegate(DataSourceDefinition dataSourceDefinition) {
    HikariConfig config = new HikariConfig();
    if (dataSourceDefinition.url() != null) {
        config.setJdbcUrl(dataSourceDefinition.url());
    }
    if (dataSourceDefinition.user() != null) {
        config.setUsername(dataSourceDefinition.user());
        config.setPassword(dataSourceDefinition.password());
    }
    if (dataSourceDefinition.maxPoolSize() > 0) {
        config.setMaximumPoolSize(dataSourceDefinition.maxPoolSize());
    }
    config.addDataSourceProperty("cachePrepStmts", "true");
    config.addDataSourceProperty("prepStmtCacheSize", "250");
    config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
    return wrap(new HikariDataSource(config));
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:18,代码来源:HammockDataSource.java

示例2: registerDataSources

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public void registerDataSources(@Observes AfterBeanDiscovery afterBeanDiscovery) {
    DataSourceDefinition defaultDataSource = dataSourceDefinitions.stream()
            .filter(dsd -> dsd.name().equals(EntityManagerFactoryProvider.DEFAULT_EMF))
            .findFirst()
            .orElse(null);
    Bean<ws.ament.hammock.jpa.DataSourceDefinition> defaultBean = beanDelegates
            .stream()
            .filter(b -> b.getName().equals(EntityManagerFactoryProvider.DEFAULT_EMF))
            .findFirst()
            .orElse(null);
    dataSourceDefinitions.stream().map(dataSourceDefinitionDataSourceDefinitionFunction)
            .map(dataSourceDefinition ->  new DataSourceDelegateBean(dataSourceDefinition.getName(),
                    () -> dataSourceDefinition))
            .forEach(afterBeanDiscovery::addBean);
    beanDelegates.stream().map(bean -> new DataSourceDelegateBean(bean.getName(), () -> bean.create(null)))
            .forEach(afterBeanDiscovery::addBean);
    databaseProducers.stream().map(producer -> new DataSourceDelegateBean(producer, create(producer)))
            .forEach(afterBeanDiscovery::addBean);
    if (defaultBean == null && defaultDataSource == null) {
        afterBeanDiscovery.addBean(new DefaultDataSourceBean());
    }
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:23,代码来源:DataSourceExtension.java

示例3: HammockDataSource

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public HammockDataSource(DataSourceDefinition dataSourceDefinition) {
    this.name = dataSourceDefinition.name();
    this.delegate = createDelegate(dataSourceDefinition);
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:5,代码来源:HammockDataSource.java

示例4: findDataSourceDefinition

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public void findDataSourceDefinition(@Observes @WithAnnotations(DataSourceDefinition.class) ProcessAnnotatedType<?> pat) {
    DataSourceDefinition annotation = pat.getAnnotatedType().getJavaClass().getAnnotation(DataSourceDefinition.class);
    dataSourceDefinitions.add(annotation);
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:5,代码来源:DataSourceExtension.java

示例5: findDataSourceDefinitionBeans

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public void findDataSourceDefinitionBeans(@Observes ProcessBean<ws.ament.hammock.jpa.DataSourceDefinition> processBean) {
    beanDelegates.add(processBean.getBean());
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:4,代码来源:DataSourceExtension.java

示例6: findDataSourceProducers

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public void findDataSourceProducers(@Observes ProcessProducer<?, ws.ament.hammock.jpa.DataSourceDefinition> processProducer) {
    Database database = processProducer.getAnnotatedMember().getAnnotation(Database.class);
    databaseProducers.add(database.value());
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:5,代码来源:DataSourceExtension.java

示例7: create

import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
private Supplier<ws.ament.hammock.jpa.DataSourceDefinition> create(String name) {
    return () -> CDI.current().select(ws.ament.hammock.jpa.DataSourceDefinition.class)
            .select(database(name))
            .get();
}
 
开发者ID:hammock-project,项目名称:hammock,代码行数:6,代码来源:DataSourceExtension.java


注:本文中的javax.annotation.sql.DataSourceDefinition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。