I didn't know Jess looks for BeanInfo objects. I'll give it a go. This might be a good item for the FAQ and/or user manual.
Thanks! alan > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, October 03, 2002 9:29 AM > To: [EMAIL PROTECTED] > Subject: Re: JESS: definstance fails on first attempt and passes on > next? > > > > Of course, the official way to do this is to use BeanInfo > objects. This is how you tell the JavaBeans machinery what is a > property and what is not. You can write a java.beans.BeanInfo object > to exclude the troublesome method, and Jess will use it. You really > need to get the JavaBeans spec from Sun to understand how to write > one, but it's pretty easy. > > > I think Alan Moore wrote: > [Charset iso-8859-1 unsupported, filtering to ASCII...] > > I had a similar problem recently definstancing an object with a > > getSnapshot() method that was getting called. This method > is not a bean > > property and could not be called at just any time - it has > side effects. I > > had to rename the method _getSnapshot() to prevent jess > from calling it when > > I definstanced it. > > > > Unfortunately, you can't change the names of the methods on the > > DefaultMutableTreeNode class. > > > > Once possible alternative is to have definstance take an > "excludeMethods" or > > "allowedMethods" parameter that would prevent it from > calling certain > > methods on the LHS or during definstance. Of course, this > would disallow the > > ability to pattern match against such things as the > firstChild in your > > DefaultMutableTreeNode but I suspect you aren't doing that anyway. > > > > Another strategy would be for you to create a wrapper class for > > DefaultMutableTreeNode that somehow checks it's wrapped instance to > > determine if an exception is going to be thrown, or just > catches one, and > > then return some reasonable default such as null in this > case. This seems > > like a bad hack but in a pinch it might just work for you. > > > > Good luck! > > > > alan > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On > > > Behalf Of pgilli1 > > > Sent: Thursday, October 03, 2002 6:56 AM > > > To: [EMAIL PROTECTED] > > > Subject: JESS: definstance fails on first attempt and > passes on next? > > > > > > > > > I'm running into a strange problem when inserting a > > > DefaultMutableTreeNode > > > object into my engine. I define the shadow fact, create a new > > > instance and try > > > to create a fact and it fails. But if I run definstance again, > > > the fact is > > > inserted successfully! What the heck is going on to exhibit this > > > behavior? > > > > > > See run below: > > > > > > > > > Jess> (defclass simple javax.swing.tree.DefaultMutableTreeNode) > > > javax.swing.tree.DefaultMutableTreeNode > > > > > > Jess> (bind ?dmtn (new > javax.swing.tree.DefaultMutableTreeNode "Parent")) > > > <External-Address:javax.swing.tree.DefaultMutableTreeNode> > > > > > > Jess> (definstance simple ?dmtn static) > > > > > > Jess reported an error in routine DefinstanceList.createFact > > > while executing (definstance simple ?dmtn static). > > > Message: Called method threw an exception. > > > Program text: ( definstance simple ?dmtn static ) at line 4. > > > Nested exception is: > > > node has no children > > > > > > java.util.NoSuchElementException: node has no children > > > > > > at > > > javax.swing.tree.DefaultMutableTreeNode.getFirstChild(DefaultMutab > > > leTreeNode.j > > > ava:864) > > > > > > (note: rest of stack trace has been removed) > > > > > > Jess> (definstance simple ?dmtn static) > > > <Fact--1> > > > > > > Jess> (facts) > > > f-0 (MAIN::simple (allowsChildren TRUE) (childCount 0) (class > > > <External-Address:java.lang.Class>) (depth 0) (firstChild > > > <External-Address:jess.SerializablePD>) (firstLeaf > > > <External-Address:jess.SerializablePD>) (lastChild > > > <External-Address:jess.SerializablePD>) (lastLeaf > > > <External-Address:jess.SerializablePD>) (leaf > > > <External-Address:jess.SerializablePD>) (leafCount > > > <External-Address:jess.SerializablePD>) (level > > > <External-Address:jess.SerializablePD>) (nextLeaf > > > <External-Address:jess.SerializablePD>) (nextNode > > > <External-Address:jess.SerializablePD>) (nextSibling > > > <External-Address:jess.SerializablePD>) (parent > > > <External-Address:jess.SerializablePD>) (path > > > <External-Address:jess.SerializablePD>) (previousLeaf > > > <External-Address:jess.SerializablePD>) (previousNode > > > <External-Address:jess.SerializablePD>) (previousSibling > > > <External-Address:jess.SerializablePD>) (root > > > <External-Address:jess.SerializablePD>) (siblingCount > > > <External-Address:jess.SerializablePD>) (userObject > > > <External-Address:jess.SerializablePD>) (userObjectPath > > > <External-Address:jess.SerializablePD>) (OBJECT > > > <External-Address:javax.swing.tree.DefaultMutableTreeNode>)) > > > > > > For a total of 1 facts. > > > > > > > > > <End>Thats the end of the run</END> > > > > > > > -------------------------------------------------------------------- > > > 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] > > -------------------------------------------------------------------- > > > > > > --------------------------------------------------------- > Ernest Friedman-Hill > Distributed Systems Research Phone: (925) 294-2154 > Sandia National Labs FAX: (925) 294-2234 > Org. 8920, MS 9012 [EMAIL PROTECTED] > PO Box 969 http://herzberg.ca.sandia.gov > Livermore, CA 94550 > > -------------------------------------------------------------------- > 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] --------------------------------------------------------------------