Package org.apache.commons.scxml.model

Examples of org.apache.commons.scxml.model.SCXML


            String src = attributes.getValue("src");
            if (SCXMLHelper.isStringEmpty(src)) {
                return;
            }
            Digester digester = getDigester();
            SCXML scxml = (SCXML) digester.peek(digester.getCount() - 1);
            // 1) Digest the external SCXML file
            SCXML externalSCXML = null;
            String path;
            Digester externalSrcDigester;
            if (pr == null) {
                path = src;
                if (root != null) {
                    externalSrcDigester = newInstance(root, null,
                        customActions);
                } else {
                    externalSrcDigester = newInstance(scxml, null,
                        customActions);
                }
            } else {
                path = pr.resolvePath(src);
                if (root != null) {
                    externalSrcDigester = newInstance(root,
                        pr.getResolver(src), customActions);
                } else {
                    externalSrcDigester = newInstance(scxml,
                        pr.getResolver(src), customActions);
                }
            }

            try {
                externalSCXML = (SCXML) externalSrcDigester.parse(path);
            } catch (Exception e) {
                org.apache.commons.logging.Log log = LogFactory.
                    getLog(SCXMLParser.class);
                log.error(e.getMessage(), e);
            }
            // 2) Adopt the children and datamodel
            if (externalSCXML == null) {
                return;
            }
            State s = (State) digester.peek();
            Transition t = new Transition();
            t.setNext(externalSCXML.getInitialstate());
            Initial ini = new Initial();
            ini.setTransition(t);
            s.setInitial(ini);
            Map children = externalSCXML.getChildren();
            Object[] ids = children.keySet().toArray();
            for (int i = 0; i < ids.length; i++) {
                s.addChild((TransitionTarget) children.get(ids[i]));
            }
            s.setDatamodel(externalSCXML.getDatamodel());
        }
View Full Code Here


            String src = attributes.getValue("src");
            if (SCXMLHelper.isStringEmpty(src)) {
                return;
            }
            Digester digester = getDigester();
            SCXML scxml = (SCXML) digester.peek(digester.getCount() - 1);
            // 1) Digest the external SCXML file
            SCXML externalSCXML = null;
            String path;
            Digester externalSrcDigester;
            if (pr == null) {
                path = src;
                if (root != null) {
                    externalSrcDigester = newInstance(root, null,
                        customActions);
                } else {
                    externalSrcDigester = newInstance(scxml, null,
                        customActions);
                }
            } else {
                path = pr.resolvePath(src);
                if (root != null) {
                    externalSrcDigester = newInstance(root,
                        pr.getResolver(src), customActions);
                } else {
                    externalSrcDigester = newInstance(scxml,
                        pr.getResolver(src), customActions);
                }
            }

            try {
                externalSCXML = (SCXML) externalSrcDigester.parse(path);
            } catch (Exception e) {
                org.apache.commons.logging.Log log = LogFactory.
                    getLog(SCXMLDigester.class);
                log.error(e.getMessage(), e);
            }
            // 2) Adopt the children and datamodel
            if (externalSCXML == null) {
                return;
            }
            State s = (State) digester.peek();
            Transition t = new Transition();
            t.setNext(externalSCXML.getInitialstate());
            Initial ini = new Initial();
            ini.setTransition(t);
            s.setInitial(ini);
            Map children = externalSCXML.getStates();
            Object[] ids = children.keySet().toArray();
            for (int i = 0; i < ids.length; i++) {
                s.addChild((State) children.get(ids[i]));
            }
            s.setDatamodel(externalSCXML.getDatamodel());
        }
View Full Code Here

        String[] testCaseName = { SCXMLSerializerTest.class.getName()};
        junit.textui.TestRunner.main(testCaseName);
    }
   
    public void testSerializeSCXMLNoStates() {
        SCXML scxml = new SCXML();
        scxml.setXmlns("namespace");
        scxml.setVersion("version1");
        scxml.setInitialstate("off");
        scxml.addChild(new State());
       
        String assertValue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<scxml xmlns=\"namespace\" version=\"version1\" "
            + "initialstate=\"off\">\n <state>\n </state>\n</scxml>\n";
       
View Full Code Here

        checkMicrowave02Sample();
    }

    // Uses SCXMLParser (latest WD)
    public void testSCXMLExecutorMicrowave03JexlSample() {
        SCXML scxml = SCXMLTestHelper.parse(microwave03jexl);
        assertNotNull(scxml);
        exec = SCXMLTestHelper.getExecutor(scxml);
        assertNotNull(exec);
        checkMicrowave01Sample();
    }
View Full Code Here

        checkMicrowave01Sample();
    }

    // Uses SCXMLParser (latest WD)
    public void testSCXMLExecutorMicrowave04JexlSample() {
        SCXML scxml = SCXMLTestHelper.parse(microwave04jexl);
        assertNotNull(scxml);
        exec = SCXMLTestHelper.getExecutor(scxml);
        assertNotNull(exec);
        checkMicrowave02Sample();
    }
View Full Code Here

        }
    }

    // Uses SCXMLParser (latest WD)
    public void testSCXMLExecutorTransitions04Sample() {
        SCXML scxml = SCXMLTestHelper.parse(transitions04);
        assertNotNull(scxml);
        exec = SCXMLTestHelper.getExecutor(scxml);
        assertNotNull(exec);
        try {
            Set currentStates = SCXMLTestHelper.fireEvent(exec, "ten.done");
View Full Code Here

    public static SCXML digest(final URL url, final ErrorHandler errHandler,
            final List customActions) {
        Assert.assertNotNull(url);
        // SAX ErrorHandler may be null
        SCXML scxml = null;
        try {
            scxml = SCXMLDigester.digest(url, errHandler, customActions);
        } catch (Exception e) {
            Log log = LogFactory.getLog(SCXMLTestHelper.class);
            log.error(e.getMessage(), e);
            Assert.fail(e.getMessage());
        }
        Assert.assertNotNull(scxml);
        SCXML roundtrip = testModelSerializability(scxml);
        Assert.assertNotNull(roundtrip);
        return roundtrip;
    }
View Full Code Here

    public static SCXML parse(final URL url, final ErrorHandler errHandler,
            final List customActions) {
        Assert.assertNotNull(url);
        // SAX ErrorHandler may be null
        SCXML scxml = null;
        try {
            scxml = SCXMLParser.parse(url, errHandler, customActions);
        } catch (Exception e) {
            Log log = LogFactory.getLog(SCXMLTestHelper.class);
            log.error(e.getMessage(), e);
            Assert.fail(e.getMessage());
        }
        Assert.assertNotNull(scxml);
        SCXML roundtrip = testModelSerializability(scxml);
        return roundtrip;
    }
View Full Code Here

        SCXML roundtrip = testModelSerializability(scxml);
        return roundtrip;
    }

    public static SCXMLExecutor getExecutor(final URL url) {
        SCXML scxml = digest(url);
        Evaluator evaluator = new JexlEvaluator();
        return getExecutor(evaluator, scxml);
    }
View Full Code Here

        return getExecutor(evaluator, scxml);
    }

    public static SCXMLExecutor getExecutor(final URL url,
            final Evaluator evaluator) {
        SCXML scxml = digest(url);
        return getExecutor(evaluator, scxml);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.scxml.model.SCXML

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.