Please ignore the syntax in this posting. Yes, it is suppose to be like this:<br><br>public abstract class Base {<br><br>}<br><br>I would appreciate if you can explain how I can achieve the polymorphism behavior in drools (explained in my example). FYI I&#39;m using version 4.0.7.<br>
<br>Thanks!<br><br><div class="gmail_quote">On Mon, May 4, 2009 at 10:57 AM, Greg Barton <span dir="ltr">&lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Well, we can start out with the fact that this is improper java syntax:<br>
<br>
class abstract Base () {}<br>
<br>
The () is not in a class declaration.  Does this code compile for you? :)<br>
<br>
--- On Mon, 5/4/09, tellkb &lt;<a href="mailto:tellkb@gmail.com">tellkb@gmail.com</a>&gt; wrote:<br>
<br>
&gt; From: tellkb &lt;<a href="mailto:tellkb@gmail.com">tellkb@gmail.com</a>&gt;<br>
&gt; Subject: [rules-users] setGlobal issue in StatefulSession<br>
&gt; To: <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; Date: Monday, May 4, 2009, 12:35 PM<br>
<div><div></div><div class="h5">&gt; Hi there,<br>
&gt;<br>
&gt; I want to set setGlobal in working memory at run time based<br>
&gt; on derived<br>
&gt; class, e.g. DerivedOne or DerivedTwo. But it throws<br>
&gt; following error:<br>
&gt;<br>
&gt;       Illegal class for global. Expected<br>
&gt; [org.comp.app.bean.Base], found<br>
&gt; [org.comp.app.bean.DerivedOne].<br>
&gt;<br>
&gt;<br>
&gt; It should automatically resolve the derived class. Please<br>
&gt; let me know if I&#39;m<br>
&gt; doing something wrong. I&#39;d appreciate your help.<br>
&gt;<br>
&gt;<br>
&gt; Thanks,<br>
&gt; -KB<br>
&gt;<br>
&gt; Here are the classed I&#39;m using in my test project:<br>
&gt;<br>
&gt;<br>
&gt; class abstract Base () {<br>
&gt;<br>
&gt;       public void init( StatefulSession workingMemory ) {<br>
&gt;               this.workingMemory = workingMemory;<br>
&gt;               workingMemory.setGlobal(&quot;app&quot;, this);<br>
&gt;       }<br>
&gt;       public void logMe() {<br>
&gt;               System.out.println(&quot;From Derived BASE...&quot;);<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt; class DerivedOne() extends Base{<br>
&gt;       public void runRules( Object obj) {<br>
&gt;               ObjOne obj1 = (ObjOne)obj<br>
&gt;               workingMemory.insert(obj1);<br>
&gt;               workingMemory.fireAllRules();<br>
&gt;               workingMemory.dispose();<br>
&gt;       }<br>
&gt;       public void logMe() {<br>
&gt;               System.out.println(&quot;From Derived ONE...&quot;);<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt; class DerivedTwo() extends Base{<br>
&gt;       public void runRules( Object obj) {<br>
&gt;               ObjTwo obj2 = (ObjTwo)obj<br>
&gt;               workingMemory.insert(obj2);<br>
&gt;               workingMemory.fireAllRules();<br>
&gt;               workingMemory.dispose();<br>
&gt;       }<br>
&gt;       public void logMe() {<br>
&gt;               System.out.println(&quot;From Derived ONE...&quot;);<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt;<br>
&gt; class Caller() {<br>
&gt;<br>
&gt;       RuleBase ruleBase = ruleBaseFactory.open(docRules);<br>
&gt;       workingMemory = ruleBase.newStatefulSession();<br>
&gt;<br>
&gt;       if (sub==1) {<br>
&gt;               der1 = new DerivedOne();<br>
&gt;               der1.init(workingMemory);<br>
&gt;               der1.runRules();<br>
&gt;       }<br>
&gt;       else if (sub==1) {<br>
&gt;               der2 = new DerivedTwo();<br>
&gt;               der2.init(workingMemory);<br>
&gt;               der2.runRules();<br>
&gt;       }<br>
&gt; }<br>
&gt;<br>
&gt; //********DRL FILE*****<br>
&gt; package com.sample<br>
&gt;<br>
&gt; import com.sample.app.RuleCaller.Message;<br>
&gt;<br>
&gt; global com.sample.app.Base app;<br>
&gt;<br>
&gt; rule &quot;using a static function&quot;<br>
&gt; when<br>
&gt;     eval( true )<br>
&gt; then<br>
&gt;     System.out.println( &quot;Message from Rule.&quot; );<br>
&gt;     app.logMe();<br>
&gt; end<br>
&gt; //********DRL FILE*****<br>
&gt; --<br>
&gt; View this message in context:<br>
&gt; <a href="http://www.nabble.com/setGlobal-issue-in-StatefulSession-tp23373008p23373008.html" target="_blank">http://www.nabble.com/setGlobal-issue-in-StatefulSession-tp23373008p23373008.html</a><br>
&gt; Sent from the drools - user mailing list archive at<br>
&gt; Nabble.com.<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>