First, you don't need to compie the change set by your self the agent will
do that in applyChangeSet() method.
Some questions that could help to figure out the problem:
1. Which version of drools are you using? (I assume >= 5.1M1)
2. Do you have any stacktrace/log file?
3. Is your cange set pointing to DRL resources. If so, the
agent internally creates kbuilders to compile them. You could have class
loaders problems there. By default the agent logs everything to System.err.
Could you post the output here?
Best,
On Fri, Jun 25, 2010 at 9:59 AM, mmarmol <marcelo.marmol(a)gmail.com> wrote:
Hi, I have managed to install Drools-core and Drools-compiler in my Equinox
osgi environment, I can compile rules and execute them just fine, I was
just
wandering how to configure a KnowledgeAgent using
KnowledgeBuilderFactoryService and KnowledgeBaseFactoryService. I managed
to
configure one but i am not able to reload rules when they change at
runtime.
I have started ResourceChangeScannerService and
ResourceChangeNotifierService, changeset related to the rules file gets
read
but no change gets implemented. An idea?
Here is the code:
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
ServiceReference serviceRef = bc
.getServiceReference(ServiceRegistry.class.getName());
ServiceRegistry registry = (ServiceRegistry)
bc.getService(serviceRef);
KnowledgeBuilderFactoryService
knowledgeBuilderFactoryService = registry
.get(KnowledgeBuilderFactoryService.class);
KnowledgeBaseFactoryService knowledgeBaseFactoryService =
registry
.get(KnowledgeBaseFactoryService.class);
ResourceFactoryService resourceFactoryService = registry
.get(ResourceFactoryService.class);
KnowledgeBuilderConfiguration kbConf =
knowledgeBuilderFactoryService
.newKnowledgeBuilderConfiguration(null,
getClass()
.getClassLoader());
KnowledgeBuilder kbuilder = knowledgeBuilderFactoryService
.newKnowledgeBuilder(kbConf);
ResourceFactoryService resource = resourceFactoryService;
kbuilder.add(resource.newFileSystemResource(filePath),
ResourceType.CHANGE_SET);
if (kbuilder.hasErrors()) {
System.out.println(kbuilder.getErrors());
throw new
RuntimeException(kbuilder.getErrors().toString());
}
KnowledgeBaseConfiguration kbaseConf =
knowledgeBaseFactoryService
.newKnowledgeBaseConfiguration(null,
getClass()
.getClassLoader());
KnowledgeBase kbase = knowledgeBaseFactoryService
.newKnowledgeBase(kbaseConf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
KnowledgeAgentConfiguration aconf =
KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
aconf.setProperty("drools.agent.scanDirectories",
"true");
aconf.setProperty("drools.agent.scanResources",
"true");
aconf.setProperty("drools.agent.newInstance",
"false");
kagent = KnowledgeAgentFactory.newKnowledgeAgent(
"CoreDroolsAgent",kbase,
aconf);
kagent.applyChangeSet(resource.newFileSystemResource(filePath));
Thanks in advance!
Cheers
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/KnowledgeAgent-and-OS...
Sent from the Drools - User mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti