yeah it did change. In 2.5, the functions are compiled into their own class,
which is then referred to as static methods in the generated rule classes.
Hence the need to be static. I should have put that in the relase notes
<scurries to work out how to edit confluence...>

IN drools 3, we will have a function construct, so you don't have to worry
about public static etc.. you just say what the function name is, what what
its return type is (if any).

On 3/8/06, Paul Smith <[EMAIL PROTECTED]> wrote:
>
> I noticed that function declarations seemed to change between drools 2.1and
> 2.5. I had some functions that were not declared as static that compiled
> ok
> with drools 2.1 but I noticed that compilation error happening when I
> switched to 2.5.
>
> On 3/8/06, Steven Williams <[EMAIL PROTECTED]> wrote:
> >
> > Hi Russell,
> >
> > From looking at the examples I think your fix should be just a matter of
> > changing your function definition from:
> >
> > public void printStock
> >
> > to
> >
> > public static void printStock
> >
> >
> > cheers
> > Steve
> >
> >
> > On 3/8/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > >
> > > Guys:
> > >
> > > I am working through a simple example for loading rules.  I am running
> > jdk
> > > 1.5, eclipse 3.1.1, and drools2.5 final.
> > >
> > >     When I run the application it complains about the rules.  This is
> > the
> > > rule set
> > >
> > >    <?xml version="1.0" encoding="UTF-8"?>
> > > <rule-set name="BusinessRuleSample"
> > >    xmlns="http://drools.org/rules";
> > >    xmlns:java="http://drools.org/semantics/java";
> > >    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance";
> > >          xs:schemaLocation="http://drools.org/rules rules.xsd
> > >                             http://drools.org/semantics/java java.xsd
> ">
> > >
> > > <!-- Import the Java Obje ts thate are referenced in the rules -->
> > > <java:import>java.lang.Object</java:import>
> > > <java:import>java.lang.String</java:import>
> > > <java:import>com.company.dept.product.domain.StockOffer</java:import>
> > >
> > > <!-- A Java utility function we reference in the rules -->
> > >   <java:functions>
> > >     public void printStock(
> > com.company.dept.product.domain.StockOfferstock){
> > >        System.out.println("Name:"     + stock.getStockName()
> > >                           + " Price:" + stock.getStockPrice()
> > >                           + " BUY:"   + stock.getRecommendPurchase());
> > >     }
> > >   </java:functions>
> > >
> > >   <rule name="Stock Price Low Enough">
> > >       <!-- parameters to pass to business rule -->
> > >      <parameter identifier="stockOffer">
> > >         <class>StockOffer</class>
> > >      </parameter>
> > >      <!--  Conditions or 'left hand side' (LHS) that must be met
> > >            for business rule to fire-->
> > >      <java:condition>stockOffer.getRecommendPurchase() == null
> > > </java:condition>
> > >      <java:condition>stockOffer.getStockPrice() &lt; 100
> > </java:condition>
> > >      <java:consequence>
> > >               stockOffer.setRecommendPurchase(StockOffer.YES);
> > >               printStock(stockOffer);
> > >      </java:consequence>
> > >   </rule>
> > > </rule-set>
> > >
> > >   I am getting this error:
> > > [start of error]
> > > org.drools.semantics.java.JavaSemanticCompileError: A problem occured
> > > compiling the embedded code:
> > >
> > >
> >
> drools/org/businessrulesample_1141764314250/java/Stock_Price_Low_Enough_0.java(30)
> > > Cannot make a static reference to the non-static method
> > > printStock(StockOffer) from the type Function_0_0
> > > [end of error]
> > >
> > > Any insight would be greatly appreciated.....
> > >
> > > Russ
> > >
> > >
> > >
> >
> >
> > --
> > Steven Williams
> >
> > Supervising Consultant
> >
> > Object Consulting
> > Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
> > [EMAIL PROTECTED]
> > www.objectconsulting.com.au
> >
> > consulting | development | training | support
> > our experience makes the difference
> >
> >
>
>

Reply via email to