diff options
Diffstat (limited to 'contrib/java/bindings')
11 files changed, 11 insertions, 162 deletions
diff --git a/contrib/java/bindings/build.properties b/contrib/java/bindings/build.properties index dd0fe62..9d23ea4 100644 --- a/contrib/java/bindings/build.properties +++ b/contrib/java/bindings/build.properties @@ -5,5 +5,5 @@ uscxml.library.path=/usr/local/share/uscxml/bindings/java uscxml.jar=/usr/local/share/uscxml/bindings/uscxml.jar -jexl.jar=libs/commons-jexl3-3.0.jar -logging.jar=libs/commons-logging-1.2.jar
\ No newline at end of file +jexl.jar=../libs/commons-jexl3-3.0.jar +logging.jar=../libs/commons-logging-1.2.jar
\ No newline at end of file diff --git a/contrib/java/bindings/build.xml b/contrib/java/bindings/build.xml index 19d7817..d5c6db7 100644 --- a/contrib/java/bindings/build.xml +++ b/contrib/java/bindings/build.xml @@ -4,6 +4,7 @@ <property file="build.properties" />
<property name="src" value="." />
+ <property name="common" value="../common" />
<property name="bin" value="bin" />
<!-- <property name="test.file" value="..." /> -->
@@ -21,6 +22,7 @@ <javac destdir="${bin}" debuglevel="lines,vars,source" debug="on"
encoding="utf-8" includeantruntime="false">
<src path="${src}" />
+ <src path="${common}" />
<classpath>
<pathelement location="${real.uscxml.jar}" />
<pathelement location="${jexl.jar}" />
diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Context.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Context.java deleted file mode 100644 index a0208c9..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Context.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -import org.uscxml.DataModel; - -public class Context { - public DataModel dm = null; -} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Evaluator.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Evaluator.java deleted file mode 100644 index 5bd5642..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/Evaluator.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -public abstract class Evaluator { - - public abstract Context newContext(Object object); - -} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/JexlEvaluator.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/JexlEvaluator.java deleted file mode 100644 index 127bed3..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/JexlEvaluator.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -import org.uscxml.Factory; -import org.uscxml.dm.jexl.JexlDataModel; - -public class JexlEvaluator extends Evaluator { - - public JexlEvaluator() { - - } - - @Override - public Context newContext(Object object) { - // TODO Auto-generated method stub - Context ctx = new Context(); - ctx.dm = new JexlDataModel(); - return ctx; - } -} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXML.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXML.java deleted file mode 100644 index 67e5b1f..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXML.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -import java.net.URL; - -public class SCXML { - public URL url = null; - -} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLExecutor.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLExecutor.java deleted file mode 100644 index 704e897..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLExecutor.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -import java.net.URL; - -import org.uscxml.ActionLanguage; -import org.uscxml.Factory; -import org.uscxml.Interpreter; -import org.uscxml.InterpreterException; -import org.uscxml.InterpreterState; -import org.uscxml.helper.TestMonitor; - -public class SCXMLExecutor { - - public Interpreter interpreter = null; - public URL sourceURL = null; - public ActionLanguage al = new ActionLanguage(); - - public SCXMLExecutor(Evaluator evaluator, Object object, SimpleErrorReporter simpleErrorReporter) { - // TODO Auto-generated constructor stub - } - - public void setStateMachine(SCXML scxml) { - sourceURL = scxml.url; - } - - public void setRootContext(Context rootContext) { - al.setDataModel(rootContext.dm); - } - - public void go() { - try { - interpreter = Interpreter.fromURL(sourceURL.toString()); - interpreter.setActionLanguage(al); - - TestMonitor tm = new TestMonitor(); - interpreter.addMonitor(tm); - - InterpreterState state = InterpreterState.USCXML_UNDEF; - while(state != InterpreterState.USCXML_FINISHED) { - interpreter.step(); - } - - } catch (InterpreterException e) { - e.printStackTrace(); - } - - } - -} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLReader.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLReader.java deleted file mode 100644 index 45c2a54..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SCXMLReader.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -import java.net.URL; - -public class SCXMLReader { - - public static SCXML read(URL scxml) { - SCXML foo = new SCXML(); - foo.url = scxml; - return foo; - } - -} diff --git a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SimpleErrorReporter.java b/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SimpleErrorReporter.java deleted file mode 100644 index 06187f8..0000000 --- a/contrib/java/bindings/org/uscxml/apache/commons/scxml2/SimpleErrorReporter.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.uscxml.apache.commons.scxml2; - -public class SimpleErrorReporter { - -} diff --git a/contrib/java/bindings/org/uscxml/examples/ApacheCommonsAPI.java b/contrib/java/bindings/org/uscxml/examples/ApacheCommonsAPI.java deleted file mode 100644 index 4cf3de4..0000000 --- a/contrib/java/bindings/org/uscxml/examples/ApacheCommonsAPI.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.uscxml.examples; - -import java.net.URL; - -//import org.uscxml.apache.commons.scxml2.*; -import org.apache.commons.scxml2.*; -import org.apache.commons.scxml2.env.SimpleErrorReporter; -import org.apache.commons.scxml2.env.jexl.JexlEvaluator; -import org.apache.commons.scxml2.io.SCXMLReader; -import org.apache.commons.scxml2.model.SCXML; - -public class ApacheCommonsAPI { - - // SCXML model source URL - private static final URL SCXML = ApacheCommonsAPI.class.getResource("hello-world.xml"); - - public static void main(String [] args) throws Exception { - String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; - if (System.getenv().containsKey("USCXML_JAVA_LIB")) { - uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); - } - - System.load(uSCXMLLibPath); - - - // evaluator instance which is used by SCXML engine to evaluate expressions in SCXML - Evaluator evaluator = new JexlEvaluator(); - // engine to execute the scxml instance - SCXMLExecutor executor = new SCXMLExecutor(evaluator, null, new SimpleErrorReporter()); - - // parse SCXML URL into SCXML model - SCXML scxml = SCXMLReader.read(SCXML); - // set state machine (scxml instance) to execute - executor.setStateMachine(scxml); - - // create root context storing variables and being used by evaluator - Context rootContext = evaluator.newContext(null); - // set the root context for the engine - executor.setRootContext(rootContext); - - // initiate the execution of the state machine - executor.go(); - } - -} diff --git a/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java b/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java index da79d37..3db5b29 100644 --- a/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java +++ b/contrib/java/bindings/org/uscxml/tests/JexlDataModelTest.java @@ -14,14 +14,14 @@ import org.uscxml.helper.TestMonitor; public class JexlDataModelTest { - public static void main(String[] args) { + public static void main(String[] args) throws MalformedURLException { String uSCXMLLibPath = "/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava.jnilib"; if (System.getenv().containsKey("USCXML_JAVA_LIB")) { uSCXMLLibPath = System.getenv("USCXML_JAVA_LIB"); } System.load(uSCXMLLibPath); -// String testUri = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/jexl/test144.scxml"; + String testUri = "/Users/sradomski/Documents/TK/Code/uscxml/test/w3c/jexl/test144.scxml"; // String testUri = "/Users/sradomski/Desktop/stopwatch.xml"; @@ -31,20 +31,20 @@ public class JexlDataModelTest { { JexlDataModel jdm = new JexlDataModel(); -// Factory.getInstance().registerDataModel(jdm); + //Factory.getInstance().registerDataModel(jdm); TestMonitor tm = new TestMonitor(); try { -// File testFile = new File(testUri); -// String testName = testFile.toURI().toURL().toString(); - String testName = "https://raw.githubusercontent.com/woonsan/commons-scxml-examples/master/stopwatch/src/main/resources/com/github/woonsan/commons/scxml/examples/stopwatch/stopwatch.xml"; + File testFile = new File(testUri); + String testName = testFile.toURI().toURL().toString(); +// String testName = "https://raw.githubusercontent.com/woonsan/commons-scxml-examples/master/stopwatch/src/main/resources/com/github/woonsan/commons/scxml/examples/stopwatch/stopwatch.xml"; System.out.println(testName); Interpreter scxml = Interpreter.fromURL(testName); - jdm.ctx.set("stopWatch", new StopWatch()); + //jdm.ctx.set("stopWatch", new StopWatch()); ActionLanguage al = new ActionLanguage(); al.setDataModel(jdm); |