KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > tx > TransactionalStagesCoordinatorImpl


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.objectserver.tx;
6
7 import com.tc.async.api.Sink;
8 import com.tc.async.api.StageManager;
9 import com.tc.objectserver.context.ApplyCompleteEventContext;
10 import com.tc.objectserver.context.ApplyTransactionContext;
11 import com.tc.objectserver.context.CommitTransactionContext;
12 import com.tc.objectserver.context.LookupEventContext;
13 import com.tc.objectserver.context.RecallObjectsContext;
14 import com.tc.objectserver.core.api.ServerConfigurationContext;
15
16 import java.util.Collections JavaDoc;
17
18 public class TransactionalStagesCoordinatorImpl implements TransactionalStageCoordinator {
19
20   private final Sink lookupSink;
21   private final Sink applySink;
22   private final Sink commitSink;
23   private final Sink applyCompleteSink;
24   private final Sink recallSink;
25
26   public TransactionalStagesCoordinatorImpl(StageManager stageManager) {
27     this.lookupSink = stageManager.getStage(ServerConfigurationContext.TRANSACTION_LOOKUP_STAGE).getSink();
28     this.recallSink = stageManager.getStage(ServerConfigurationContext.RECALL_OBJECTS_STAGE).getSink();
29     this.applySink = stageManager.getStage(ServerConfigurationContext.APPLY_CHANGES_STAGE).getSink();
30     this.applyCompleteSink = stageManager.getStage(ServerConfigurationContext.APPLY_COMPLETE_STAGE).getSink();
31     this.commitSink = stageManager.getStage(ServerConfigurationContext.COMMIT_CHANGES_STAGE).getSink();
32   }
33
34   public void addToApplyStage(ApplyTransactionContext context) {
35     applySink.add(context);
36   }
37
38   public void initiateLookup() {
39     lookupSink.addLossy(new LookupEventContext());
40   }
41
42   public void initiateApplyComplete() {
43     applyCompleteSink.addLossy(new ApplyCompleteEventContext());
44   }
45
46   public void initiateCommit() {
47     commitSink.addLossy(new CommitTransactionContext());
48   }
49
50   public void initiateRecallAll() {
51     recallSink.add(new RecallObjectsContext(Collections.EMPTY_LIST, true));
52   }
53
54 }
55
Popular Tags