Re: JESS: Userfunctions and Jess - Java type conversion
I think erich.oliphant wrote: [Charset iso-8859-1 unsupported, filtering to ASCII...] Hmm, ok thanks, I understand better now. However, jess.Userfunctions return Value's so is there anything I can do in that case to activate the type conversion? I tried Value.resolve() but that did not help. You know, there's not actually a public API for getting Jess to do those conversions on demand from Java, although you've made a good case as to why there should be. The method you want is the static method jess.ReflectFunctions.objectToValue(), which takes two arguments, the object and the class of the Object; this is so that you can pass (for example) java.lang.Boolean as a Boolean.class or as a Boolean.TYPE -- i.e., a primitive. You could simply use obj and obj.getClass() as the two arguments. Since it's private, you could either change the source to make it public, or you could call the method reflectively using something like Object prop = ... Method oTV = Class.forName(jess.ReflectFunctions).getMethod(objectToValue); oTV.setAccessible(true); Value result = (Value) oTV.invoke(null, new Object[] {prop, prop.getClass()}); Of course, you'd probably want to get the Method object and cache it in a member variable someplace, and then stick all of this into your own objectToValue method. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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]
Re: JESS: creating an audit trail
Thought about it haven't done it. I would think the most performant least intrusive way is add a log4j listener to the class that fires the rules. I will look for it tonight. Why log4j? It is a non-blocking thread, unlick logging to a file, port or db. And if misconfigured you jess app will still work, plus you can play with HTML reports. Ever had an apd fail because the log file filled the disk or the db couldn't connect? quite frankly log4j makes a great debugging tool in any case. Jon -- !DOCTYPE HTML PUBLIC -//IETF//DTD HTML//EN html head meta http-equiv=Content-Type Content=text/html; charset=iso-8859-1 /head bodya href=http://jakarta.apache.org/tapestry/;img src=http://howardlewisship.com/images/no-struts.png; width=200 height=154 alt=Friends Don't Let Friends Code Struts border=0//a /body /html Roger Studner [EMAIL PROTECTED] wrote: Has anyone has success in industry with a pattern or methodology for tracking which rules fires and for what facts through a set of rules? I have thought of listeners on firings as well as inserting javabean value objects that can provide an API for collection relevant aspects of the rules firing conditions on the RHS. Any suggestions? Thanks, Roger Studner 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]
Re: JESS: creating an audit trail
Both suggestions are equally useful.. thanks.. I'll check in the API for registering a listener with the jess engine (is it for the whole engine, or by rule?) As well, i'm already using log4j in my java wrapper classes I make use of Engine's in.. so I will just STORE a logger and use it to track various 'inferred' pieces of information. Thanks both of you for your help Roger S On 12/1/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I think Roger Studner wrote: Has anyone has success in industry with a pattern or methodology for tracking which rules fires and for what facts through a set of rules? Not sure what you mean by a pattern or methodology, but... I have thought of listeners on firings That's all you have to do; DEFRULE_FIRED events contain the actual Activation object, which gives you the Defrule and all the Fact objects that matched. You'll get the events in the order the rules fire. You can then log all the info you want. Is there something more that you need beyond that? - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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]
Re: JESS: Userfunctions and Jess - Java type conversion
I think erich.oliphant wrote: I tried that function, but it doesn't seem to exist on the jess.ReflectFunctions class (I am using 7.0 beta 4. There seems to be a a static Value a(Class, Object) throws JessException method based on browsing the class file. Could this be it? You're not using a licensed version of Jess. Contact Craig Smith, [EMAIL PROTECTED], to obtain a license. Also, in regards to the original question, just thought about something. Since returning new Value(Boolean()) from my userfunction returns the Java Object, I'm still not clear about why this didn't work: (test (eq (ognl-get ?obj booleanProperty) (Boolean.TRUE))) shouldn't 'eq' call returnedObj.equals(Boolean.TRUE) ? The Jess function (Boolean.TRUE) returns the symbol TRUE, which is not the same at the Java object Boolean.TRUE; as I said before, calling a Java function from Jess reflectively always converts the result to a Jess data type. - Ernest Friedman-Hill Advanced Software Research Phone: (925) 294-2154 Sandia National LabsFAX: (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]