-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22202 from quarkusio/narayana-dont-rollback
Narayana: support @DontRollback on exception type
- Loading branch information
Showing
5 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...narayana-jta/deployment/src/test/java/io/quarkus/narayana/interceptor/AnnotatedError.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.narayana.interceptor; | ||
|
||
import io.quarkus.narayana.jta.Rollback; | ||
|
||
// prevent a rollback to counter the default | ||
@Rollback(false) | ||
public class AnnotatedError extends Error { | ||
} |
8 changes: 8 additions & 0 deletions
8
...-jta/deployment/src/test/java/io/quarkus/narayana/interceptor/AnnotatedTestException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.narayana.interceptor; | ||
|
||
import io.quarkus.narayana.jta.Rollback; | ||
|
||
// force a rollback to counter the default | ||
@Rollback | ||
public class AnnotatedTestException extends Exception { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
extensions/narayana-jta/runtime/src/main/java/io/quarkus/narayana/jta/Rollback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.narayana.jta; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* If you annotate your exception with this annotation, the transactional interceptor will | ||
* use the exception's instructions to force a rollback or not. | ||
* | ||
* FIXME: move to SPI so it can be used by TransactionalReactive | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Inherited | ||
public @interface Rollback { | ||
/** | ||
* Specify whether the annotated exception should cause a rollback or not. Defaults to true. | ||
* | ||
* @return true if the annotated exception should cause a rollback or not. | ||
*/ | ||
boolean value() default true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters