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


Java TomcatJdbcDataSourceFactory类代码示例

本文整理汇总了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());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:21,代码来源:AmazonRdsInstanceConfiguration.java

示例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();
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:23,代码来源:AmazonRdsDataSourceBeanDefinitionParser.java

示例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;
    };
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:10,代码来源:AmazonRdsInstanceConfigurationTest.java

示例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;
}
 
开发者ID:spring-cloud-samples,项目名称:aws-refapp,代码行数:10,代码来源:PoolConfiguration.java

示例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;

    }
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:10,代码来源:RdsDataSourceFactorBeanPostProcessor.java


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