Creating custom JavaScript interpreter

Jyoti Gandhe <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <3C473712E955294D86A9C69445EE658D0A7E7C@exmb-00-ah.ad.mathworks.com>
I have created a custom JavaScript interpreter because I want to avoid creating a dependency on Rhino. I have created implementations of Interpreter and InterpreterFactory interfaces. I am trying to determine the best way of  registering my InterpreterFactory with Batik. My current approach is to subclass BridgeContext and hard-code it to return my custom interpreter-


public class CustomBridgeContext extends BridgeContext {

   public Interpreter getInterpreter(String language) {
            if (language.equalsIgnoreCase("ecmascript")) {

                  return new MyJavaScriptInterpreter();
            }

            return super.getInterpreter(language);
    }

}


I have subclassed JSVGCanvas to return an instance of my CustomBridgeContext -


public class CustomJSVGCanvas extends JSVGCanvas {
    /**
     * Creates a new bridge context.
     */
    protected BridgeContext createBridgeContext(SVGOMDocument doc) {
        super.createBridgeContext(doc);
        return new CustomBridgeContext(userAgent, loader);
    }
}

I have read about using Service provider to register InterpreterFactory with batik. However, I could not determine how to use it correctly. Can someone point me to an example of how to register my interpreterfactory with batik script engine.

Thanks,
Jyoti
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.