1 23 24 package com.sun.ejb.containers; 25 26 import java.util.ArrayList ; 27 28 import com.sun.ejb.spi.sfsb.store.SFSBTxStoreManager; 29 30 import com.sun.ejb.base.sfsb.initialization.SFSBTxStoreManagerFactory; 31 32 import com.sun.ejb.base.sfsb.util.EJBServerConfigLookup; 33 34 import com.sun.ejb.spi.sfsb.store.SFSBBeanState; 35 import com.sun.ejb.spi.sfsb.store.SFSBStoreManagerException; 36 37 import java.util.logging.*; 38 import com.sun.logging.*; 39 40 45 public class SFSBTxCheckpointCoordinator { 46 47 private static Logger _logger = 48 LogDomains.getLogger(LogDomains.EJB_LOGGER); 49 50 private static String _haStoreType; 51 static { 52 EJBServerConfigLookup ejbConfigLookup = new EJBServerConfigLookup(); 53 _haStoreType = ejbConfigLookup.getSfsbHaPersistenceTypeFromConfig(); 54 } 55 56 private ArrayList ctxList = new ArrayList (); 57 58 SFSBTxCheckpointCoordinator() { 59 } 60 61 void registerContext(SessionContextImpl ctx) { 62 ctxList.add(ctx); 63 } 64 65 void doTxCheckpoint() { 66 SessionContextImpl[] contexts = (SessionContextImpl[]) ctxList.toArray( 67 new SessionContextImpl[0]); 68 int size = contexts.length; 69 ArrayList states = new ArrayList (size); 70 71 for (int i=0; i<size; i++) { 72 SessionContextImpl ctx = contexts[i]; 73 StatefulSessionContainer container = 74 (StatefulSessionContainer) ctx.getContainer(); 75 SFSBBeanState beanState = container.getSFSBBeanState(ctx); 76 if (beanState != null) { 77 states.add(beanState); 78 } 79 } 80 81 if (states.size () > 0) { 82 SFSBBeanState[] beanStates = (SFSBBeanState[]) states.toArray( 83 new SFSBBeanState[0]); 84 85 try { 86 SFSBTxStoreManager txStoreManager = SFSBTxStoreManagerFactory. 87 createSFSBTxStoreManager(_haStoreType); 88 txStoreManager.checkpointSave(beanStates); 89 } catch (SFSBStoreManagerException sfsbEx) { 90 _logger.log(Level.WARNING, "Exception during checkpointSave", 91 sfsbEx); 92 } catch (Throwable th) { 93 _logger.log(Level.WARNING, "Exception during checkpointSave", 94 th); 95 } 96 } 97 98 for (int i=0; i<size; i++) { 99 SessionContextImpl ctx = contexts[i]; 100 StatefulSessionContainer container = 101 (StatefulSessionContainer) ctx.getContainer(); 102 container.txCheckpointCompleted(ctx); 103 } 104 } 105 106 } 107 | Popular Tags |