Plugging custom TimerService

View: New views
8 Messages — Rating Filter:   Alert me  

Plugging custom TimerService

by Maciek Prochniak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

are there any unintrusive (without recompiling in drools-core ;)) ways
to plug own implementation of TimerService?
Currently configuration is based on enumeration ClockType, which is

It would be nice to be able to pass any object implementing
TimerService, or some factory class.

One of the reasons is that I'd like to have more control over thread
pool used by JdkTimerService. Current implementation allows for
unlimited number of threads, it's also not possible to share thread pool
between different KnowledgeSessions

thx for reply & br
maciek

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

Re: Plugging custom TimerService

by Edson Tirelli-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    Maciek,

    I did not made the implementation pluggable yet due to the complexities involved in the implementation of new clocks and the fact that interface could still change. Particularly, I would like to have a couple more implementations done (including the heart beat based clock and the fact attribute based clock) before I know that the interface is stable enough to enable pluggability.

    Meanwhile, if you would like to contribute your implementation I would happily add it to the drools codebase and release it in the next version. It will certainly help towards the stabilization of the interface.

    Finally, I am working on a more controllable thread pool wrapper, so that we can plug external thread pools into Drools. Check the ExternalExecutorService implementation and its uses. Maybe what we need is to have your implementation also use that. Suggestions welcome.

   Edson
 

2009/10/22 Maciej Prochniak <mpr@...>
Hello,

are there any unintrusive (without recompiling in drools-core ;)) ways
to plug own implementation of TimerService?
Currently configuration is based on enumeration ClockType, which is

It would be nice to be able to pass any object implementing
TimerService, or some factory class.

One of the reasons is that I'd like to have more control over thread
pool used by JdkTimerService. Current implementation allows for
unlimited number of threads, it's also not possible to share thread pool
between different KnowledgeSessions

thx for reply & br
maciek

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



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com

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

Re: Plugging custom TimerService

by Maciek Prochniak :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for answer,

I wasn't able to use ExternalExectorService directly, as it would have to be made into ScheduledExecutorService.
If it implemented ScheduledExecutorService interface, it could be a matter of adding new constructor to JdkTimerService. Meanwhile, I'm attaching my current, a bit simplistExternalTimerService.javaic implementation (big part of code is a
bit refactored code from JdkTimerService)

br,
maciek

Edson Tirelli-4 wrote:
    Maciek,

    I did not made the implementation pluggable yet due to the complexities
involved in the implementation of new clocks and the fact that interface
could still change. Particularly, I would like to have a couple more
implementations done (including the heart beat based clock and the fact
attribute based clock) before I know that the interface is stable enough to
enable pluggability.

    Meanwhile, if you would like to contribute your implementation I would
happily add it to the drools codebase and release it in the next version. It
will certainly help towards the stabilization of the interface.

    Finally, I am working on a more controllable thread pool wrapper, so
that we can plug external thread pools into Drools. Check the
ExternalExecutorService implementation and its uses. Maybe what we need is
to have your implementation also use that. Suggestions welcome.

   Edson


2009/10/22 Maciej Prochniak <mpr@touk.pl>

> Hello,
>
> are there any unintrusive (without recompiling in drools-core ;)) ways
> to plug own implementation of TimerService?
> Currently configuration is based on enumeration ClockType, which is
>
> It would be nice to be able to pass any object implementing
> TimerService, or some factory class.
>
> One of the reasons is that I'd like to have more control over thread
> pool used by JdkTimerService. Current implementation allows for
> unlimited number of threads, it's also not possible to share thread pool
> between different KnowledgeSessions
>
> thx for reply & br
> maciek
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>



--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com

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

is this a bug? import function not supporting varargs?

by Jane James :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi guys,
    I have a question regarding the import function feature in Drools 5.1.0M.

    I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal Bali and tried one of the examples but somehow I couldn't get my rules work with the method that has varargs.

Here's what I have (copied from page 123):

public class ValidationHelper {
    public static void error (RuleContext kcontext, Object... context) {
        KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
        ValidationReport validationReport = (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
        ReportFactory reportFactory = (ReportFactory) knowledgeRuntime.getGlobal("reportFactory");

        kcontext.insertLogical(reportFactory.createMessage(
                Message.Type.ERROR, kcontext.getRule().getName(),
                context));
    }
}


then in my drools file (copied from page 42):
i have

import org.drools.runtime.rule.RuleContext;
import function ValidationHelper.error;
...
rule test
when
  #condition
then
    error(drools)


but when I ran the test, I got error message:

Exception in thread "main" org.drools.runtime.rule.ConsequenceException: [Error: unable to resolve method: ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper) [arglength=1]]

If I remove the parameter Object... context, then everything worked. But I do need the varargs here because I need my error message to be more specific.

Did anyone else encounter the same problems?


thanks!


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

Re: is this a bug? import function not supporting varargs?

by Michael Neale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think there are issues with java5 syntax isms - which varargs is?

On Tue, Nov 3, 2009 at 2:17 PM, Jane James <jane6210@...> wrote:

> Hi guys,
>     I have a question regarding the import function feature in Drools
> 5.1.0M.
>
>     I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal
> Bali and tried one of the examples but somehow I couldn't get my rules work
> with the method that has varargs.
>
> Here's what I have (copied from page 123):
>
> public class ValidationHelper {
>     public static void error (RuleContext kcontext, Object... context) {
>         KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
>         ValidationReport validationReport =
> (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
>         ReportFactory reportFactory = (ReportFactory)
> knowledgeRuntime.getGlobal("reportFactory");
>
>         kcontext.insertLogical(reportFactory.createMessage(
>                 Message.Type.ERROR, kcontext.getRule().getName(),
>                 context));
>     }
> }
>
>
> then in my drools file (copied from page 42):
> i have
>
> import org.drools.runtime.rule.RuleContext;
> import function ValidationHelper.error;
> ...
> rule test
> when
>   #condition
> then
>     error(drools)
>
>
> but when I ran the test, I got error message:
>
> Exception in thread "main" org.drools.runtime.rule.ConsequenceException:
> [Error: unable to resolve method:
> ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)
> [arglength=1]]
>
> If I remove the parameter Object... context, then everything worked. But I
> do need the varargs here because I need my error message to be more
> specific.
>
> Did anyone else encounter the same problems?
>
>
> thanks!
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@...
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>



--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com

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

Re: is this a bug? import function not supporting varargs?

by Jane James :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

  public static void error (RuleContext kcontext, Object... context) {...}

===>Object... context





----- Original Message ----
From: Michael Neale <michael.neale@...>
To: Rules Dev List <rules-dev@...>
Sent: Mon, November 2, 2009 11:56:09 PM
Subject: Re: [rules-dev] is this a bug? import function not supporting varargs?

I think there are issues with java5 syntax isms - which varargs is?

On Tue, Nov 3, 2009 at 2:17 PM, Jane James <jane6210@...> wrote:

> Hi guys,
>     I have a question regarding the import function feature in Drools
> 5.1.0M.
>
>     I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal
> Bali and tried one of the examples but somehow I couldn't get my rules work
> with the method that has varargs.
>
> Here's what I have (copied from page 123):
>
> public class ValidationHelper {
>     public static void error (RuleContext kcontext, Object... context) {
>         KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
>         ValidationReport validationReport =
> (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
>         ReportFactory reportFactory = (ReportFactory)
> knowledgeRuntime.getGlobal("reportFactory");
>
>         kcontext.insertLogical(reportFactory.createMessage(
>                 Message.Type.ERROR, kcontext.getRule().getName(),
>                 context));
>     }
> }
>
>
> then in my drools file (copied from page 42):
> i have
>
> import org.drools.runtime.rule.RuleContext;
> import function ValidationHelper.error;
> ...
> rule test
> when
>   #condition
> then
>     error(drools)
>
>
> but when I ran the test, I got error message:
>
> Exception in thread "main" org.drools.runtime.rule.ConsequenceException:
> [Error: unable to resolve method:
> ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)
> [arglength=1]]
>
> If I remove the parameter Object... context, then everything worked. But I
> do need the varargs here because I need my error message to be more
> specific.
>
> Did anyone else encounter the same problems?
>
>
> thanks!
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@...
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>



--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com

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



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

Re: is this a bug? import function not supporting varargs?

by Michael Neale :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

yes my point is the varargs thing probably will not work.

On Wed, Nov 4, 2009 at 4:59 AM, Jane James <jane6210@...> wrote:

>  public static void error (RuleContext kcontext, Object... context) {...}
>
> ===>Object... context
>
>
>
>
>
> ----- Original Message ----
> From: Michael Neale <michael.neale@...>
> To: Rules Dev List <rules-dev@...>
> Sent: Mon, November 2, 2009 11:56:09 PM
> Subject: Re: [rules-dev] is this a bug? import function not supporting varargs?
>
> I think there are issues with java5 syntax isms - which varargs is?
>
> On Tue, Nov 3, 2009 at 2:17 PM, Jane James <jane6210@...> wrote:
>> Hi guys,
>>     I have a question regarding the import function feature in Drools
>> 5.1.0M.
>>
>>     I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal
>> Bali and tried one of the examples but somehow I couldn't get my rules work
>> with the method that has varargs.
>>
>> Here's what I have (copied from page 123):
>>
>> public class ValidationHelper {
>>     public static void error (RuleContext kcontext, Object... context) {
>>         KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
>>         ValidationReport validationReport =
>> (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
>>         ReportFactory reportFactory = (ReportFactory)
>> knowledgeRuntime.getGlobal("reportFactory");
>>
>>         kcontext.insertLogical(reportFactory.createMessage(
>>                 Message.Type.ERROR, kcontext.getRule().getName(),
>>                 context));
>>     }
>> }
>>
>>
>> then in my drools file (copied from page 42):
>> i have
>>
>> import org.drools.runtime.rule.RuleContext;
>> import function ValidationHelper.error;
>> ...
>> rule test
>> when
>>   #condition
>> then
>>     error(drools)
>>
>>
>> but when I ran the test, I got error message:
>>
>> Exception in thread "main" org.drools.runtime.rule.ConsequenceException:
>> [Error: unable to resolve method:
>> ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)
>> [arglength=1]]
>>
>> If I remove the parameter Object... context, then everything worked. But I
>> do need the varargs here because I need my error message to be more
>> specific.
>>
>> Did anyone else encounter the same problems?
>>
>>
>> thanks!
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev@...
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
>
>
> --
> Michael D Neale
> home: www.michaelneale.net
> blog: michaelneale.blogspot.com
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@...
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@...
> https://lists.jboss.org/mailman/listinfo/rules-dev
>



--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com

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

Re: is this a bug? import function not supporting varargs?

by Michal Bali-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jane,

The varargs feature definitely works with 5.0.1. I haven't tried 5.1.0M.

You can download the working example from http://code.google.com/p/droolsbook/
Download the parent-1.0-examples.zip, extract it and see project validation in droolsBookParent/validation/src/main/resources/validation.drl. To test it you can run the unit test in droolsBookParent/validation/src/test/java/droolsbook/bank/service/impl/ValidationTest

You could also try to put the fuction inside the DRL itself as it is shown in validation.drl (code that is commented out)

BTW the 'Rules Dev List' is not for these type of questions. It is meant for core developers of the Drools platform.

Best regards,
Michal


On Wed, Nov 4, 2009 at 2:44 AM, Michael Neale <michael.neale@...> wrote:
yes my point is the varargs thing probably will not work.

On Wed, Nov 4, 2009 at 4:59 AM, Jane James <jane6210@...> wrote:
>  public static void error (RuleContext kcontext, Object... context) {...}
>
> ===>Object... context
>
>
>
>
>
> ----- Original Message ----
> From: Michael Neale <michael.neale@...>
> To: Rules Dev List <rules-dev@...>
> Sent: Mon, November 2, 2009 11:56:09 PM
> Subject: Re: [rules-dev] is this a bug? import function not supporting varargs?
>
> I think there are issues with java5 syntax isms - which varargs is?
>
> On Tue, Nov 3, 2009 at 2:17 PM, Jane James <jane6210@...> wrote:
>> Hi guys,
>>     I have a question regarding the import function feature in Drools
>> 5.1.0M.
>>
>>     I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal
>> Bali and tried one of the examples but somehow I couldn't get my rules work
>> with the method that has varargs.
>>
>> Here's what I have (copied from page 123):
>>
>> public class ValidationHelper {
>>     public static void error (RuleContext kcontext, Object... context) {
>>         KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
>>         ValidationReport validationReport =
>> (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
>>         ReportFactory reportFactory = (ReportFactory)
>> knowledgeRuntime.getGlobal("reportFactory");
>>
>>         kcontext.insertLogical(reportFactory.createMessage(
>>                 Message.Type.ERROR, kcontext.getRule().getName(),
>>                 context));
>>     }
>> }
>>
>>
>> then in my drools file (copied from page 42):
>> i have
>>
>> import org.drools.runtime.rule.RuleContext;
>> import function ValidationHelper.error;
>> ...
>> rule test
>> when
>>   #condition
>> then
>>     error(drools)
>>
>>
>> but when I ran the test, I got error message:
>>
>> Exception in thread "main" org.drools.runtime.rule.ConsequenceException:
>> [Error: unable to resolve method:
>> ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)
>> [arglength=1]]
>>
>> If I remove the parameter Object... context, then everything worked. But I
>> do need the varargs here because I need my error message to be more
>> specific.
>>
>> Did anyone else encounter the same problems?
>>
>>
>> thanks!
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev@...
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
>
>
> --
> Michael D Neale
> home: www.michaelneale.net
> blog: michaelneale.blogspot.com
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@...
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@...
> https://lists.jboss.org/mailman/listinfo/rules-dev
>



--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com

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


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