Java 如何在Drools中激活规则(在程序中使用无限循环)
我有一个包含无限循环的函数(MonitorLOg);这是必要的,因为我想监视一个文件,并在有修改时执行操作。但是,Drools中的Java 如何在Drools中激活规则(在程序中使用无限循环),java,drools,business-rules,drools-fusion,Java,Drools,Business Rules,Drools Fusion,我有一个包含无限循环的函数(MonitorLOg);这是必要的,因为我想监视一个文件,并在有修改时执行操作。但是,Drools中的myRules不想启动(“WS-is-updated”不出现)。有什么建议吗 rule "SmartWssec" when PolicyUpdateWssec(changelog == true) then System.out.println("WS is updated"); end ///////////////////////////////////////
myRules
不想启动(“WS-is-updated”不出现)。有什么建议吗
rule "SmartWssec"
when
PolicyUpdateWssec(changelog == true)
then
System.out.println("WS is updated");
end
//////////////////////////////////////////////////////
PolicyUpdateWssec LogModSecurity = new PolicyUpdateWssec();
LogModSecurity.MonitorLog("D:\\Mod");
kSession.insert(LogModSecurity);
kSession.fireAllRules();
LogModSecurity
while(true){
WatchKey key;
try {
// wait for a key to be available
key = watcher.take();
} catch (InterruptedException ex) {
return;
}
for (WatchEvent<?> event : key.pollEvents()) {
// get event type
WatchEvent.Kind<?> kind = event.kind();
// get file name
@SuppressWarnings("unchecked")
WatchEvent<Path> ev = (WatchEvent<Path>) event;
Path fileName = ev.context();
System.out.println(kind.name() + ": " + fileName);
if (kind == ENTRY_MODIFY ) {
changelog=true;
setChangelog(changelog);
System.out.println("WS-Policy is being Update.......");
///////////////////////////
PolicyUpdateWssec LogModSecurity = new PolicyUpdateWssec();
LogModSecurity.MonitorLog("D:\\Mod");
kSession.insert(LogModSecurity);
kSession.fireAllRules();
LogModSecurity
while(true){
WatchKey key;
try {
// wait for a key to be available
key = watcher.take();
} catch (InterruptedException ex) {
return;
}
for (WatchEvent<?> event : key.pollEvents()) {
// get event type
WatchEvent.Kind<?> kind = event.kind();
// get file name
@SuppressWarnings("unchecked")
WatchEvent<Path> ev = (WatchEvent<Path>) event;
Path fileName = ev.context();
System.out.println(kind.name() + ": " + fileName);
if (kind == ENTRY_MODIFY ) {
changelog=true;
setChangelog(changelog);
System.out.println("WS-Policy is being Update.......");
while(true){
监视键;
试一试{
//等待钥匙可用
key=watcher.take();
}捕获(中断异常例外){
返回;
}
for(WatchEvent事件:key.pollEvents()){
//获取事件类型
WatchEvent.Kind-Kind=event.Kind();
//获取文件名
@抑制警告(“未选中”)
WatchEvent ev=(WatchEvent)事件;
路径文件名=ev.context();
System.out.println(kind.name()+“:”+文件名);
如果(种类==条目\修改){
changelog=true;
setChangelog(changelog);
System.out.println(“WS-Policy正在更新……);
请你在这里分享你的功能代码好吗?如果没有这个,很难说会发生什么。这是我的代码,谢谢你的帮助。你能在这里分享你的功能代码吗?没有这个很难说会发生什么。这是我的代码,谢谢你的帮助