Skip to content

Commit 3f93807

Browse files
committed
defaults for commit, abort and prepareForAbort
We see a lot of transaction implementations having to override commit and rollback just to honor the API. Same happens for participants that want to be engaged at abort time so they need to implement AbortParticipant, but the prepareForAbort implementation just calls prepare. We now provide default implementations for those.
1 parent 3b593cf commit 3f93807

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

jpos/src/main/java/org/jpos/transaction/AbortParticipant.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface AbortParticipant extends TransactionParticipant {
3434
* @param context transaction context
3535
* @return 0 [| NO_JOIN | READONLY)
3636
*/
37-
int prepareForAbort(long id, Serializable context);
37+
default int prepareForAbort(long id, Serializable context) {
38+
return prepare (id, context);
39+
}
3840
}
39-

jpos/src/main/java/org/jpos/transaction/TransactionParticipant.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public interface TransactionParticipant extends TransactionConstants {
4242
* @param id the Transaction identifier
4343
* @param context transaction context
4444
*/
45-
void commit(long id, Serializable context);
45+
default void commit(long id, Serializable context) { }
4646

4747
/**
4848
* Called by TransactionManager upon transaction commit.
@@ -52,6 +52,5 @@ public interface TransactionParticipant extends TransactionConstants {
5252
* @param id the Transaction identifier
5353
* @param context transaction context
5454
*/
55-
void abort(long id, Serializable context);
55+
default void abort(long id, Serializable context) { }
5656
}
57-

0 commit comments

Comments
 (0)