Nothing wrong with that, if that's what you need to do. Every shadow fact also has a slot named OBJECT which contains the actual object, and so if you wanted to match that, you could call "getClass()" on it rather than using Class.forName().

Note if you use getShadowClassName() as suggested below, then you'll get the name of the class used to define the template, which might be an interface (in which case you can't instantiate it, of course.) If you use the OBJECT slot, as I suggest, then you'll get the actual class of the object behind the fact, and that may or may not be what you actually want.



On Nov 3, 2009, at 7:26 AM, Marco Zappatore wrote:


I think that a possible solution could be the following

val.factValue(context).getDeftemplate().getShadowClassName()

and then instantiate a new instance starting from the string that the above
method returns...

In any case, I'd like to know your opinion...



Marco Zappatore wrote:

Dear Jess users,
I have a rule "myrule" that fires whenever two facts with specific slot
contents are found within the working memory.
These facts are shadow facts.
Then I have a java user function "myUserFunction" that passes those two facts (using their pointers, let's say ?f1 and ?f2) to a Java program. My question is: is it possible to get those facts and instantiate them
again in Java?
In other words the procedure is:
1) define a java bean
2) assert shadow facts from that java bean with different slot contents
each time
3) find a given fact with a given content using a proper rule
4) pass the fact to a java program
5) create a new instance of the java bean with the content just retrieved

the problem resides at point n°5 because actually I'm using
Value val = vv.get(1).resolveValue(context);
Using val.factValue(context)) I can verify that the content is correct but
how can I use val to instantiate a new Java Bean?

Any help is appreciated, thanks in advance.

Marco Zappatore


--
View this message in context: 
http://old.nabble.com/Retrieve-facts-from-Jess-and-re-instantiate-them-in-Java-tp26160053p26160091.html
Sent from the Jess mailing list archive at Nabble.com.



--------------------------------------------------------------------
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
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
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].
--------------------------------------------------------------------

Reply via email to