View Javadoc

1   package org.modeshape.repository.sequencer;
2   
3   import net.jcip.annotations.NotThreadSafe;
4   import org.modeshape.graph.ExecutionContext;
5   import org.modeshape.graph.Graph;
6   import org.modeshape.graph.io.Destination;
7   import org.modeshape.graph.io.GraphBatchDestination;
8   
9   /**
10   * The sequencer context represents the complete context of a sequencer invocation, including the execution context
11   * (which contains JAAS credentials, namespace mappings, and value factories) and the I/O environment for writing
12   *  output.
13   * 
14   *  <p>
15   *  This class is not thread safe due to its use of {@link Destination a destination}.
16   *  </p>
17   */
18  @NotThreadSafe
19  public class SequencerContext {
20      
21      private final ExecutionContext executionContext;
22      private final Graph graph;
23      private final Destination destination;
24      
25      public SequencerContext( ExecutionContext executionContext,
26                               Graph graph ) {
27          super();
28          
29          assert executionContext != null;
30          assert graph != null;
31          
32          this.executionContext = executionContext;
33          this.graph = graph;
34          this.destination = new GraphBatchDestination(graph.batch());
35      }
36  
37      /**
38       * Returns the execution context under which this sequencer context operates
39       * @return the execution context under which this sequencer context operates
40       */
41      public ExecutionContext getExecutionContext() {
42          return executionContext;
43      }
44  
45      /**
46       * Returns the I/O environment in which this sequencer context operates
47       * @return the I/O environment in which this sequencer context operates
48       */
49      public Destination getDestination() {
50          return destination;
51      }
52      
53      Graph graph() {
54          return this.graph;
55      }
56  
57  }