當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。