Two ways you could do it:

List list = workingMemory.getObjects(Target.class);

or use a query:

query "target objects"

QueryResults results = workingMemory.getQueryResults ( "target objects" );


On 4/10/07, jdepaul < > wrote:

Suppose my client code initially asserts two Facts into WorkingMemory
instance:  one Source object and one TargetOne object.  As the rules get
applied, some of the rules may assert additional Target facts into WM.   How
can I retrieve all of the Target facts (however many were created) from the
WorkingMemory after fireAllRules() method was called (regardless of how many
Target objects were created as a result)?!

I will not know the concrete type of the target object types that were
asserted into WM instance, as they can be as many as 7 class sub-types
(TargetOne, TargetTwo, TargetThree), though they will all share a common
super-class (com.mypackage.Target).  Can someone show an example on how to
fetch the resulting Target objects after fireAllRules() is called and filter
out the Target objects?

Thanks in advance -

View this message in context:
Sent from the drools - user mailing list archive at

rules-users mailing list

Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501

consulting | development | training | support
our experience makes the difference