<div dir="ltr">I discovered a way forward: <a href="https://github.com/joeferner/node-java#import">https://github.com/joeferner/node-java#import</a> Makes a Java class work like a JavaScript class, in my reading.  I will proceed to write a nodejs file which creates all the classes, if we are in agreement that this is a nodejs-only solution and we want it. node-java is the npm java I was talking about.  This will primarily make an X3DJSAIL derivative, and will not be native JavaScript. I am not really into generating a bunch of untested code at this point, and it seems like X3DJSAIL is becoming a crown jewel again.  I do think that something like PhantomJS is better for testing webapps rather than creating a nodejs app to do it. I still test my webapps by hand unfortunately!<br><div><br></div><div>However, I think we may have discussed this solution some time back, and it may be worth reviewing the email.</div><div><br></div><div>It does tie us to an external source code out of our control, but is that any different netbeans?</div><div><br></div><div>Will we run into the same problems as PyJNIus?</div><div><br></div><div>It seems like we could create some test cases pretty quickly, that is, use the same ones that cause PyJNIus to fail.</div><div><br>I'm not sure when I'll get to this.</div><div><br></div><div>Note that this will likely NOT be like the SAI reference implementation for ECMAScript.</div><div>This will be a Java derivative that builds on previous work.<br></div><div><br></div><div>I welcome people who want to help with the JSweet solution, but that won't be SAI either.</div><div><br></div><div>Perhaps we should have server-side SAI and client-side SAI?</div><div><br></div><div>John</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 10, 2020 at 7:46 PM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">So here's a description of my Java<->node.js bridge for RunSaxon.java.<div><br></div><div>I have a file, runAndSend.js that imports another javascript file, allsaxon.js</div><div><br></div><div>runAndSend.js has the following code:</div><div>-----------------------------------------------------</div><div>var runsaxon = require('./allsaxon');<br>var config = require('./config');<br>var fs = require("fs");<br><br>function runAndSend(args, callback) {<br>        runsaxon(args);<br></div><div>----------------------------------------------------</div><div>allsaxon.js looks like this:</div><div>----------------------------------------------------</div><div>var java = require("java");<br>java.options.push("-Djava.awt.headless=true");<br>java.options.push("-Xmx1000m");<br>//java.options.push('-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005');<br>java.classpath.push("saxon9he.jar");<br>java.classpath.push("../saxon9he.jar");<br>java.classpath.push("../../saxon9he.jar");<br>java.classpath.push("../../../saxon9he.jar");<br><br>java.classpath.push("target/classes");<br>java.classpath.push("../target/classes");<br>java.classpath.push("../../target/classes");<br>java.classpath.push("../../../target/classes");<br><br>java.classpath.push("target/X3DJSONLD-1.0-SNAPSHOT.jar");<br>java.classpath.push("../target/X3DJSONLD-1.0-SNAPSHOT.jar");<br>java.classpath.push("../../target/X3DJSONLD-1.0-SNAPSHOT.jar");<br>java.classpath.push("../../../target/X3DJSONLD-1.0-SNAPSHOT.jar");<br><br>function translate(infiles) {<br>        java.callStaticMethodSync("net.coderextreme.RunSaxon", "main", infiles);<br>}<br><br>if (typeof module === 'object')  {<br>        module.exports = translate;<br>}<br></div><div>---------------------------------------------------------------------------------------------------------</div><div>I have forgotten if there are class level interfaces to the underlying Java code, as we had in PyJNIus.   That would require research. We may run into the same issues as PyJNIus.</div><div><br></div><div>In any cases, it would require mirroring the entire X3DJSAIL package, so it would be best if we probably wrote a stylesheet that put out this binding JavaScript code, whatever that may be.</div><div><br></div><div>Here is the repository for npm (or node) java:</div><div><br></div><div><a href="https://github.com/joeferner/node-java#javaNewInstance" target="_blank">https://github.com/joeferner/node-java</a></div><div><br></div><div>It seems to me that we need some python or xslt code to read the X3DUOM and produce the glue code. Possibly only at the class level, but more likely at the method and instance level, not sure.  That requires more research.  I suggest someone take the Transform specification and convert it to the necessary glue code.  For me, I don't "need" this glue code as I am happy with Nashorn presently.  So it would probably be best to apply some $$ to make me need this glue code.  That is, I am pretty much happy with a Java/Nashorn server-side and JavaScript client-side solution.  I don't really need a JavaScript server-side solution.</div><div><br></div><div>So who exactly needs a JavaScript server solution, and why aren't they speaking up?</div><div><br></div><div>Thanks,</div><div><br></div><div>John</div><div> <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 10, 2020 at 7:24 PM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 24, 2020 at 8:20 AM Don Brutzman wrote:</div><div dir="ltr" class="gmail_attr"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Authoring use-case environments are<br>
1. Script inside X3D scene graph,<br>
2. Script in outer HTML5 web page,<br>
3. Standalone programmatic use in node.js<br>
<br>
Now get specific.<br></blockquote><div><br></div><div>Not yet.   We need to discuss the environments.   X_ITE does inside X3D, and with the addition of X_ITE_DOM, in outer HTML5. X3DOM does outer HTML5. X3DJSAIL is a standalone library.</div><div><br></div><div>So what we really need is a standalone EAI for node.js without rendering except to an encoding.  Can we turn either X3DJSAIL, X_ITE or X3DOM into such an environment?  I provided a solution for Nashorn on top of X3DJSAIL, but not a solution for node.js. Have we had any take up on the Nashorn solution, enough to warrant a node.js solution?</div><div><br></div><div>So I would recommend that before researching all the various Transforms, that we just try to develop a single Transform.js class for node.js, with an encoding rendering.  It will be throwaway code, just a proof of concept.</div><div><br></div><div>Suggestions for next steps are welcome, and I will review Don's email again and see what he said.</div><div><br></div><div>For node.js, I believe there are packages that emulate the browser enviroment, i think that jsdom (?) and xmldom are two popular ones, so we can look at turning node.js into a headless browser.   There are also ways to run browsers in headless mode, PhantomJs comes to mind, but I haven't researched this extensively.</div><div><br></div><div>There are environments for running Java and node.js together, as I demonstrated with RunSaxon.java in X3DJSONLD.  My approach for that was simplistic, and won't really work for a multiclass approach.  There is also the java npm package that may lead towards a solution.</div><div><br></div><div>So a possible path forward is generating the glue code between node.js and Java, similar to what we did for PyJNIus.</div><div><br></div><div>I suggest that we do a very simple single class solution, not unlike the RunSaxon.java solution. This required various node.js files.   I think the new solution will be more complex to deal with the npm java peculiarities.</div><div><br></div><div>So this is throwaway code for now, just a single class.</div><div><br></div><div>Note that I have been stripping RunSaxon code out of my code, since I have a XML to JSON solution.</div><div><br></div><div>What do you think?</div><div><br></div><div>John</div><div><br></div></div></div>
</blockquote></div>
</blockquote></div>