01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package com.tc.objectserver.handler;
06:
07: import com.tc.async.api.AbstractEventHandler;
08: import com.tc.async.api.ConfigurationContext;
09: import com.tc.async.api.EventContext;
10: import com.tc.objectserver.context.CommitTransactionContext;
11: import com.tc.objectserver.core.api.ServerConfigurationContext;
12: import com.tc.objectserver.persistence.api.PersistenceTransactionProvider;
13: import com.tc.objectserver.tx.ServerTransactionManager;
14: import com.tc.objectserver.tx.TransactionalObjectManager;
15:
16: public class CommitTransactionChangeHandler extends
17: AbstractEventHandler {
18:
19: private ServerTransactionManager transactionManager;
20: private final PersistenceTransactionProvider ptxp;
21: private TransactionalObjectManager txnObjectManager;
22:
23: public CommitTransactionChangeHandler(
24: PersistenceTransactionProvider ptxp) {
25: this .ptxp = ptxp;
26: }
27:
28: public void handleEvent(EventContext context) {
29: CommitTransactionContext ctc = (CommitTransactionContext) context;
30: txnObjectManager.commitTransactionsComplete(ctc);
31: if (ctc.isInitialized()) {
32: transactionManager.commit(ptxp, ctc.getObjects(), ctc
33: .getNewRoots(), ctc
34: .getAppliedServerTransactionIDs());
35: }
36: }
37:
38: public void initialize(ConfigurationContext context) {
39: super .initialize(context);
40: ServerConfigurationContext scc = (ServerConfigurationContext) context;
41: this.transactionManager = scc.getTransactionManager();
42: this.txnObjectManager = scc.getTransactionalObjectManager();
43: }
44:
45: }
|