Package org.apache.commons.scxml.model

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


        return getExecutor(context, evaluator, scxml, ed, trc);
    }

    public static SCXMLExecutor getExecutor(final URL url, final Context ctx,
            final Evaluator evaluator) {
        SCXML scxml = digest(url);
        EventDispatcher ed = new SimpleDispatcher();
        Tracer trc = new Tracer();
        return getExecutor(ctx, evaluator, scxml, ed, trc);
    }
View Full Code Here


            System.err.println("SKIPPED SERIALIZATION: Failed directory creation");
            return scxml;
        }
        String filename = SERIALIZATION_FILE_PREFIX
            + System.currentTimeMillis() + SERIALIZATION_FILE_SUFFIX;
        SCXML roundtrip = null;
        try {
            ObjectOutputStream out =
                new ObjectOutputStream(new FileOutputStream(filename));
            out.writeObject(scxml);
            out.close();
View Full Code Here

            fail(e.getMessage());
        }
    }

    public void testEventdata04Sample() throws InterruptedException {
        SCXML scxml = SCXMLTestHelper.parse(eventdata04);
        Tracer trc = new Tracer();
        try {
            exec = new SCXMLExecutor(new JexlEvaluator(), null, trc);
            exec.setEventdispatcher(new SimpleScheduler(exec));
            exec.addListener(scxml, trc);
View Full Code Here

        String[] testCaseName = { SCXMLSerializerTest.class.getName()};
        junit.textui.TestRunner.main(testCaseName);
    }
   
    public void testSerializeSCXMLNoStates() {
        SCXML scxml = new SCXML();
        Map namespaces = new LinkedHashMap();
        namespaces.put("", "http://www.w3.org/2005/07/scxml");
        namespaces.put("cs", "http://commons.apache.org/scxml");
        namespaces.put("foo", "http://f.o.o");
        namespaces.put("bar", "http://b.a.r");
        scxml.setNamespaces(namespaces);
        scxml.setVersion("version1");
        scxml.setInitial("off");
        scxml.addChild(new State());
       
        String assertValue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<scxml xmlns=\"http://www.w3.org/2005/07/scxml\" xmlns:cs=\"http://commons.apache.org/scxml\" "
            + "xmlns:foo=\"http://f.o.o\" xmlns:bar=\"http://b.a.r\" "
            + "version=\"version1\" initial=\"off\">\n <!-- http://commons.apache.org/scxml -->\n <state>\n "
View Full Code Here

        assertEquals(actualValue, returnValue.toString());
    }

    public void testSerializeSCXMLState() {
        SCXML scxml = new SCXML();
        scxml.setVersion("1.0");
        scxml.setInitial("S1");

        State s1 = new State();
        s1.setId("S1");

        scxml.addChild(s1);

        String assertValue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<scxml xmlns=\"http://www.w3.org/2005/07/scxml\" "
            + "version=\"1.0\" initial=\"S1\">\n <!-- http://commons.apache.org/scxml -->\n"
            + " <state id=\"S1\">\n </state>\n</scxml>\n";
View Full Code Here

        assertEquals(assertValue, SCXMLSerializer.serialize(scxml));
    }

    public void testSerializeParallel() {

        SCXML scxml = new SCXML();
        scxml.setVersion("1.0");
        scxml.setInitial("par");

        Parallel par = new Parallel();
        par.setId("par");

        State s1 = new State();
        s1.setId("S1");

        State s11 = new State();
        s11.setId("S11");

        s1.addChild((TransitionTarget)s11);

        State s2 = new State();
        s2.setId("S2");

        State s21 = new State();
        s21.setId("S21");

        s2.addChild((TransitionTarget)s21);

        par.addChild((TransitionTarget)s1);
        par.addChild((TransitionTarget)s2);

        scxml.addChild(par);

        String assertValue = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
            + "<scxml xmlns=\"http://www.w3.org/2005/07/scxml\" "
            + "version=\"1.0\" initial=\"par\">\n"
            + " <!-- http://commons.apache.org/scxml -->\n"
View Full Code Here

     */
    public static SCXML digest(final URL scxmlURL,
            final ErrorHandler errHandler, final List customActions)
    throws IOException, SAXException, ModelException {

        SCXML scxml = null;
        Digester scxmlDigester = SCXMLDigester
                .newInstance(null, new URLResolver(scxmlURL), customActions);
        scxmlDigester.setErrorHandler(errHandler);

        try {
View Full Code Here

        if (documentRealPath == null) {
            throw new IllegalArgumentException(ERR_NULL_PATH);
        }

        SCXML scxml = null;
        Digester scxmlDigester = SCXMLDigester.newInstance(null, pathResolver,
            customActions);
        scxmlDigester.setErrorHandler(errHandler);

        try {
View Full Code Here

        Digester scxmlDigester = SCXMLDigester.newInstance(null, null,
            customActions);
        scxmlDigester.setErrorHandler(errHandler);

        SCXML scxml = null;
        try {
            scxml = (SCXML) scxmlDigester.parse(documentInputSource);
        catch (RuntimeException rte) {
            // Intercept runtime exceptions, only to log them with a
            // sensible error message about failure in document parsing
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;
                externalSrcDigester = newInstance(scxml, null, customActions);
            } else {
                path = pr.resolvePath(src);
                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

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.