[jboss-jira] [JBoss JIRA] (JBRULES-2700) Allow setting a global variable (for example a service) which can be used by the score rules

Geoffrey De Smet (JIRA) jira-events at lists.jboss.org
Fri Aug 17 08:56:15 EDT 2012


    [ https://issues.jboss.org/browse/JBRULES-2700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12712214#comment-12712214 ] 

Geoffrey De Smet commented on JBRULES-2700:
-------------------------------------------

Solution proposal D: Notifying the globals at the beginning and ending of workingMemory creation (not solve())
I don't prefer this proposal, because it requires the global instances to implement a custom interface, so you can't reuse JDCB's datasource directly etc.

Solution proposal E: Notify a WorkingMemoryManager interface from DroolsScoreDirectorFactory every time a WM is created or destroyed.
This is basically proposal B. I think I prefer this one.

How to do proposal E:
DroolsScoreDirector must delegate WM creation and destruction to DroolsScoreDirectorFactory
DroolsScoreDirectorFactory can have a WorkingMemoryManager instance.
Upon WM creation and destruction, DroolsScoreDirectorFactory calls WorkingMemoryManager.
This gives WorkingMemoryManager an opportunity to add globals (and whatnot) to the WM during creation and cleanup during destruction.
                
> Allow setting a global variable (for example a service) which can be used by the score rules
> --------------------------------------------------------------------------------------------
>
>                 Key: JBRULES-2700
>                 URL: https://issues.jboss.org/browse/JBRULES-2700
>             Project: Drools
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>          Components: drools-planner
>            Reporter: Wouter Horré
>            Assignee: Geoffrey De Smet
>
> Currently, it is not possible to set a global variable in the working memory used by the solver. If a scoring rule needs an external helper for calculating scores (e.g. a dependency injected with OSGi DS), a workaround using a static variable in some class accessible by the scoring rules is needed.
> The easiest implementation is probably a new method in the Solver interface: // Impossible
> public WorkingMemory getWorkingMemory();
> which provides access to the working memory used by the solver.
> => Impossible because the number of WorkingMemory equals the number of threads being used by Planner, and sometimes they are reset.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jboss-jira mailing list