Hi,
I've a DRL file and Java Class, and ChangeSet.xml present in local drive D:
DRL file is rulemaster.drl having rule A,rule B.
My ChangeSet.xml is <change-set
xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/...
<add
<resource source='file:D:\rulemaster.drl' type='DRL' /
</add
</change-set
Now My Java class is
package com.sample;
public class RuleEngine
{
private RuleEngine()
{
}
public static final void main(String[] args)
{
int counter=0;
try
{
System.out.println("Before rule engine start ");
RuleEngine.start();
System.out.println("After rule engine start ");
do{
Collection<KnowledgePackage> kpackages =
_kbase.getKnowledgePackages();
System.out.println("no of packages"+kpackages.size());
for(KnowledgePackage kpackage : kpackages)
{
for(org.drools.definition.rule.Rule rule1
:kpackage.getRules())
{
String packname= rule1.getPackageName();
String rulename=rule1.getName();
System.out.println("This is : "+packname+" Packages and
RuleName is " +rulename);
}
}
counter++;
try{
Thread.sleep(10000);
}catch (InterruptedException e){
System.out.println("Sleep exception occured");
}
}while(counter < 10000);
}catch (Throwable t){
t.printStackTrace();
}
}
public static synchronized RuleEngine start()
{
try{
if ( _instance == null)
{
_instance = new RuleEngine();
//create knowledgeBuilder
String url="file:D:\\ChangeSet.xml";
_kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent" );
System.out.println("after creating kagent");
_kagent.applyChangeSet(ResourceFactory.newUrlResource(url));
System.out.println("after apply change set");
//Create Knowledge Base
_kbase = _kagent.getKnowledgeBase();
ResourceChangeScannerConfiguration sconf=
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
sconf.setProperty("drools.resource.scanner.interval", "5");
ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
System.out.println("After starting Notification service");
}
}catch(Exception e)
{
System.out.println(e.getMessage());
}
return _instance;
}
private static KnowledgeAgent _kagent;
private static RuleEngine _instance;
private static KnowledgeBase _kbase=null;
private static StatelessKnowledgeSession _ksession=null;
}
Now as I'm making changes to DRL file by adding Rule C,Rule D..I've written
applyChangeSet method in Java class.But it is not displaying new
RuleNames.Please suggest me what is the way to applyChangeSet to DRL
file.Does anythng went wrong in above code..
Please suggest me
THanks
--
View this message in context:
http://drools.46999.n3.nabble.com/Unable-to-apply-ChangeSet-to-DRL-file-t...
Sent from the Drools: User forum mailing list archive at
Nabble.com.