001 package org.jboss.dna.repository.sequencer;
002
003 import net.jcip.annotations.NotThreadSafe;
004 import org.jboss.dna.graph.ExecutionContext;
005 import org.jboss.dna.graph.Graph;
006 import org.jboss.dna.graph.io.Destination;
007 import org.jboss.dna.graph.io.GraphBatchDestination;
008
009 /**
010 * The sequencer context represents the complete context of a sequencer invocation, including the execution context
011 * (which contains JAAS credentials, namespace mappings, and value factories) and the I/O environment for writing
012 * output.
013 *
014 * <p>
015 * This class is not thread safe due to its use of {@link Destination a destination}.
016 * </p>
017 */
018 @NotThreadSafe
019 public class SequencerContext {
020
021 private final ExecutionContext executionContext;
022 private final Graph graph;
023 private final Destination destination;
024
025 public SequencerContext( ExecutionContext executionContext,
026 Graph graph ) {
027 super();
028
029 assert executionContext != null;
030 assert graph != null;
031
032 this.executionContext = executionContext;
033 this.graph = graph;
034 this.destination = new GraphBatchDestination(graph.batch());
035 }
036
037 /**
038 * Returns the execution context under which this sequencer context operates
039 * @return the execution context under which this sequencer context operates
040 */
041 public ExecutionContext getExecutionContext() {
042 return executionContext;
043 }
044
045 /**
046 * Returns the I/O environment in which this sequencer context operates
047 * @return the I/O environment in which this sequencer context operates
048 */
049 public Destination getDestination() {
050 return destination;
051 }
052
053 Graph graph() {
054 return this.graph;
055 }
056
057 }