本文整理汇总了Java中org.springframework.cloud.aws.jdbc.datasource.TomcatJdbcDataSourceFactory类的典型用法代码示例。如果您正苦于以下问题:Java TomcatJdbcDataSourceFactory类的具体用法?Java TomcatJdbcDataSourceFactory怎么用?Java TomcatJdbcDataSourceFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TomcatJdbcDataSourceFactory类属于org.springframework.cloud.aws.jdbc.datasource包,在下文中一共展示了TomcatJdbcDataSourceFactory类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerDataSource
import org.springframework.cloud.aws.jdbc.datasource.TomcatJdbcDataSourceFactory; //导入依赖的package包/类
protected void registerDataSource(BeanDefinitionRegistry beanDefinitionRegistry, String amazonRdsClientBeanName, String dbInstanceIdentifier,
String password, boolean readReplica, String userName, String databaseName) {
BeanDefinitionBuilder datasourceBuilder = getBeanDefinitionBuilderForDataSource(readReplica);
//Constructor (mandatory) args
datasourceBuilder.addConstructorArgReference(amazonRdsClientBeanName);
datasourceBuilder.addConstructorArgValue(dbInstanceIdentifier);
datasourceBuilder.addConstructorArgValue(password);
//optional args
datasourceBuilder.addPropertyValue("username", userName);
datasourceBuilder.addPropertyValue("databaseName", databaseName);
String resourceResolverBeanName = GlobalBeanDefinitionUtils.retrieveResourceIdResolverBeanName(beanDefinitionRegistry);
datasourceBuilder.addPropertyReference("resourceIdResolver", resourceResolverBeanName);
datasourceBuilder.addPropertyValue("dataSourceFactory", BeanDefinitionBuilder.rootBeanDefinition(TomcatJdbcDataSourceFactory.class).getBeanDefinition());
beanDefinitionRegistry.registerBeanDefinition(dbInstanceIdentifier, datasourceBuilder.getBeanDefinition());
}
示例2: createDataSourceFactoryBeanDefinition
import org.springframework.cloud.aws.jdbc.datasource.TomcatJdbcDataSourceFactory; //导入依赖的package包/类
/**
* Creates a {@link org.springframework.cloud.aws.jdbc.datasource.DataSourceFactory} implementation. Uses the
* TomcatJdbcDataSourceFactory implementation and passes all pool attributes from the xml directly to the class
* (through setting the bean properties).
*
* @param element
* - The datasource element which may contain a pool-attributes element
* @return - fully configured bean definition for the DataSourceFactory
*/
private static AbstractBeanDefinition createDataSourceFactoryBeanDefinition(Element element) {
BeanDefinitionBuilder datasourceFactoryBuilder = BeanDefinitionBuilder.rootBeanDefinition(TomcatJdbcDataSourceFactory.class);
Element poolAttributes = DomUtils.getChildElementByTagName(element, "pool-attributes");
if (poolAttributes != null) {
NamedNodeMap attributes = poolAttributes.getAttributes();
for (int i = 0, x = attributes.getLength(); i < x; i++) {
Node item = attributes.item(i);
datasourceFactoryBuilder.addPropertyValue(item.getNodeName(), item.getNodeValue());
}
}
return datasourceFactoryBuilder.getBeanDefinition();
}
示例3: instanceConfigurer
import org.springframework.cloud.aws.jdbc.datasource.TomcatJdbcDataSourceFactory; //导入依赖的package包/类
@Bean
public RdsInstanceConfigurer instanceConfigurer() {
return () -> {
TomcatJdbcDataSourceFactory dataSourceFactory = new TomcatJdbcDataSourceFactory();
dataSourceFactory.setInitialSize(0);
dataSourceFactory.setValidationQuery("SELECT 1 FROM TEST");
return dataSourceFactory;
};
}
示例4: postProcessAfterInitialization
import org.springframework.cloud.aws.jdbc.datasource.TomcatJdbcDataSourceFactory; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof TomcatJdbcDataSourceFactory) {
TomcatJdbcDataSourceFactory tomcatJdbcDataSourceFactory = (TomcatJdbcDataSourceFactory) bean;
tomcatJdbcDataSourceFactory.setTestOnBorrow(true);
tomcatJdbcDataSourceFactory.setValidationQuery("SELECT 1");
}
return bean;
}
示例5: tomcatJdbcDataSourceFactory
import org.springframework.cloud.aws.jdbc.datasource.TomcatJdbcDataSourceFactory; //导入依赖的package包/类
TomcatJdbcDataSourceFactory tomcatJdbcDataSourceFactory() {
TomcatJdbcDataSourceFactory fac = new TomcatJdbcDataSourceFactory();
fac.setRemoveAbandonedTimeout(360000);
fac.setMaxWait(20000);
return fac;
}