<html>
<head>
    <base href="https://docs.jboss.org/author">
            <link rel="stylesheet" href="/author/s/en/2172/19/5/_/styles/combined.css?spaceKey=TEIID&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://docs.jboss.org/author/display/TEIID/Drools+Component+Integration">Drools Component Integration</a></h2>
    <h4>Page  <b>added</b> by             <a href="https://docs.jboss.org/author/display/~van.halbert">Van Halbert</a>
    </h4>
         <br/>
    <div class="notificationGreySide">
         <h1><a name="DroolsComponentIntegration-DroolsComponentIntegration"></a>Drools Component Integration</h1>

<p>The Drools component integration is an example of integrating business rules with your data.  This example will demonstrate how a business rule can be triggered via a User Defined Function (UDF).  </p>

<p>The UDF (RulesUDF.java) is written to load one or more drools .drl file(s) that is defined as a system property.  An example is:</p>
<ul class="alternate" type="square">
        <li>&lt;property name="org.teiid.drools.UDF" value="org.jboss.teiid.quickstart.data.MarketData:MyBusinessRules.drl"/&gt;</li>
</ul>


<p>  where:  -  value format is:  POJO className:.drl file<span class="error">&#91;,POJO className:.drl,…&#93;</span></p>

<p>The format maps the POJO to the rule that will process it.</p>

<p>The caller to the UDF will call the following function method:<br/>
  &lt;code&gt;<br/>
        public static Object performRuleOnData(final String className, final String returnMethodName, final Object returnIfNull, final Object... arguments) </p>
<div class="error"><span class="error">Unknown macro: {
        ..
        }</span> </div>
<p>  &lt;/code&gt;</p>

<p>  where:</p>
<ul class="alternate" type="square">
        <li>className:  class name of the POJO to be instantiated and passed to the rules</li>
        <li>returnMethodName:  name of the method to call on the POJO to get the return value (if one)</li>
        <li>returnIfNull:  if returnMethodName returns a null value, then default to returnIfNull value</li>
        <li>arguments:  is a variable number of objects, that must match to the constructor of the POJO.<br/>
                So all the arguments will be passed in when the "className" is instantiated.</li>
</ul>


<p>One of the goals of this example was to demonstrate that a UDF could be written generically to integrate with drools.   </p>

    </div>
    <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;" class="grey">
                        <a href="https://docs.jboss.org/author/users/removespacenotification.action?spaceKey=TEIID">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://docs.jboss.org/author/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
       <a href="https://docs.jboss.org/author/display/TEIID/Drools+Component+Integration">View Online</a>
              |
       <a href="https://docs.jboss.org/author/display/TEIID/Drools+Component+Integration?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
           </div>
</div>
</div>
</div>
</div>
</body>
</html>