2012/3/2 Jian Feng Ng <jng42@csc.com>
I tried but it doesn't seem to work. I am using UrlResource for the KnowledgeAgent.

kagent.getKnowledgeBase().addEventListener(new foo());
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();

But when the package is rescan, foo seems to be gone as kagent rebuilds knowledgebase?


The Knowledge Agent builds a new Knowledge Base when resources change. You should set up a listener for the Agent to detect KnowledgeBaseUpdatedEvent and other Agent events.
-W
 


-----rules-users-bounces@lists.jboss.org wrote: -----
To: Rules Users List <rules-users@lists.jboss.org>
From: Wolfgang Laun
Sent by: rules-users-bounces@lists.jboss.org
Date: 03/01/2012 05:21PM
Subject: Re: [rules-users] Adding change/event listener to package

As with all Listeners in Java, you write a class implementing the methods defined by the interface. The parameter types tell you about what is passed to the respective call.

class Foo implements KnowledgeBaseEventListener {
    public void afterRuleAdded(AfterRuleAddedEvent event){
        if( "WatchedPackage".equals( event.getRule().getPackageName() ){

        }
    }

    //...
}

A new Foo is attached to the kSession object - that's all.

-W

2012/3/1 Jian Feng Ng <jng42@csc.com>:
> I saw many interfaces, but the problem is I do not know how to 'use' them.
> Is there a tutorial or example codes somewhere?
>
>
>
> -----rules-users-bounces@lists.jboss.org wrote: -----
>
> To: Rules Users List <rules-users@lists.jboss.org>
> From: Wolfgang Laun
> Sent by: rules-users-bounces@lists.jboss.org
> Date: 03/01/2012 04:38PM
> Subject: Re: [rules-users] Adding change/event listener to package
>
> See the javadoc on a lot of interfaces in org.drools.event.knowledgebase.
> The expert manual has a section on the "Event Model" showing how to attach a
> listener to the knowledge session (not a package).
> -W
>
>
>
> 2012/3/1 Jian Feng Ng <jng42@csc.com>
>>
>> I wish to add a listener to a package, so that my application can do
>> something else when there is any creation or deletion of rules in the
>> package. May I know how can I do this?
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> CSC • Please consider the environment before printing this e-mail.
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery. NOTE: Regardless of content, this e-mail shall not operate to bind
> CSC to any order or other contract unless pursuant to explicit written
> agreement or government initiative expressly permitting the use of e-mail
> for such purpose • CSC Technology Singapore Pte. Ltd. • Registered Office:
> 20 Anson Road, #11-01 Twenty Anson Singapore 079912 • Registered in
> Singapore No: 198400958N
> _______________________________________________
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


CSC • Please consider the environment before printing this e-mail.

This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose
 • CSC Technology Singapore Pte. Ltd. • Registered Office: 20 Anson Road, #11-01 Twenty Anson Singapore 079912 • Registered in Singapore No: 198400958N

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users