public class SpringUtils extends Object
Provides utility methods related to Spring.
Modifier and Type | Method and Description |
---|---|
static String |
getResourceName(org.springframework.core.io.Resource resource)
Returns a name that represents the resource.
|
static String |
getResourceName(org.springframework.core.io.Resource resource,
boolean truncate)
Returns an optionally truncated name that represents the resource.
|
static void |
runAfterFailedTransaction(Callable<Void> operation)
Runs the given callable after the transaction has been committed unsuccessfully.
|
static void |
runAfterSuccessfulTransaction(Callable<Void> operation)
Runs the given callable after the transaction has been committed successfully.
|
static <T> T |
runInTransaction(org.springframework.transaction.PlatformTransactionManager transactionManager,
Callable<T> callable)
Runs the given callable in the current transaction, creating a new transaction if necessary.
|
static void |
runInTransaction(org.springframework.transaction.PlatformTransactionManager transactionManager,
Runnable runnable)
Runs the given runnable in the current transaction, creating a new transaction if necessary.
|
public static String getResourceName(org.springframework.core.io.Resource resource)
Returns a name that represents the resource.
resource
- the resource for which to get a namepublic static String getResourceName(org.springframework.core.io.Resource resource, boolean truncate)
Returns an optionally truncated name that represents the resource.
resource
- the resource for which to get a nametruncate
- <i>true</i> if the resource name should be truncated in case the resource has a path availablepublic static void runAfterSuccessfulTransaction(Callable<Void> operation)
Runs the given callable after the transaction has been committed successfully.
operation
- the operation to invoke after the successful transactionpublic static void runAfterFailedTransaction(Callable<Void> operation)
Runs the given callable after the transaction has been committed unsuccessfully.
operation
- the operation to invoke after the unsuccessful transactionpublic static <T> T runInTransaction(org.springframework.transaction.PlatformTransactionManager transactionManager, Callable<T> callable)
Runs the given callable in the current transaction, creating a new transaction if necessary.
T
- the callable return typetransactionManager
- the platform transaction managercallable
- the Callable to be executedRuntimeException
- if the Callable threw an exceptionpublic static void runInTransaction(org.springframework.transaction.PlatformTransactionManager transactionManager, Runnable runnable)
Runs the given runnable in the current transaction, creating a new transaction if necessary.
transactionManager
- the platform transaction managerrunnable
- the Runnable to be executedRuntimeException
- if the Runnable threw an exceptionCopyright © 2010 - 2019 edorasware ag. All Rights Reserved.