[x3d-public] Idea for X3dToJava.xslt

John Carlson yottzumm at gmail.com
Sun Apr 22 22:44:44 PDT 2018


The idea would be have a single class factory in the jar which creates all your X3D objects, so you would call into the factory instead of directly calling new on the constructor.   Then you would load the class factory with the custom URLClassLoader which has loaded the X3DJSAIL*.jar from over the network.

Something to think about, maybe create a separate X3dToJavaFactory.xslt for those who want to use the network jar.

Hmm.  It might now be too hard to change my JavaSerializer to do something like this.  Hmm.  Hmm.

Or maybe add the Jar to the system classloader path dynamically.

Hmm.  Hmm.  How to keep people up to date with the latest.  Hmm. Hmm.   Can you put https:// on the classpath? You can with webstart.  Maybe we should do a webstart solution?

Something to think about.

John
Sent from Mail for Windows 10

From: John Carlson
Sent: Monday, April 23, 2018 1:27 AM
To: Don Brutzman; x3d-public at web3d.org
Subject: RE: Idea for X3dToJava.xslt

Looks like this works for a single class, and probably some kind of RMI.  Good luck if you decide to do something like this.

John

import java.net.*;
import java.lang.reflect.*;

public class LocalMUDClient extends URLClassLoader {
        static public void main(String args[]) {
                try {
                        String nick = "John";
                        if (args.length > 0) {
                                nick = args[0];
                        }
                        String room = "rmi://localhost/Generic_Room";
                        if (args.length > 1) {
                                room = args[1];
                        }
                        String url = "jar:http://localhost/webstart/chat/icbmc.jar!/";
                        if (args.length > 2) {
                                url = args[2];
                        }
                        String args2[] = new String[1];
                        // String args2[] = new String[2];
                        args2[0] = nick;
                        // args2[1] = room;

                        URL urls[] = new URL[1];
                        urls[0] = new URL(url);
                        LocalMUDClient j = new LocalMUDClient(urls);
                        Class c = j.findClass("icbm.MUDClient");
                        System.err.println(c.getName());
                        Class params[] = new Class[1];
                        params[0] = args2.getClass();
                        Constructor cons = c.getConstructor(params);

                        Object objs[] = new Object[1];
                        objs[0] = args2;
                        cons.newInstance(objs);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
        public LocalMUDClient(URL urls[]) {
                super(urls);
        }
}

Sent from Mail for Windows 10

From: John Carlson
Sent: Monday, April 23, 2018 1:09 AM
To: Don Brutzman; x3d-public at web3d.org
Subject: Idea for X3dToJava.xslt

Perhaps the Java program could download the X3DJSAIL*.jar from over the network, so one is always up to date?  I’ve got some examples of that.

Thanks,

John



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20180423/adb12eb4/attachment-0001.html>


More information about the x3d-public mailing list