[rules-users] Getting validation errors

Mike Dougherty mjdougherty at gmail.com
Mon Mar 12 22:07:10 EDT 2007


Hello,

I am using JBoss Rules to validate entities before storing them in  
the database. I therefore need a way to inform the calling code that  
the entity which was asserted failed verification. The only way I  
have been able to find that works is to assert an exception from  
within the rule file. For example:

rule "user is 'miked'"
   when
     identity : Identity( username == "miked" )
   then
     assertLogical(new IllegalStateException("Entity failed  
verification."));
end

Then in the Java that fires the rule, I have:

workingMemory.fireAllRules();
for(Iterator i = workingMemory.getObjects(Exception.class).iterator 
(); i.hasNext(); ) {
     System.out.println("Exception: "+i.next());
}

Which seems to be working OK. But I wanted to see if maybe there is a  
better way to accomplish what I need.

Thanks for you help.
Mike


--
*********************************
Mike Dougherty
mjdougherty at gmail.com
858.232.3635

http://www.google.com/talk/
*********************************



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070312/787e3493/attachment.html 


More information about the rules-users mailing list