本文整理匯總了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;
}