View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.scxml2;
18  
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.scxml2.model.EnterableState;
21  import org.apache.commons.scxml2.model.SCXML;
22  
23  /**
24   * ActionExecutionContext providing restricted access to the SCXML model, instance and services needed
25   * for the execution of {@link org.apache.commons.scxml2.model.Action} instances
26   */
27  public class ActionExecutionContext {
28  
29      /**
30       * The SCXML execution context this action exection context belongs to
31       */
32      private final SCXMLExecutionContext exctx;
33  
34      /**
35       * Constructor
36       * @param exctx The SCXML execution context this action execution context belongs to
37       */
38      public ActionExecutionContext(SCXMLExecutionContext exctx) {
39          this.exctx = exctx;
40      }
41  
42      /**
43       * @return Returns the state machine
44       */
45      public SCXML getStateMachine() {
46          return exctx.getStateMachine();
47      }
48  
49      /**
50       * @return Returns the global context
51       */
52      public Context getGlobalContext() {
53          return exctx.getScInstance().getGlobalContext();
54      }
55  
56      /**
57       * @return Returns the context for an EnterableState
58       */
59      public Context getContext(EnterableState state) {
60          return exctx.getScInstance().getContext(state);
61      }
62  
63      /**
64       * @return Returns The evaluator.
65       */
66      public Evaluator getEvaluator() {
67          return exctx.getEvaluator();
68      }
69  
70      /**
71       * @return Returns the error reporter
72       */
73      public ErrorReporter getErrorReporter() {
74          return exctx.getErrorReporter();
75      }
76  
77      /**
78       * @return Returns the event dispatcher
79       */
80      public EventDispatcher getEventDispatcher() {
81          return exctx.getEventDispatcher();
82      }
83  
84      /**
85       * @return Returns the I/O Processor for the internal event queue
86       */
87      public SCXMLIOProcessor getInternalIOProcessor() {
88          return exctx;
89      }
90  
91      /**
92       * @return Returns the SCXML Execution Logger for the application
93       */
94      public Log getAppLog() {
95          return exctx.getAppLog();
96      }
97  }