Hey,
I had a similar problem with using Rete.addUserpackage() from java. All
.clp files that referenced any functions defined in my Userpackage
displayed 'unknown function' errors. Adding an explicit (load-package
...) call to the top of all affected .clp files fixed the problem.
My original intention in using the Rete.addUserpackage() call from Java
was to make a set of custom functions available globally without the
need for an explicit (load-package) call in each .clp file (or a
ubiquitous (batch) command that loads the package indirectly). I'm no
longer convinced that this is all that beneficial.
I'm comfortable with requiring the explicit (load-package) call. It
does provide a form of self documentation.
One option that might work would be to add a "Jess class:" field
somewhere on the Windows->Preferences->Jess Editor preferences page that
specifies the executable class to be used by the JessDE. The default
would be jess.Main, but this would allow me to substitute, for example,
com.mycompany.myjess.MyMain. This class could then be structured as
follows:
...
public class MyMain extends jess.Main {
public static void main(String[] argv) {
MyMain m = new MyMain();
m.initialize(argv, new Rete());
m.execute(true);
}
public jess.Main initialize(String[] argv, Rete r) {
super.initialize(argv, r);
// perform custom initialization of the Rete instance here.
r.addUserpackage(new MyUserpackage);
r.importClass("org.apache.log4j.Logger");
// etc.
return this;
}
}
If the JessDE editor then used this class instead of jess.Main, the
customizations would be applied without explicit calls in the .clp
files.
Yet another option might be to add an "Initialization script:" field to
the Windows->Preferences->Jess Editor preferences page. This script can
then be evaluated by the editor at startup. This script could
conceivably provide the customizations that might be done in Java at
runtime.
Again, I'm not advocating that either of these are better than simply
being explicit in our .clp files. However, it might provide a solution
for people who choose to customize the Jess instance at runtime via
Java.
-Mitch
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, January 11, 2005 1:40 PM
To: [email protected]
Subject: Re: JESS: JessDE .clp file errors and defclass
I think [EMAIL PROTECTED] wrote:
>
> I have a rules file that references a [ defclass ] ... defined from
> Java.... In the JessDE, the reference to these facts are displayed
> as errors. Is there a way to tell the JessDE that these facts are
> defined else where? I found similar postings related to cascading
> .clp files, but nothing related to defining in Java. ... Is what I
> have done unconventional?
No, this isn't unconventional, mainly because we haven't established
any conventions yet! People certainly do this, and have done so for
some time, but of course nobody's done much of it with JessDE yet
because it's so new, and we're just starting to figure out how to use
it properly.
The Jess community has historically figured this sort of thing out
together, and I hope our recent growth hasn't put a damper on that. So
I'll put it to you as a question: how would you like to see this
handled?
One way to do it with the current version of the software would be to
create an extra little clp file containing just the defclass, and add
it to the main file as a source dependency (as described in those
other posts you mention.)
>
> Also, was it a conscious decision to not put the errors and warnings
in the
> Problems view or could that be added as a feature request? It sure
would
> be easier to copy/paste the actual errors if they were displayed in
the
> Problems view.
The Eclipse Problems view has a filter which, by default, will only
display some problems; Jess errors won't be among them (This is a
silly default, if you ask me!) In the title bar of the Problems view,
click on that little icon that looks like two blue arrows and one
yellow one. You'll get the "Filters" dialog, and you should be able to
tell the view to display the Jess error markers.
Thanks for reminding me that this needs to be in the manual! If
anybody knows how the JessDE can automatically set up this filter from
code, let me know.
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify
[EMAIL PROTECTED]
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------