Skip to content

Commit

Permalink
Merge branch 'master' into feat/metadatatypes-api-support
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkvdVorst authored May 21, 2024
2 parents c9d8976 + ad6faa3 commit 19b6e19
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 73 deletions.
90 changes: 46 additions & 44 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.ibissource</groupId>
<artifactId>ibis-ladybug</artifactId>
<version>2.3-SNAPSHOT</version>
<version>${revision}</version>

<name>Ladybug Test Tool</name>
<description>
Expand All @@ -14,6 +14,7 @@
<url>https://github.com/wearefrank/ladybug</url>

<properties>
<revision>2.3-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>5.3.34</spring.version>
<cxf.version>3.5.5</cxf.version>
Expand Down Expand Up @@ -368,7 +369,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>3.0.1</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
Expand Down Expand Up @@ -531,22 +532,36 @@
</build>
</profile>
<profile>
<id>ossrh</id>
<id>frankframework</id>
<distributionManagement>
<repository>
<id>frankframework</id>
<url>https://nexus.frankframework.org/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>frankframework</id>
<url>https://nexus.frankframework.org/content/repositories/snapshots</url>
</snapshotRepository>
<site>
<id>www.frankframework.org</id>
<url>file:target/site-deploy</url>
</site>
</distributionManagement>
<repositories>
<repository>
<id>frankframework</id>
<url>https://nexus.frankframework.org/content/groups/public</url>
</repository>
</repositories>
</profile>
<profile>
<id>sign</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<version>3.2.4</version>
<configuration>
<passphrase>${gpg.passphrase}</passphrase>
<gpgArguments>
Expand All @@ -557,23 +572,27 @@
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
<tagNameFormat>v@{project.version}</tagNameFormat>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ossrh</id>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand All @@ -593,24 +612,7 @@
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<site>
<id>www.ibissource.org</id>
<url>file:target/site-deploy</url>
</site>
</distributionManagement>
</profile>
<profile>
<id>ibissource</id>
<distributionManagement>
<repository>
<id>ibissource</id>
<url>https://nexus.frankframework.org/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>ibissource</id>
<url>https://nexus.frankframework.org/content/repositories/snapshots</url>
</snapshotRepository>
<site>
<id>www.ibissource.org</id>
<id>www.wearefrank.org</id>
<url>file:target/site-deploy</url>
</site>
</distributionManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.lang.invoke.MethodHandles;

import javax.sql.DataSource;
import javax.sql.XADataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -28,10 +29,10 @@
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionException;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.TransactionSystemException;
import org.springframework.transaction.jta.JtaTransactionManager;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;

import lombok.Getter;
import lombok.Setter;

/**
Expand Down Expand Up @@ -77,59 +78,74 @@
*/
public class OptionalJtaTransactionManager implements PlatformTransactionManager, InitializingBean {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private JtaTransactionManager jtaTransactionManager;
private DataSourceTransactionManager dataSourceTransactionManager;
private PlatformTransactionManager delegate;
/**
* Will be used when a fallback to {@link org.springframework.jdbc.datasource.DataSourceTransactionManager} is
* needed (Java EE servers that provide a transaction manager will automatically link the data source to it as the
* data source is also managed by the Java EE server).
*/
private @Setter DataSource dataSource;
private @Setter @Getter DataSource dataSource;

public OptionalJtaTransactionManager() {
jtaTransactionManager = new JtaTransactionManager();
// Copied from Frank!Framework, seems like a reasonable default
jtaTransactionManager.setTransactionSynchronization(
AbstractPlatformTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION);
delegate = getJtaTransactionManager();
if (delegate != null) {
log.debug("JtaTransactionManager will be used");
} else {
DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager();
delegate = dataSourceTransactionManager;
log.debug("DataSourceTransactionManager will be used");
}
}

@Override
public void afterPropertiesSet() throws TransactionSystemException {
/**
* Make it possible for an application using Ladybug to check whether JtaTransactionManager will be used. For
* example Frank!Framework will configure it's PoolingDataSourceFactory to pool XA data sources only when a JTA
* environment is not available. In a JTA environment the PoolingDataSourceFactory, which is configured to provide
* a {@link DataSource} to Ladybug, should not pool the {@link XADataSource}
*
* @return true when a JTA environment is available
*/
public static boolean isJtaAvailable() {
return getJtaTransactionManager() != null;
}

private static JtaTransactionManager getJtaTransactionManager() {
try {
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
// Copied from Frank!Framework, seems like a reasonable default
jtaTransactionManager.setTransactionSynchronization(
AbstractPlatformTransactionManager.SYNCHRONIZATION_ON_ACTUAL_TRANSACTION);
// Method afterPropertiesSet() will thrown the IllegalStateException, hence call it here (to check whether
// a JTA environment is available) instead of doing it in method afterPropertiesSet() of this class
jtaTransactionManager.afterPropertiesSet();
log.debug("JtaTransactionManager will be used");
return jtaTransactionManager;
} catch(IllegalStateException e) {
log.debug("DataSourceTransactionManager will be used");
dataSourceTransactionManager = new DataSourceTransactionManager();
return null;
}
}

@Override
public void afterPropertiesSet() {
// For JtaTransactionManager method afterPropertiesSet() is called in getJtaTransactionManager()
if (delegate instanceof DataSourceTransactionManager) {
DataSourceTransactionManager dataSourceTransactionManager = ((DataSourceTransactionManager)delegate);
dataSourceTransactionManager.setDataSource(dataSource);
dataSourceTransactionManager.afterPropertiesSet();
}
}

@Override
public final TransactionStatus getTransaction(@Nullable TransactionDefinition definition) throws TransactionException {
if (dataSourceTransactionManager != null) {
return dataSourceTransactionManager.getTransaction(definition);
} else {
return jtaTransactionManager.getTransaction(definition);
}
return delegate.getTransaction(definition);
}

@Override
public void commit(TransactionStatus status) throws TransactionException {
if (dataSourceTransactionManager != null) {
dataSourceTransactionManager.commit(status);
} else {
jtaTransactionManager.commit(status);
}
delegate.commit(status);
}

@Override
public void rollback(TransactionStatus status) throws TransactionException {
if (dataSourceTransactionManager != null) {
dataSourceTransactionManager.rollback(status);
} else {
jtaTransactionManager.rollback(status);
}
delegate.rollback(status);
}
}
}

0 comments on commit 19b6e19

Please sign in to comment.