001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.scxml2;
018
019import org.apache.commons.logging.Log;
020import org.apache.commons.scxml2.model.EnterableState;
021import org.apache.commons.scxml2.model.SCXML;
022
023/**
024 * ActionExecutionContext providing restricted access to the SCXML model, instance and services needed
025 * for the execution of {@link org.apache.commons.scxml2.model.Action} instances
026 */
027public class ActionExecutionContext {
028
029    /**
030     * The SCXML execution context this action exection context belongs to
031     */
032    private final SCXMLExecutionContext exctx;
033
034    /**
035     * Constructor
036     * @param exctx The SCXML execution context this action execution context belongs to
037     */
038    public ActionExecutionContext(SCXMLExecutionContext exctx) {
039        this.exctx = exctx;
040    }
041
042    /**
043     * @return Returns the state machine
044     */
045    public SCXML getStateMachine() {
046        return exctx.getStateMachine();
047    }
048
049    /**
050     * @return Returns the global context
051     */
052    public Context getGlobalContext() {
053        return exctx.getScInstance().getGlobalContext();
054    }
055
056    /**
057     * @return Returns the context for an EnterableState
058     */
059    public Context getContext(EnterableState state) {
060        return exctx.getScInstance().getContext(state);
061    }
062
063    /**
064     * @return Returns The evaluator.
065     */
066    public Evaluator getEvaluator() {
067        return exctx.getEvaluator();
068    }
069
070    /**
071     * @return Returns the error reporter
072     */
073    public ErrorReporter getErrorReporter() {
074        return exctx.getErrorReporter();
075    }
076
077    /**
078     * @return Returns the event dispatcher
079     */
080    public EventDispatcher getEventDispatcher() {
081        return exctx.getEventDispatcher();
082    }
083
084    /**
085     * @return Returns the I/O Processor for the internal event queue
086     */
087    public SCXMLIOProcessor getInternalIOProcessor() {
088        return exctx;
089    }
090
091    /**
092     * @return Returns the SCXML Execution Logger for the application
093     */
094    public Log getAppLog() {
095        return exctx.getAppLog();
096    }
097}