2016-12-26 110 views
0

我定義了一個帶有靜態字段的類,我想訪問規則左邊的字段。可能嗎?訪問LHS中的靜態字段

這裏是類:

package cep.model; 

public class Events { 
    public static final int A = 1; 
    public static final int B = 2; 
    public static int getA() { 
     return A; 
    } 

    public static int getB() { 
     return B; 
    } 
} 

和規則:

package cep.drl; 
dialect "mvel" 
import cep.Event; 
import cep.model.Events; 

declare Event 
@role(event) 
@expires(20s) 
end 

//A & B 
rule "r001" 
no-loop 
    when 
    $a : Event(typeId == Events.A) 
    and $b : Event(typeId == Events.B) 
    then 
end 

,並使用編譯滴料後插件:

Unable to Analyse Expression typeId == Events.A: 
[Error: unable to resolve method using strict-mode: cep$Event.Events()] 
[Near : {... typeId == Events.A ....}] 
        ^
[Line: 15, Column: 4] : [Rule name='r001'] 


Unable to Analyse Expression typeId == Events.B: 
[Error: unable to resolve method using strict-mode: cep$Event.Events()] 
[Near : {... typeId == Events.B ....}] 
        ^
[Line: 16, Column: 8] : [Rule name='r001'] 

回答

0

我想你必須把規則以這種方式,replace == to:對事件做出約束.A

rule "r001" 
no-loop 
    when 
    $a : Event(typeId : Events.A) 
    and $b : Event(typeId == Events.B) 
    then 
end 
相關問題