[rules-users] Detect changes in rules at runtime

rviswanathan v_ramakrishnan at hotmail.com
Thu Jul 9 14:00:20 EDT 2009


Thank you. I was able to use the resource scanner to poll and get the
changes. 

I am also trying to see the possibility of using a push based approach,
instead of the polling. I see the classes for the ResourceChangeMonitor,
ResourceChangeNotifier and ResourceChangeListener, but I am not sure how I
should go about using these.

I tried to use the following method on the ResourceChangeNotifier by passing
in a listener implementation and the ChangeSet as the resource - but what do
I implement inside this method? 

void subscribeResourceChangeListener(ResourceChangeListener listener,
                                     Resource resource)


Is this approach correct? 

Thanks
Ram



kitc25 wrote:
> 
> Hello,
> 
> Yes, is it possible to detect the changing in rules in Java and to
> re-generate the newest knowledge package, go visit the Droosl Expert
> documentation from Jboss, in the KnowledgeAgent section.
> 
> Kit
> 
> rviswanathan wrote:
>> 
>> Hi 
>> 
>> I am using Guvnor for editing my business rules. I am able to write a
>> test program in java that would fire one sample rule that I have created
>> in guvnor. 
>> 
>> public static final void main(String[] args) {
>> 	try {
>> 
>> 		// load up the knowledge base
>> 		//KnowledgeBase kbase = readKnowledgeBase();
>> 		KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent(
>> "MyAgent" );
>>         		kagent.applyChangeSet(
>> 		ResourceFactory.newFileResource("C:/Test/changeset.xml"));
>> 		KnowledgeBase kbase1 = kagent.getKnowledgeBase(); 
>> 		StatefulKnowledgeSession ksession = 
>>                                kbase1.newStatefulKnowledgeSession();
>> 		Message message = new Message();
>> 		message.setMessage("Hello World");
>> 		message.setStatus(Message.HELLO);
>> 		ksession.insert(message);
>> 		ksession.fireAllRules();
>> 		ksession.dispose();
>> 	}
>> 	catch (Exception ex) {
>> 			ex.printStackTrace();
>> 	}
>> }
>> 
>> Now I am trying to see if I would be able to detect changes in the rules
>> that I edit in Guvnor at runtime. What I am trying to do is to edit one
>> of the rules and save it, and I need this change to be picked up
>> automatically by my java application.
>> 
>> Is this possible? How do I do this? 
>> 
>> Thanks 
>> Ram
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Detect-changes-in-rules-at-runtime-tp24379025p24414998.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list