Package org.apache.commons.scxml2.model

Examples of org.apache.commons.scxml2.model.ModelException


     * @throws ModelException if the state machine hasn't been setup for this instance
     */
    protected void initialize() throws ModelException {
        running = false;
        if (stateMachine == null) {
            throw new ModelException(ERR_NO_STATE_MACHINE);
        }
        if (evaluator == null) {
            throw new ModelException(ERR_NO_EVALUATOR);
        }
        if (errorReporter == null) {
            throw new ModelException(ERR_NO_ERROR_REPORTER);
        }
        systemContext = null;
        globalContext = null;
        contexts.clear();
        histories.clear();
View Full Code Here


     * @param evaluator The evaluator for this state machine instance.
     * @throws ModelException if an attempt is made to set a null value for the evaluator
     */
    protected void setEvaluator(Evaluator evaluator) throws ModelException {
        if (evaluator == null) {
            throw new ModelException(ERR_NO_EVALUATOR);
        }
        if (this.evaluator != null && initialized) {
            this.evaluator = evaluator;
            // change of evaluator after initialization: re-initialize
            initialize();
View Full Code Here

     * @param errorReporter The error reporter for this state machine instance.
     * @throws ModelException if an attempt is made to set a null value for the error reporter
     */
    protected void setErrorReporter(ErrorReporter errorReporter) throws ModelException {
        if (errorReporter == null) {
            throw new ModelException(ERR_NO_ERROR_REPORTER);
        }
        this.errorReporter = errorReporter;
    }
View Full Code Here

     * @param stateMachine The state machine for this instance
     * @throws ModelException if an attempt is made to set a null value for the state machine
     */
    protected void setStateMachine(SCXML stateMachine) throws ModelException {
        if (stateMachine == null) {
            throw new ModelException(ERR_NO_STATE_MACHINE);
        }
        if (this.stateMachine != null && initialized) {
            this.stateMachine = stateMachine;
            // change of state machine after initialization: re-initialize
            initialize();
View Full Code Here

        MessageFormat msgFormat = new MessageFormat(errType);
        String errMsg = msgFormat.format(msgArgs);
        org.apache.commons.logging.Log log = LogFactory.
                getLog(ModelUpdater.class);
        log.error(errMsg);
        throw new ModelException(errMsg);
    }
View Full Code Here

            states.removeAll(step.getExitSet());
            states.addAll(step.getEntrySet());
        }
        // validate the result states represent a legal configuration
        if (!isLegalConfig(states, exctx.getErrorReporter())) {
            throw new ModelException("Illegal state machine configuration!");
        }
    }
View Full Code Here

            if (es.isAtomicState()) {
                if (es instanceof Final) {
                    // Final states don't have transitions, skip to parent
                    if (es.getParent() == null) {
                        // should not happen: a top level active Final state should have stopped the state machine
                        throw new ModelException("Illegal state machine configuration: encountered top level <final> "
                                + "state while processing an event");
                    }
                    else {
                        es = es.getParent();
                    }
View Full Code Here

                    Invoker inv = exctx.getInvoker(entry.getKey());
                    try {
                        inv.parentEvent(event);
                    } catch (InvokerException ie) {
                        exctx.getAppLog().error(ie.getMessage(), ie);
                        throw new ModelException(ie.getMessage(), ie.getCause());
                    }
                }
            }
            /*
            else {
View Full Code Here

        scxml.setInitial(readAV(reader, ATTR_INITIAL));
        scxml.setName(readAV(reader, ATTR_NAME));
        scxml.setProfile(readAV(reader, ATTR_PROFILE));
        scxml.setVersion(readRequiredAV(reader, ELEM_SCXML, ATTR_VERSION));
        if (!SCXML_REQUIRED_VERSION.equals(scxml.getVersion())) {
            throw new ModelException(new MessageFormat(ERR_INVALID_VERSION).format(new Object[] {scxml.getVersion()}));
        }
        readNamespaces(configuration, scxml);

        boolean hasGlobalScript = false;
View Full Code Here

        try {
            externalSCXML = SCXMLReader.readInternal(configuration, new URL(location), null, null, null, null);
        } catch (Exception e) {
            MessageFormat msgFormat = new MessageFormat(ERR_STATE_SRC);
            String errMsg = msgFormat.format(new Object[] {src});
            throw new ModelException(errMsg + " : " + e.getMessage(), e);
        }

        // Pull in the parts of the external document as needed
        if (fragment == null) {
            // All targets pulled in since its not a src fragment
            if (ts instanceof State) {
                State s = (State) ts;
                Initial ini = new Initial();
                SimpleTransition t = new SimpleTransition();
                t.setNext(externalSCXML.getInitial());
                ini.setTransition(t);
                s.setInitial(ini);
                for (EnterableState child : externalSCXML.getChildren()) {
                    s.addChild(child);
                }
                s.setDatamodel(externalSCXML.getDatamodel());
            } else if (ts instanceof Parallel) {
                // TODO src attribute for <parallel>
            }
        } else {
            // Need to pull in only descendent targets
            Object source = externalSCXML.getTargets().get(fragment);
            if (source == null) {
                MessageFormat msgFormat = new MessageFormat(ERR_STATE_SRC_FRAGMENT);
                String errMsg = msgFormat.format(new Object[] {src});
                throw new ModelException(errMsg);
            }
            if (source instanceof State && ts instanceof State) {
                State s = (State) ts;
                State include = (State) source;
                for (OnEntry onentry : include.getOnEntries()) {
                    s.addOnEntry(onentry);
                }
                for (OnExit onexit : include.getOnExits()) {
                    s.addOnExit(onexit);
                }
                s.setDatamodel(include.getDatamodel());
                List<History> histories = include.getHistory();
                for (History h : histories) {
                    s.addHistory(h);
                    configuration.parent.addTarget(h);
                }
                for (EnterableState child : include.getChildren()) {
                    s.addChild(child);
                    configuration.parent.addTarget(child);
                    readInExternalTargets(configuration.parent, child);
                }
                for (Invoke invoke : include.getInvokes()) {
                    s.addInvoke(invoke);
                }
                if (include.getInitial() != null) {
                    s.setInitial(include.getInitial());
                }
                List<Transition> transitions = include.getTransitionsList();
                for (Transition t : transitions) {
                    s.addTransition(t);
                }
            } else if (ts instanceof Parallel && source instanceof Parallel) {
                // TODO src attribute for <parallel>
            } else {
                MessageFormat msgFormat =
                        new MessageFormat(ERR_STATE_SRC_FRAGMENT_TARGET);
                String errMsg = msgFormat.format(new Object[] {src});
                throw new ModelException(errMsg);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.scxml2.model.ModelException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.