-
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.
Defer register XAResourceRecovery after recovery manager service is c…
…reated
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
41 changes: 39 additions & 2 deletions
41
...ana-jta/runtime/src/main/java/io/quarkus/narayana/jta/runtime/QuarkusRecoveryService.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 |
---|---|---|
@@ -1,17 +1,54 @@ | ||
package io.quarkus.narayana.jta.runtime; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jboss.tm.XAResourceRecovery; | ||
|
||
import com.arjuna.ats.jbossatx.jta.RecoveryManagerService; | ||
|
||
public class QuarkusRecoveryService { | ||
public class QuarkusRecoveryService extends RecoveryManagerService { | ||
private static RecoveryManagerService recoveryManagerService; | ||
private List<XAResourceRecovery> xaResources; | ||
private boolean isCreated; | ||
|
||
public static RecoveryManagerService getInstance() { | ||
if (recoveryManagerService == null) { | ||
recoveryManagerService = new RecoveryManagerService(); | ||
recoveryManagerService = new QuarkusRecoveryService(); | ||
} | ||
return recoveryManagerService; | ||
} | ||
|
||
private QuarkusRecoveryService() { | ||
xaResources = new ArrayList<>(); | ||
isCreated = false; | ||
} | ||
|
||
@Override | ||
public void addXAResourceRecovery(XAResourceRecovery xares) { | ||
if (isCreated) { | ||
super.addXAResourceRecovery(xares); | ||
} else { | ||
xaResources.add(xares); | ||
} | ||
} | ||
|
||
@Override | ||
public void removeXAResourceRecovery(XAResourceRecovery xares) { | ||
if (isCreated) { | ||
super.removeXAResourceRecovery(xares); | ||
} else { | ||
xaResources.remove(xares); | ||
} | ||
} | ||
|
||
@Override | ||
public void create() { | ||
super.create(); | ||
isCreated = true; | ||
for (XAResourceRecovery xares : xaResources) { | ||
super.addXAResourceRecovery(xares); | ||
} | ||
xaResources.clear(); | ||
} | ||
} |
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