Another illegal method that I have used is to create a dummy applet inside the application to "fool" Jess into thinking that it is running in an applet.

class myStub implements AppletStub {
public myStub(String profile) {
if (!profile.equals("")) {
_base = profile;
} else {
_base = this.getClass().getClassLoader().getSystemResource("clip/scriptlib.clp");
}
System.out.println("CODEBASE = " + _base);
}

private AppletContext _context = null;
private URL _base = null;

public void appletResize(int w, int h) {
}

public AppletContext getAppletContext() {
return _context;
}

public URL getDocumentBase() {
return _base;
}

public URL getCodeBase() {
return _base;
}

public String getParameter(String in) {
return "";
}

public boolean isActive() {
return false;
}
}

Applet myApplet = new Applet();
myApplet.setStub(new myStub(""));

jess = new Rete(myApplet);

It's probably what one would, in polite circles, call a hack but it does work...

On Monday, February 18, 2002, at 09:17 PM, [EMAIL PROTECTED] wrote:

The function docs for (batch) (in chapter8 of the manual) say that the
argument is a file, and if and only if Jess is running in an applet
(i.e., Rete.setApplet() has been called) then (batch) will try to find
the file hanging off of the applet's documentBase. No place does the
manual say that batch takes a URL; if this works in an applet, it's
just undefined behavior -- a coincidence.

If you want to load Jess code from a URL, then the only legal way to
do it is to do it yourself. This is pretty easy -- something like

Rete engine = ...;
URL url = new URL("http://foo");
Reader r = new InputStreamReader(url.openStream());
Jesp j = new Jesp(r, engine);
// Read until end-of-file
Value v = j.parse(false);

would work fine. This is all that (batch) does.

I Graham
-------------------------------------------------------------------------------
Beware of Geeks bearing GIFS. http://www.jlab.org/coda Jefferson lab DAQ group

Reply via email to