use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.
the class ResourceRecoveryManagerImpl method getAllRecoverableResources.
/**
* get all recoverable resources
* @param xaresList xa resources
* @return recovery-handlers and their resources
*/
private Map<RecoveryResourceHandler, Vector> getAllRecoverableResources(Vector xaresList) {
Map<RecoveryResourceHandler, Vector> resourcesToHandlers = new HashMap<RecoveryResourceHandler, Vector>();
for (RecoveryResourceHandler handler : recoveryResourceHandlers) {
// TODO V3 FINE LOG
Vector resources = new Vector();
handler.loadXAResourcesAndItsConnections(xaresList, resources);
resourcesToHandlers.put(handler, resources);
}
return resourcesToHandlers;
}
use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.
the class ResourceRecoveryManagerImpl method registerRecoveryResourceHandler.
public static void registerRecoveryResourceHandler(final XAResource xaResource) {
RecoveryResourceHandler recoveryResourceHandler = new RecoveryResourceHandler() {
public void loadXAResourcesAndItsConnections(List xaresList, List connList) {
xaresList.add(xaResource);
}
public void closeConnections(List connList) {
;
}
};
externallyRegisteredRecoveryResourceHandlers.add(recoveryResourceHandler);
}
use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.
the class ResourceRecoveryManagerImpl method recoverXAResources.
/**
* recover the xa-resources
* @param force boolean to indicate if it has to be forced.
*/
public void recoverXAResources(boolean force) {
if (force) {
try {
if (txnService == null) {
Config c = habitat.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
txnService = c.getExtensionByType(TransactionService.class);
}
if (!Boolean.valueOf(txnService.getAutomaticRecovery())) {
return;
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "ejbserver.recovery", "Perform recovery of XAResources...");
}
configure();
Vector xaresList = new Vector();
Map<RecoveryResourceHandler, Vector> resourcesToHandler = getAllRecoverableResources(xaresList);
int size = xaresList.size();
XAResource[] xaresArray = new XAResource[size];
for (int i = 0; i < size; i++) {
xaresArray[i] = (XAResource) xaresList.elementAt(i);
}
resourceRecoveryStarted();
if (_logger.isLoggable(Level.FINE)) {
String msg = localStrings.getStringWithDefault("xaresource.recovering", "Recovering {0} XA resources...", new Object[] { String.valueOf(size) });
_logger.log(Level.FINE, msg);
}
txMgr.recover(xaresArray);
resourceRecoveryCompleted();
closeAllResources(resourcesToHandler);
} catch (Exception ex) {
_logger.log(Level.SEVERE, "xaresource.recover_error", ex);
}
}
}
use of com.sun.enterprise.transaction.spi.RecoveryResourceHandler in project Payara by payara.
the class ResourceRecoveryManagerImpl method closeAllResources.
/**
* close all resources provided using their handlers
* @param resourcesToHandlers map that holds handlers and their resources
*/
private void closeAllResources(Map<RecoveryResourceHandler, Vector> resourcesToHandlers) {
if (resourcesToHandlers != null) {
Set<Map.Entry<RecoveryResourceHandler, Vector>> entries = resourcesToHandlers.entrySet();
for (Map.Entry<RecoveryResourceHandler, Vector> entry : entries) {
RecoveryResourceHandler handler = entry.getKey();
Vector resources = entry.getValue();
handler.closeConnections(resources);
}
}
}
Aggregations