View Javadoc

1   /*
2    * $Id: RulesEngine.java 22048 2011-05-31 14:39:03Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.bpm;
12  
13  import org.mule.api.NameableObject;
14  
15  
16  /**
17   * A generic interface for any Rules Engine.  Theoretically, any Rules Engine can be "plugged into" 
18   * Mule if it implements this interface.  
19   * 
20   * @see MessageService
21   */
22  public interface RulesEngine extends NameableObject
23  {
24      /**
25       * Inject a callback so that the Rules Engine may generate messages within Mule.
26       * This method is REQUIRED.
27       * 
28       * @param messageService An interface within Mule which the rules may call to generate Mule messages.
29       */
30      public void setMessageService(MessageService messageService);
31  
32      /**
33       * Create a provider-specific session for interacting with the Rules Engine.
34       * This method is REQUIRED.
35       * 
36       * @param ruleset
37       * @return an initialized rules session
38       */
39      public Object createSession(Rules ruleset) throws Exception;
40      
41      /**
42       * Dispose of a provider-specific session if necessary.
43       * This method is OPTIONAL.
44       * 
45       * @param session - an initialized rules session
46       */
47      public void disposeSession(Object session) throws Exception;
48      
49      /**
50       * Assert a fact in the knowledge base.
51       * This method is REQUIRED.
52       *
53       * @param ruleset 
54       * @param fact to assert
55       * @return a handle to the fact for future reference
56       */
57      public Object assertFact(Rules ruleset, Object fact) throws Exception;
58  
59      /**
60       * Retract a fact from the knowledge base.
61       * This method is REQUIRED.
62       *
63       * @param ruleset 
64       * @param fact to retract
65       */
66      public void retractFact(Rules ruleset, Object fact) throws Exception;
67  
68      /**
69       * Add an event to the event stream.  This is used for CEP.
70       * This method is OPTIONAL.
71       *
72       * @param ruleset 
73       * @param event
74       * @param entryPoint for the event stream
75       * @return a handle to the event for future reference
76       */
77      public Object assertEvent(Rules ruleset, Object event, String entryPoint) throws Exception;
78  }