Mike

What I usually see is that you have a fact or attribute where you can set the result of your validation:

rule "user is miked"
when
   $id : Identity( usename == "miked" )
   $p : Permission( id == $id )
then
   $p.deny();
end

In your application you asserted the Permission object, so you have it's handle and just check the result:

if( permission.isDenied() ) {
   // do something
}

Another way would be to use call back, setting the callback instance as a global:

global org.sample.PermissionManager permission;

rule "user is miked"
when
   $id : Identity( usename == "miked" )
then
   permission.deny( $id );
end

  []s
  Edson

Mike Dougherty wrote:

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
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
858.232.3635

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



------------------------------------------------------------------------

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to