commit
2de8c49d9f
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.actuate.autoconfigure.metrics;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
import io.micrometer.core.instrument.Meter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A boundary for a service-level agreement (SLA) for use when configuring Micrometer. Can
|
|
||||||
* be specified as either a {@link Long} (applicable to timers and distribution summaries)
|
|
||||||
* or a {@link Duration} (applicable to only timers).
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @since 2.0.0
|
|
||||||
* @deprecated as of 2.3.0 in favor of {@link ServiceLevelObjectiveBoundary}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public final class ServiceLevelAgreementBoundary {
|
|
||||||
|
|
||||||
private final MeterValue value;
|
|
||||||
|
|
||||||
ServiceLevelAgreementBoundary(MeterValue value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the underlying value of the SLA in form suitable to apply to the given meter
|
|
||||||
* type.
|
|
||||||
* @param meterType the meter type
|
|
||||||
* @return the value or {@code null} if the value cannot be applied
|
|
||||||
*/
|
|
||||||
public Long getValue(Meter.Type meterType) {
|
|
||||||
Double value = this.value.getValue(meterType);
|
|
||||||
return (value != null) ? value.longValue() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a new {@link ServiceLevelAgreementBoundary} instance for the given long
|
|
||||||
* value.
|
|
||||||
* @param value the source value
|
|
||||||
* @return a {@link ServiceLevelAgreementBoundary} instance
|
|
||||||
*/
|
|
||||||
public static ServiceLevelAgreementBoundary valueOf(long value) {
|
|
||||||
return new ServiceLevelAgreementBoundary(MeterValue.valueOf(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a new {@link ServiceLevelAgreementBoundary} instance for the given String
|
|
||||||
* value.
|
|
||||||
* @param value the source value
|
|
||||||
* @return a {@link ServiceLevelAgreementBoundary} instance
|
|
||||||
*/
|
|
||||||
public static ServiceLevelAgreementBoundary valueOf(String value) {
|
|
||||||
return new ServiceLevelAgreementBoundary(MeterValue.valueOf(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.batch;
|
|
||||||
|
|
||||||
import org.springframework.batch.core.explore.JobExplorer;
|
|
||||||
import org.springframework.batch.core.launch.JobLauncher;
|
|
||||||
import org.springframework.batch.core.repository.JobRepository;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link ApplicationRunner} to {@link JobLauncher launch} Spring Batch jobs. Runs all
|
|
||||||
* jobs in the surrounding context by default. Can also be used to launch a specific job
|
|
||||||
* by providing a jobName.
|
|
||||||
*
|
|
||||||
* @author Dave Syer
|
|
||||||
* @author Jean-Pierre Bergamin
|
|
||||||
* @author Mahmoud Ben Hassine
|
|
||||||
* @since 1.0.0
|
|
||||||
* @deprecated since 2.3.0 in favor of {@link JobLauncherApplicationRunner}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class JobLauncherCommandLineRunner extends JobLauncherApplicationRunner {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new {@link JobLauncherCommandLineRunner}.
|
|
||||||
* @param jobLauncher to launch jobs
|
|
||||||
* @param jobExplorer to check the job repository for previous executions
|
|
||||||
* @param jobRepository to check if a job instance exists with the given parameters
|
|
||||||
* when running a job
|
|
||||||
*/
|
|
||||||
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer, JobRepository jobRepository) {
|
|
||||||
super(jobLauncher, jobExplorer, jobRepository);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.elasticsearch.rest;
|
|
||||||
|
|
||||||
import org.elasticsearch.client.RestClientBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback interface that can be implemented by beans wishing to further customize the
|
|
||||||
* {@link org.elasticsearch.client.RestClient} via a {@link RestClientBuilder} whilst
|
|
||||||
* retaining default auto-configuration.
|
|
||||||
*
|
|
||||||
* @author Brian Clozel
|
|
||||||
* @since 2.1.0
|
|
||||||
* @deprecated as of 2.3.1 in favor of
|
|
||||||
* {@link org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer}
|
|
||||||
*/
|
|
||||||
@FunctionalInterface
|
|
||||||
@Deprecated
|
|
||||||
public interface RestClientBuilderCustomizer
|
|
||||||
extends org.springframework.boot.autoconfigure.elasticsearch.RestClientBuilderCustomizer {
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deprecated auto-configuration for Elasticsearch client, superseded by classes in
|
|
||||||
* {@code org.springframework.boot.autoconfigure.elasticsearch}.
|
|
||||||
*/
|
|
||||||
package org.springframework.boot.autoconfigure.elasticsearch.rest;
|
|
@ -1,121 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.transaction.jta;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.jms.Message;
|
|
||||||
import javax.transaction.TransactionManager;
|
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import bitronix.tm.BitronixTransactionManager;
|
|
||||||
import bitronix.tm.TransactionManagerServices;
|
|
||||||
import bitronix.tm.jndi.BitronixContext;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
||||||
import org.springframework.boot.jdbc.XADataSourceWrapper;
|
|
||||||
import org.springframework.boot.jms.XAConnectionFactoryWrapper;
|
|
||||||
import org.springframework.boot.system.ApplicationHome;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.transaction.jta.JtaTransactionManager;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JTA Configuration for <A href="https://github.com/bitronix/btm">Bitronix</A>.
|
|
||||||
*
|
|
||||||
* @author Josh Long
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
* @author Kazuki Shimizu
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
|
||||||
@EnableConfigurationProperties(JtaProperties.class)
|
|
||||||
@ConditionalOnClass({ JtaTransactionManager.class, BitronixContext.class })
|
|
||||||
@ConditionalOnMissingBean(org.springframework.transaction.TransactionManager.class)
|
|
||||||
class BitronixJtaConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
@ConfigurationProperties(prefix = "spring.jta.bitronix.properties")
|
|
||||||
bitronix.tm.Configuration bitronixConfiguration(JtaProperties jtaProperties) {
|
|
||||||
bitronix.tm.Configuration config = TransactionManagerServices.getConfiguration();
|
|
||||||
if (StringUtils.hasText(jtaProperties.getTransactionManagerId())) {
|
|
||||||
config.setServerId(jtaProperties.getTransactionManagerId());
|
|
||||||
}
|
|
||||||
File logBaseDir = getLogBaseDir(jtaProperties);
|
|
||||||
config.setLogPart1Filename(new File(logBaseDir, "part1.btm").getAbsolutePath());
|
|
||||||
config.setLogPart2Filename(new File(logBaseDir, "part2.btm").getAbsolutePath());
|
|
||||||
config.setDisableJmx(true);
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private File getLogBaseDir(JtaProperties jtaProperties) {
|
|
||||||
if (StringUtils.hasLength(jtaProperties.getLogDir())) {
|
|
||||||
return new File(jtaProperties.getLogDir());
|
|
||||||
}
|
|
||||||
File home = new ApplicationHome().getDir();
|
|
||||||
return new File(home, "transaction-logs");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean(TransactionManager.class)
|
|
||||||
BitronixTransactionManager bitronixTransactionManager(bitronix.tm.Configuration configuration) {
|
|
||||||
// Inject configuration to force ordering
|
|
||||||
return TransactionManagerServices.getTransactionManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean(XADataSourceWrapper.class)
|
|
||||||
org.springframework.boot.jta.bitronix.BitronixXADataSourceWrapper xaDataSourceWrapper() {
|
|
||||||
return new org.springframework.boot.jta.bitronix.BitronixXADataSourceWrapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
static org.springframework.boot.jta.bitronix.BitronixDependentBeanFactoryPostProcessor bitronixDependentBeanFactoryPostProcessor() {
|
|
||||||
return new org.springframework.boot.jta.bitronix.BitronixDependentBeanFactoryPostProcessor();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
JtaTransactionManager transactionManager(UserTransaction userTransaction, TransactionManager transactionManager,
|
|
||||||
ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
|
|
||||||
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager);
|
|
||||||
transactionManagerCustomizers.ifAvailable((customizers) -> customizers.customize(jtaTransactionManager));
|
|
||||||
return jtaTransactionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
|
||||||
@ConditionalOnClass(Message.class)
|
|
||||||
static class BitronixJtaJmsConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean(XAConnectionFactoryWrapper.class)
|
|
||||||
org.springframework.boot.jta.bitronix.BitronixXAConnectionFactoryWrapper xaConnectionFactoryWrapper() {
|
|
||||||
return new org.springframework.boot.jta.bitronix.BitronixXAConnectionFactoryWrapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id "org.springframework.boot.starter"
|
|
||||||
}
|
|
||||||
|
|
||||||
description = "Starter for JTA transactions using Bitronix. Deprecated since 2.3.0"
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
|
|
||||||
api("jakarta.jms:jakarta.jms-api")
|
|
||||||
api("jakarta.transaction:jakarta.transaction-api")
|
|
||||||
api("org.codehaus.btm:btm") {
|
|
||||||
exclude group: "javax.transaction", module: "jta"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.transaction.TransactionManager;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
||||||
import org.springframework.core.Ordered;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link BeanFactoryPostProcessor} to automatically register the recommended
|
|
||||||
* {@link ConfigurableListableBeanFactory#registerDependentBean(String, String)
|
|
||||||
* dependencies} for correct Bitronix shutdown ordering. With Bitronix it appears that
|
|
||||||
* ConnectionFactory and DataSource beans must be shutdown before the
|
|
||||||
* {@link TransactionManager}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @since 1.2.0
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class BitronixDependentBeanFactoryPostProcessor implements BeanFactoryPostProcessor, Ordered {
|
|
||||||
|
|
||||||
private static final String[] NO_BEANS = {};
|
|
||||||
|
|
||||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
|
||||||
String[] transactionManagers = beanFactory.getBeanNamesForType(TransactionManager.class, true, false);
|
|
||||||
for (String transactionManager : transactionManagers) {
|
|
||||||
addTransactionManagerDependencies(beanFactory, transactionManager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addTransactionManagerDependencies(ConfigurableListableBeanFactory beanFactory,
|
|
||||||
String transactionManager) {
|
|
||||||
for (String dependentBeanName : getBeanNamesForType(beanFactory, "javax.jms.ConnectionFactory")) {
|
|
||||||
beanFactory.registerDependentBean(transactionManager, dependentBeanName);
|
|
||||||
}
|
|
||||||
for (String dependentBeanName : getBeanNamesForType(beanFactory, "javax.sql.DataSource")) {
|
|
||||||
beanFactory.registerDependentBean(transactionManager, dependentBeanName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] getBeanNamesForType(ConfigurableListableBeanFactory beanFactory, String type) {
|
|
||||||
try {
|
|
||||||
return beanFactory.getBeanNamesForType(Class.forName(type), true, false);
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException | NoClassDefFoundError ex) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
return NO_BEANS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
return this.order;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrder(int order) {
|
|
||||||
this.order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.jms.XAConnectionFactory;
|
|
||||||
|
|
||||||
import org.springframework.boot.jms.XAConnectionFactoryWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link XAConnectionFactoryWrapper} that uses a Bitronix
|
|
||||||
* {@link PoolingConnectionFactoryBean} to wrap a {@link XAConnectionFactory}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @since 1.2.0
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class BitronixXAConnectionFactoryWrapper implements XAConnectionFactoryWrapper {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConnectionFactory wrapConnectionFactory(XAConnectionFactory connectionFactory) {
|
|
||||||
PoolingConnectionFactoryBean pool = new PoolingConnectionFactoryBean();
|
|
||||||
pool.setConnectionFactory(connectionFactory);
|
|
||||||
return pool;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.sql.XADataSource;
|
|
||||||
|
|
||||||
import org.springframework.boot.jdbc.XADataSourceWrapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@link XADataSourceWrapper} that uses a Bitronix {@link PoolingDataSourceBean} to wrap
|
|
||||||
* a {@link XADataSource}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @since 1.2.0
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class BitronixXADataSourceWrapper implements XADataSourceWrapper {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PoolingDataSourceBean wrapDataSource(XADataSource dataSource) throws Exception {
|
|
||||||
PoolingDataSourceBean pool = new PoolingDataSourceBean();
|
|
||||||
pool.setDataSource(dataSource);
|
|
||||||
return pool;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.jms.JMSException;
|
|
||||||
import javax.jms.XAConnection;
|
|
||||||
import javax.jms.XAConnectionFactory;
|
|
||||||
import javax.jms.XAJMSContext;
|
|
||||||
|
|
||||||
import bitronix.tm.resource.common.ResourceBean;
|
|
||||||
import bitronix.tm.resource.common.XAStatefulHolder;
|
|
||||||
import bitronix.tm.resource.jms.PoolingConnectionFactory;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanNameAware;
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spring friendly version of {@link PoolingConnectionFactory}. Provides sensible defaults
|
|
||||||
* and also supports direct wrapping of a {@link XAConnectionFactory} instance.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @author Josh Long
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
* @since 1.2.0
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
@ConfigurationProperties(prefix = "spring.jta.bitronix.connectionfactory")
|
|
||||||
public class PoolingConnectionFactoryBean extends PoolingConnectionFactory
|
|
||||||
implements BeanNameAware, InitializingBean, DisposableBean {
|
|
||||||
|
|
||||||
private static final ThreadLocal<PoolingConnectionFactoryBean> source = new ThreadLocal<>();
|
|
||||||
|
|
||||||
private String beanName;
|
|
||||||
|
|
||||||
private XAConnectionFactory connectionFactory;
|
|
||||||
|
|
||||||
public PoolingConnectionFactoryBean() {
|
|
||||||
setMaxPoolSize(10);
|
|
||||||
setTestConnections(true);
|
|
||||||
setAutomaticEnlistingEnabled(true);
|
|
||||||
setAllowLocalTransactions(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void init() {
|
|
||||||
source.set(this);
|
|
||||||
try {
|
|
||||||
super.init();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
source.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBeanName(String name) {
|
|
||||||
this.beanName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
|
||||||
if (!StringUtils.hasLength(getUniqueName())) {
|
|
||||||
setUniqueName(this.beanName);
|
|
||||||
}
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void destroy() throws Exception {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the {@link XAConnectionFactory} directly, instead of calling
|
|
||||||
* {@link #setClassName(String)}.
|
|
||||||
* @param connectionFactory the connection factory to use
|
|
||||||
*/
|
|
||||||
public void setConnectionFactory(XAConnectionFactory connectionFactory) {
|
|
||||||
this.connectionFactory = connectionFactory;
|
|
||||||
setClassName(DirectXAConnectionFactory.class.getName());
|
|
||||||
setDriverProperties(new Properties());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final XAConnectionFactory getConnectionFactory() {
|
|
||||||
return this.connectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception {
|
|
||||||
if (xaFactory instanceof DirectXAConnectionFactory) {
|
|
||||||
xaFactory = ((DirectXAConnectionFactory) xaFactory).getConnectionFactory();
|
|
||||||
}
|
|
||||||
return super.createPooledConnection(xaFactory, bean);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@link XAConnectionFactory} implementation that delegates to the
|
|
||||||
* {@link ThreadLocal} {@link PoolingConnectionFactoryBean}.
|
|
||||||
*
|
|
||||||
* @see PoolingConnectionFactoryBean#setConnectionFactory(XAConnectionFactory)
|
|
||||||
*/
|
|
||||||
public static class DirectXAConnectionFactory implements XAConnectionFactory {
|
|
||||||
|
|
||||||
private final XAConnectionFactory connectionFactory;
|
|
||||||
|
|
||||||
public DirectXAConnectionFactory() {
|
|
||||||
this.connectionFactory = source.get().connectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAConnection createXAConnection() throws JMSException {
|
|
||||||
return this.connectionFactory.createXAConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAConnection createXAConnection(String userName, String password) throws JMSException {
|
|
||||||
return this.connectionFactory.createXAConnection(userName, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XAConnectionFactory getConnectionFactory() {
|
|
||||||
return this.connectionFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAJMSContext createXAContext() {
|
|
||||||
return this.connectionFactory.createXAContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAJMSContext createXAContext(String username, String password) {
|
|
||||||
return this.connectionFactory.createXAContext(username, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.SQLFeatureNotSupportedException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.sql.XAConnection;
|
|
||||||
import javax.sql.XADataSource;
|
|
||||||
|
|
||||||
import bitronix.tm.resource.common.ResourceBean;
|
|
||||||
import bitronix.tm.resource.common.XAStatefulHolder;
|
|
||||||
import bitronix.tm.resource.jdbc.PoolingDataSource;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.BeanNameAware;
|
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Spring friendly version of {@link PoolingDataSource}. Provides sensible defaults and
|
|
||||||
* also supports direct wrapping of a {@link XADataSource} instance.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
* @author Josh Long
|
|
||||||
* @author Andy Wilkinson
|
|
||||||
* @since 1.2.0
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
@ConfigurationProperties(prefix = "spring.jta.bitronix.datasource")
|
|
||||||
public class PoolingDataSourceBean extends PoolingDataSource implements BeanNameAware, InitializingBean {
|
|
||||||
|
|
||||||
private static final ThreadLocal<PoolingDataSourceBean> source = new ThreadLocal<>();
|
|
||||||
|
|
||||||
private XADataSource dataSource;
|
|
||||||
|
|
||||||
private String beanName;
|
|
||||||
|
|
||||||
public PoolingDataSourceBean() {
|
|
||||||
setMaxPoolSize(10);
|
|
||||||
setAllowLocalTransactions(true);
|
|
||||||
setEnableJdbc4ConnectionTest(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void init() {
|
|
||||||
source.set(this);
|
|
||||||
try {
|
|
||||||
super.init();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
source.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBeanName(String name) {
|
|
||||||
this.beanName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterPropertiesSet() throws Exception {
|
|
||||||
if (!StringUtils.hasLength(getUniqueName())) {
|
|
||||||
setUniqueName(this.beanName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the {@link XADataSource} directly, instead of calling
|
|
||||||
* {@link #setClassName(String)}.
|
|
||||||
* @param dataSource the data source to use
|
|
||||||
*/
|
|
||||||
public void setDataSource(XADataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
setClassName(DirectXADataSource.class.getName());
|
|
||||||
setDriverProperties(new Properties());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final XADataSource getDataSource() {
|
|
||||||
return this.dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAStatefulHolder createPooledConnection(Object xaFactory, ResourceBean bean) throws Exception {
|
|
||||||
if (xaFactory instanceof DirectXADataSource) {
|
|
||||||
xaFactory = ((DirectXADataSource) xaFactory).getDataSource();
|
|
||||||
}
|
|
||||||
return super.createPooledConnection(xaFactory, bean);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
|
||||||
XADataSource dataSource = this.dataSource;
|
|
||||||
if (dataSource != null) {
|
|
||||||
try {
|
|
||||||
return dataSource.getParentLogger();
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
// Swallow and continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@link XADataSource} implementation that delegates to the {@link ThreadLocal}
|
|
||||||
* {@link PoolingDataSourceBean}.
|
|
||||||
*
|
|
||||||
* @see PoolingDataSourceBean#setDataSource(XADataSource)
|
|
||||||
*/
|
|
||||||
public static class DirectXADataSource implements XADataSource {
|
|
||||||
|
|
||||||
private final XADataSource dataSource;
|
|
||||||
|
|
||||||
public DirectXADataSource() {
|
|
||||||
this.dataSource = source.get().dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PrintWriter getLogWriter() throws SQLException {
|
|
||||||
return this.dataSource.getLogWriter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAConnection getXAConnection() throws SQLException {
|
|
||||||
return this.dataSource.getXAConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public XAConnection getXAConnection(String user, String password) throws SQLException {
|
|
||||||
return this.dataSource.getXAConnection(user, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLogWriter(PrintWriter out) throws SQLException {
|
|
||||||
this.dataSource.setLogWriter(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLoginTimeout(int seconds) throws SQLException {
|
|
||||||
this.dataSource.setLoginTimeout(seconds);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLoginTimeout() throws SQLException {
|
|
||||||
return this.dataSource.getLoginTimeout();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
|
||||||
return this.dataSource.getParentLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
public XADataSource getDataSource() {
|
|
||||||
return this.dataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Support classes for Bitronix JTA.
|
|
||||||
* @deprecated since 2.3.0 as the Bitronix project is no longer being maintained
|
|
||||||
*/
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import bitronix.tm.BitronixTransactionManager;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.spy;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link BitronixDependentBeanFactoryPostProcessor}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
class BitronixDependentBeanFactoryPostProcessorTests {
|
|
||||||
|
|
||||||
private AnnotationConfigApplicationContext context;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setsDependsOn() {
|
|
||||||
DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory());
|
|
||||||
this.context = new AnnotationConfigApplicationContext(beanFactory);
|
|
||||||
this.context.register(Config.class);
|
|
||||||
this.context.refresh();
|
|
||||||
String name = "bitronixTransactionManager";
|
|
||||||
verify(beanFactory).registerDependentBean(name, "dataSource");
|
|
||||||
verify(beanFactory).registerDependentBean(name, "connectionFactory");
|
|
||||||
this.context.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
|
||||||
static class Config {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
DataSource dataSource() {
|
|
||||||
return mock(DataSource.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
ConnectionFactory connectionFactory() {
|
|
||||||
return mock(ConnectionFactory.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
BitronixTransactionManager bitronixTransactionManager() {
|
|
||||||
return mock(BitronixTransactionManager.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
static BitronixDependentBeanFactoryPostProcessor bitronixPostProcessor() {
|
|
||||||
return new BitronixDependentBeanFactoryPostProcessor();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.jms.ConnectionFactory;
|
|
||||||
import javax.jms.XAConnectionFactory;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link BitronixXAConnectionFactoryWrapper}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
class BitronixXAConnectionFactoryWrapperTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void wrap() {
|
|
||||||
XAConnectionFactory connectionFactory = mock(XAConnectionFactory.class);
|
|
||||||
BitronixXAConnectionFactoryWrapper wrapper = new BitronixXAConnectionFactoryWrapper();
|
|
||||||
ConnectionFactory wrapped = wrapper.wrapConnectionFactory(connectionFactory);
|
|
||||||
assertThat(wrapped).isInstanceOf(PoolingConnectionFactoryBean.class);
|
|
||||||
assertThat(((PoolingConnectionFactoryBean) wrapped).getConnectionFactory()).isSameAs(connectionFactory);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
import javax.sql.XADataSource;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link BitronixXADataSourceWrapper}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
class BitronixXADataSourceWrapperTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void wrap() throws Exception {
|
|
||||||
XADataSource dataSource = mock(XADataSource.class);
|
|
||||||
BitronixXADataSourceWrapper wrapper = new BitronixXADataSourceWrapper();
|
|
||||||
DataSource wrapped = wrapper.wrapDataSource(dataSource);
|
|
||||||
assertThat(wrapped).isInstanceOf(PoolingDataSourceBean.class);
|
|
||||||
assertThat(((PoolingDataSourceBean) wrapped).getDataSource()).isSameAs(dataSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import javax.jms.XAConnectionFactory;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link PoolingConnectionFactoryBean}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
class PoolingConnectionFactoryBeanTests {
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
private PoolingConnectionFactoryBean bean = new PoolingConnectionFactoryBean() {
|
|
||||||
@Override
|
|
||||||
public synchronized void init() {
|
|
||||||
// Stub out for the tests
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void sensibleDefaults() {
|
|
||||||
assertThat(this.bean.getMaxPoolSize()).isEqualTo(10);
|
|
||||||
assertThat(this.bean.getTestConnections()).isTrue();
|
|
||||||
assertThat(this.bean.getAutomaticEnlistingEnabled()).isTrue();
|
|
||||||
assertThat(this.bean.getAllowLocalTransactions()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setsUniqueNameIfNull() throws Exception {
|
|
||||||
this.bean.setBeanName("beanName");
|
|
||||||
this.bean.afterPropertiesSet();
|
|
||||||
assertThat(this.bean.getUniqueName()).isEqualTo("beanName");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void doesNotSetUniqueNameIfNotNull() throws Exception {
|
|
||||||
this.bean.setBeanName("beanName");
|
|
||||||
this.bean.setUniqueName("un");
|
|
||||||
this.bean.afterPropertiesSet();
|
|
||||||
assertThat(this.bean.getUniqueName()).isEqualTo("un");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setConnectionFactory() throws Exception {
|
|
||||||
XAConnectionFactory factory = mock(XAConnectionFactory.class);
|
|
||||||
this.bean.setConnectionFactory(factory);
|
|
||||||
this.bean.setBeanName("beanName");
|
|
||||||
this.bean.afterPropertiesSet();
|
|
||||||
this.bean.init();
|
|
||||||
this.bean.createPooledConnection(factory, this.bean);
|
|
||||||
verify(factory).createXAConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.springframework.boot.jta.bitronix;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLFeatureNotSupportedException;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.sql.XAConnection;
|
|
||||||
import javax.sql.XADataSource;
|
|
||||||
|
|
||||||
import bitronix.tm.TransactionManagerServices;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
import static org.mockito.BDDMockito.given;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for {@link PoolingDataSourceBean}.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
class PoolingDataSourceBeanTests {
|
|
||||||
|
|
||||||
private PoolingDataSourceBean bean = new PoolingDataSourceBean();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void sensibleDefaults() {
|
|
||||||
assertThat(this.bean.getMaxPoolSize()).isEqualTo(10);
|
|
||||||
assertThat(this.bean.getAutomaticEnlistingEnabled()).isTrue();
|
|
||||||
assertThat(this.bean.isEnableJdbc4ConnectionTest()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setsUniqueNameIfNull() throws Exception {
|
|
||||||
this.bean.setBeanName("beanName");
|
|
||||||
this.bean.afterPropertiesSet();
|
|
||||||
assertThat(this.bean.getUniqueName()).isEqualTo("beanName");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void doesNotSetUniqueNameIfNotNull() throws Exception {
|
|
||||||
this.bean.setBeanName("beanName");
|
|
||||||
this.bean.setUniqueName("un");
|
|
||||||
this.bean.afterPropertiesSet();
|
|
||||||
assertThat(this.bean.getUniqueName()).isEqualTo("un");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldReturnGlobalLoggerWhenDataSourceIsAbsent() throws SQLFeatureNotSupportedException {
|
|
||||||
assertThat(this.bean.getParentLogger()).isSameAs(Logger.getLogger(Logger.GLOBAL_LOGGER_NAME));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldReturnGlobalLoggerWhenDataSourceThrowsException() throws SQLFeatureNotSupportedException {
|
|
||||||
XADataSource dataSource = mock(XADataSource.class);
|
|
||||||
given(dataSource.getParentLogger()).willThrow(new SQLFeatureNotSupportedException());
|
|
||||||
this.bean.setDataSource(dataSource);
|
|
||||||
assertThat(this.bean.getParentLogger()).isSameAs(Logger.getLogger(Logger.GLOBAL_LOGGER_NAME));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldReturnParentLoggerFromDataSource() throws SQLFeatureNotSupportedException {
|
|
||||||
Logger logger = Logger.getLogger("test");
|
|
||||||
XADataSource dataSource = mock(XADataSource.class);
|
|
||||||
given(dataSource.getParentLogger()).willReturn(logger);
|
|
||||||
this.bean.setDataSource(dataSource);
|
|
||||||
assertThat(this.bean.getParentLogger()).isSameAs(logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void setDataSource() throws Exception {
|
|
||||||
XADataSource dataSource = mock(XADataSource.class);
|
|
||||||
XAConnection xaConnection = mock(XAConnection.class);
|
|
||||||
Connection connection = mock(Connection.class);
|
|
||||||
given(dataSource.getXAConnection()).willReturn(xaConnection);
|
|
||||||
given(xaConnection.getConnection()).willReturn(connection);
|
|
||||||
this.bean.setDataSource(dataSource);
|
|
||||||
this.bean.setBeanName("beanName");
|
|
||||||
this.bean.afterPropertiesSet();
|
|
||||||
this.bean.init();
|
|
||||||
this.bean.createPooledConnection(dataSource, this.bean);
|
|
||||||
verify(dataSource).getXAConnection();
|
|
||||||
TransactionManagerServices.getTaskScheduler().shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id "java"
|
|
||||||
id "org.springframework.boot.conventions"
|
|
||||||
}
|
|
||||||
|
|
||||||
description = "Spring Boot Bitronix JTA smoke test"
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-artemis"))
|
|
||||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-jpa"))
|
|
||||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jta-bitronix"))
|
|
||||||
if (JavaVersion.current().java9Compatible) {
|
|
||||||
implementation("jakarta.xml.bind:jakarta.xml.bind-api")
|
|
||||||
}
|
|
||||||
implementation("org.springframework:spring-jms")
|
|
||||||
|
|
||||||
runtimeOnly("com.h2database:h2")
|
|
||||||
runtimeOnly("org.apache.activemq:artemis-jms-server") {
|
|
||||||
exclude group: "org.apache.geronimo.specs", module: "geronimo-jms_2.0_spec"
|
|
||||||
}
|
|
||||||
|
|
||||||
testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package smoketest.bitronix;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
public class Account {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
Account() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Account(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return this.username;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package smoketest.bitronix;
|
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
|
|
||||||
public interface AccountRepository extends JpaRepository<Account, Long> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package smoketest.bitronix;
|
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
|
|
||||||
import org.springframework.jms.core.JmsTemplate;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Transactional
|
|
||||||
public class AccountService {
|
|
||||||
|
|
||||||
private final JmsTemplate jmsTemplate;
|
|
||||||
|
|
||||||
private final AccountRepository accountRepository;
|
|
||||||
|
|
||||||
public AccountService(JmsTemplate jmsTemplate, AccountRepository accountRepository) {
|
|
||||||
this.jmsTemplate = jmsTemplate;
|
|
||||||
this.accountRepository = accountRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createAccountAndNotify(String username) {
|
|
||||||
this.jmsTemplate.convertAndSend("accounts", username);
|
|
||||||
this.accountRepository.save(new Account(username));
|
|
||||||
if ("error".equals(username)) {
|
|
||||||
throw new RuntimeException("Simulated error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package smoketest.bitronix;
|
|
||||||
|
|
||||||
import org.springframework.jms.annotation.JmsListener;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class Messages {
|
|
||||||
|
|
||||||
@JmsListener(destination = "accounts")
|
|
||||||
public void onMessage(String content) {
|
|
||||||
System.out.println("----> " + content);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package smoketest.bitronix;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
|
||||||
public class SampleBitronixApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
ApplicationContext context = SpringApplication.run(SampleBitronixApplication.class, args);
|
|
||||||
AccountService service = context.getBean(AccountService.class);
|
|
||||||
AccountRepository repository = context.getBean(AccountRepository.class);
|
|
||||||
service.createAccountAndNotify("josh");
|
|
||||||
System.out.println("Count is " + repository.count());
|
|
||||||
try {
|
|
||||||
service.createAccountAndNotify("error");
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
}
|
|
||||||
System.out.println("Count is " + repository.count());
|
|
||||||
Thread.sleep(100);
|
|
||||||
((Closeable) context).close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
spring.artemis.embedded.queues=accounts
|
|
||||||
spring.jpa.open-in-view=true
|
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2012-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package smoketest.bitronix;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import bitronix.tm.resource.jms.PoolingConnectionFactory;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.test.system.CapturedOutput;
|
|
||||||
import org.springframework.boot.test.system.OutputCaptureExtension;
|
|
||||||
import org.springframework.context.ApplicationContext;
|
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Basic integration tests for demo application.
|
|
||||||
*
|
|
||||||
* @author Phillip Webb
|
|
||||||
*/
|
|
||||||
@ExtendWith(OutputCaptureExtension.class)
|
|
||||||
class SampleBitronixApplicationTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testTransactionRollback(CapturedOutput output) throws Exception {
|
|
||||||
SampleBitronixApplication.main(new String[] {});
|
|
||||||
assertThat(output).satisfies(numberOfOccurrences("---->", 1));
|
|
||||||
assertThat(output).satisfies(numberOfOccurrences("----> josh", 1));
|
|
||||||
assertThat(output).satisfies(numberOfOccurrences("Count is 1", 2));
|
|
||||||
assertThat(output).satisfies(numberOfOccurrences("Simulated error", 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testExposesXaAndNonXa() {
|
|
||||||
ApplicationContext context = SpringApplication.run(SampleBitronixApplication.class);
|
|
||||||
Object jmsConnectionFactory = context.getBean("jmsConnectionFactory");
|
|
||||||
Object xaJmsConnectionFactory = context.getBean("xaJmsConnectionFactory");
|
|
||||||
Object nonXaJmsConnectionFactory = context.getBean("nonXaJmsConnectionFactory");
|
|
||||||
assertThat(jmsConnectionFactory).isSameAs(xaJmsConnectionFactory);
|
|
||||||
assertThat(jmsConnectionFactory).isInstanceOf(PoolingConnectionFactory.class);
|
|
||||||
assertThat(nonXaJmsConnectionFactory).isNotInstanceOf(PoolingConnectionFactory.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends CharSequence> Consumer<T> numberOfOccurrences(String substring, int expectedCount) {
|
|
||||||
return (charSequence) -> {
|
|
||||||
int count = StringUtils.countOccurrencesOf(charSequence.toString(), substring);
|
|
||||||
assertThat(count).isEqualTo(expectedCount);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue