Coder Social home page Coder Social logo

legian's Introduction

Legian

An SCXML parser and executor built in Java using Rhino to execute Javascript code. It is not fully compliant to the W3C specs, but it supports some addional features that I'm extensively using in my production code.

In src/test you will find some sample SCXMLs file and a SampleConsole.java that demonstrates how to use the engine.

The following code creates an instance of the SCXML engine and register and event handler:

StateChartModel stateChartModel = new SCXMLBuilder().build(new File(args[0]));
ScriptExecutor scriptExecutor = new RhinoScriptExecutor();
scriptExecutor.addToGlobalContext("out", System.out);
StateChartExecutor stateChartExecutor = new StateChartExecutor(stateChartModel, scriptExecutor);
StateChartInstance stateChartInstance = stateChartExecutor.createInstance(null);
stateChartInstance.getListeners().add(new StateChartEventListener() {
    @Override
    public void eventTriggered(Event e) {
        System.out.println("EVENT -> " + e.toString());
        System.out.flush();
    }
});
stateChartInstance.initialize(null);

Whenever you need to send a message to the state chart just use stateChartInstance.send()

##Features

  • All the following tags are supported: <assign>, <if>, <elseif>, <else>, <onentry>, <onexit>, <log>, <script>, <state>, <initial>, <final>, <scxml>, <transition>. Not all parameters are supported for all events. To check which params are supported look into the src/builder folder.

  • Support for custom tag libraries: It is veary easy to add custom tag libraries implemented in javascript. An example is provided in the sample code. The custom library can be included using the <taglib> custom tag.

  • Support for scxml includes: It is possible to include an SCXML file into a state of another SCXML file. An example is included in the sample code. In order to include an SCXML file use th <include> custom tag.

If you are interested in extending the functionalities to fully support the W3C specs, please let me know. The code is quite stable and has been used in production running an IVR system handling 300+ concurrent calls.

legian's People

Contributors

snork-alt avatar

Stargazers

Pink Bobsledder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.