本文整理汇总了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));
}
示例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());
}
}
示例3: HammockDataSource
import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public HammockDataSource(DataSourceDefinition dataSourceDefinition) {
this.name = dataSourceDefinition.name();
this.delegate = createDelegate(dataSourceDefinition);
}
示例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);
}
示例5: findDataSourceDefinitionBeans
import javax.annotation.sql.DataSourceDefinition; //导入依赖的package包/类
public void findDataSourceDefinitionBeans(@Observes ProcessBean<ws.ament.hammock.jpa.DataSourceDefinition> processBean) {
beanDelegates.add(processBean.getBean());
}
示例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());
}
示例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();
}