[x3d-public] JSweet translation of X3DJSAIL to JavaScript: need specific design goals first

John Carlson yottzumm at gmail.com
Fri Apr 10 17:46:47 PDT 2020


So here's a description of my Java<->node.js bridge for RunSaxon.java.

I have a file, runAndSend.js that imports another javascript file,
allsaxon.js

runAndSend.js has the following code:
-----------------------------------------------------
var runsaxon = require('./allsaxon');
var config = require('./config');
var fs = require("fs");

function runAndSend(args, callback) {
        runsaxon(args);
----------------------------------------------------
allsaxon.js looks like this:
----------------------------------------------------
var java = require("java");
java.options.push("-Djava.awt.headless=true");
java.options.push("-Xmx1000m");
//java.options.push('-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005');
java.classpath.push("saxon9he.jar");
java.classpath.push("../saxon9he.jar");
java.classpath.push("../../saxon9he.jar");
java.classpath.push("../../../saxon9he.jar");

java.classpath.push("target/classes");
java.classpath.push("../target/classes");
java.classpath.push("../../target/classes");
java.classpath.push("../../../target/classes");

java.classpath.push("target/X3DJSONLD-1.0-SNAPSHOT.jar");
java.classpath.push("../target/X3DJSONLD-1.0-SNAPSHOT.jar");
java.classpath.push("../../target/X3DJSONLD-1.0-SNAPSHOT.jar");
java.classpath.push("../../../target/X3DJSONLD-1.0-SNAPSHOT.jar");

function translate(infiles) {
        java.callStaticMethodSync("net.coderextreme.RunSaxon", "main",
infiles);
}

if (typeof module === 'object')  {
        module.exports = translate;
}
---------------------------------------------------------------------------------------------------------
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.

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.

Here is the repository for npm (or node) java:

https://github.com/joeferner/node-java
<https://github.com/joeferner/node-java#javaNewInstance>

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.

So who exactly needs a JavaScript server solution, and why aren't they
speaking up?

Thanks,

John


On Fri, Apr 10, 2020 at 7:24 PM John Carlson <yottzumm at gmail.com> wrote:

>
>
> On Tue, Mar 24, 2020 at 8:20 AM Don Brutzman wrote:
>
> Authoring use-case environments are
>> 1. Script inside X3D scene graph,
>> 2. Script in outer HTML5 web page,
>> 3. Standalone programmatic use in node.js
>>
>> Now get specific.
>>
>
> 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.
>
> 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?
>
> 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.
>
> Suggestions for next steps are welcome, and I will review Don's email
> again and see what he said.
>
> 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.
>
> 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.
>
> So a possible path forward is generating the glue code between node.js and
> Java, similar to what we did for PyJNIus.
>
> 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.
>
> So this is throwaway code for now, just a single class.
>
> Note that I have been stripping RunSaxon code out of my code, since I have
> a XML to JSON solution.
>
> What do you think?
>
> John
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200410/0e9190a4/attachment.html>


More information about the x3d-public mailing list