FileDocCategorySizeDatePackage
SFSBTxCheckpointCoordinator.javaAPI DocGlassfish v2 API4217Fri May 04 22:32:58 BST 2007com.sun.ejb.containers

SFSBTxCheckpointCoordinator

public class SFSBTxCheckpointCoordinator extends Object
A class to checkpoint HA enabled SFSBs as a single transactional unit.
author
Mahesh Kannan

Fields Summary
private static final Logger
_logger
private static String
_haStoreType
private ArrayList
ctxList
Constructors Summary
SFSBTxCheckpointCoordinator()


     
    
Methods Summary
voiddoTxCheckpoint()

	SessionContextImpl[] contexts = (SessionContextImpl[]) ctxList.toArray(
		new SessionContextImpl[0]);
	int size = contexts.length;
	ArrayList states = new ArrayList(size);

	for (int i=0; i<size; i++) {
	    SessionContextImpl ctx = contexts[i];
	    StatefulSessionContainer container =
		(StatefulSessionContainer) ctx.getContainer();
	    SFSBBeanState beanState = container.getSFSBBeanState(ctx);
	    if (beanState != null) {
		states.add(beanState);
	    }
	}

	if (states.size () > 0) {
	    SFSBBeanState[] beanStates = (SFSBBeanState[]) states.toArray(
		new SFSBBeanState[0]);

	    try {
		SFSBTxStoreManager txStoreManager = SFSBTxStoreManagerFactory.
		    createSFSBTxStoreManager(_haStoreType);
		txStoreManager.checkpointSave(beanStates);
	    } catch (SFSBStoreManagerException sfsbEx) {
		_logger.log(Level.WARNING, "Exception during checkpointSave",
			sfsbEx);
	    } catch (Throwable th) {
		_logger.log(Level.WARNING, "Exception during checkpointSave",
			th);
	    }
	}

	for (int i=0; i<size; i++) {
	    SessionContextImpl ctx = contexts[i];
	    StatefulSessionContainer container =
		(StatefulSessionContainer) ctx.getContainer();
	    container.txCheckpointCompleted(ctx);
	}
    
voidregisterContext(SessionContextImpl ctx)

	ctxList.add(ctx);