Hi,
I am using guvnor to create rules and access it through java
code in my application.
I have create pachage “Mypackage” and one rule “Myrule”
inside the package.
The code to access the rules is –
public SubnetDTO getValidSubnet(SubnetDTO
dto) {
ClassLoader
old = Thread.currentThread().getContextClassLoader();
try {
System.out.println("reading
working business rules ---------- ");
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
RuleAgent
agent = RuleAgent.newRuleAgent("/subnet.properties");
RuleBase ruleBase = agent.getRuleBase();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
workingMemory.insert(dto);
workingMemory.fireAllRules();
for (Iterator
i = workingMemory.iterateObjects(); i.hasNext();)
{
System.out.println("getCanonicalName > "+i.next().getClass().getCanonicalName());
}
return dto;
}
catch (Throwable t) {
t.printStackTrace();
}
finally
{
Thread.currentThread().setContextClassLoader(old);
}
return null;
}
Subnet.properties contains url as –
url=http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/Mypackage/LATEST
Now I have created “Myrule1” in the package “Mypackage”
and tried to access the both rule with the same url in the properties file.
But it is only validating the first rule only.
So let me know what changes I have to make to access both rules
from the package.
If any other approach is possible then suggest that also.
Thanks
Rabindra
Kumar Srivastava | ATT04 | Tech Mahindra
Hinjewadi, Pune 411 057, INDIA
( Office: +91 20 42250000 | Mobile: +91 9892232699| Ext: 253918
Email: rs0090916@techmahindra.com