Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0037643
TypeCategorySeverityReproducibilityDate SubmittedLast Update
feature request[Openbravo ERP] A. Platformminorhave not tried2018-01-15 18:242018-02-22 18:18
ReporterAugustoMauchView Statuspublic 
Assigned ToAugustoMauch 
PrioritynormalResolutionfixedFixed in Version3.0PR18Q2
StatusclosedFix in branchFixed in SCM revision120a6a75f9b7
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tocaristu
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0037643: Improve the use of the ScriptEngine by reusing engine instance

DescriptionCurrently, each time that we want to eval a javascript expression using the ScriptEngine, we are create a new ScriptEngineManager and a new ScriptEngine instance. Then the bindings are set to the instance, and the expression is evaluated.

This can be improved by sharing a single instance of the Script, since creating the ScriptEngine can sometimes be expensive, and the class is thread safe (see [1])

[1] https://stackoverflow.com/a/30159424 [^]
Steps To Reproduce-
Proposed SolutionInstead of creating a new ScriptEngine instance each time a javascript expression needs to be evaluated, reuse the same one and set the bindings to each evaluation, instead of to the engine itself.
TagsPerformance
Attached Files

- Relationships Relation Graph ] Dependency Graph ]

-  Notes
(0101727)
hgbot (developer)
2018-01-16 17:17

Repository: erp/devel/pi
Changeset: 120a6a75f9b757f20a7434d5cbb9d0cfe271a831
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Tue Jan 16 17:16:51 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/120a6a75f9b757f20a7434d5cbb9d0cfe271a831 [^]

Fixes issue 37643: OBScriptEngine can be used to evaluate javascript scripts

There were four classes that were creating a new instance of ScriptEngine each time they needed to evaluate a javascript script. This was not the better way
to do it, since creating a ScriptEngine instance can be expensive, and that class is thread safety if properly used (i.e. by setting the bindings to each
evaluation instead of to the script engine itself).

A new singleton class has been added, OBScriptEngine, that is now used by all the classes that need to evaluate javascript scripts.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/ParameterUtils.java
M modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewFieldHandler.java
M modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorDefaultFilterActionHandler.java
M src/org/openbravo/base/expression/Evaluator.java
A src/org/openbravo/base/expression/OBScriptEngine.java
---
(0101796)
hgbot (developer)
2018-01-19 14:33

Repository: erp/devel/pi
Changeset: 8dbb68df297c6ae5ad18149c9389ff399252b422
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Fri Jan 19 14:15:15 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/8dbb68df297c6ae5ad18149c9389ff399252b422 [^]

related to issue 37643: avoid definining getInstance() method as synchronized

  The instance variable is now initialized on first class load instead.

---
M src/org/openbravo/base/expression/OBScriptEngine.java
---
(0101797)
caristu (developer)
2018-01-19 14:34

Code reviewed + tested OK.
(0102659)
hudsonbot (developer)
2018-02-22 18:18

A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/980a6ad5bbf5 [^]
Maturity status: Test
(0102667)
hudsonbot (developer)
2018-02-22 18:18

A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/980a6ad5bbf5 [^]
Maturity status: Test

- Issue History
Date Modified Username Field Change
2018-01-15 18:24 AugustoMauch New Issue
2018-01-15 18:24 AugustoMauch Assigned To => AugustoMauch
2018-01-15 18:24 AugustoMauch Modules => Core
2018-01-15 18:24 AugustoMauch Triggers an Emergency Pack => No
2018-01-16 17:17 hgbot Checkin
2018-01-16 17:17 hgbot Note Added: 0101727
2018-01-16 17:17 hgbot Status new => resolved
2018-01-16 17:17 hgbot Resolution open => fixed
2018-01-16 17:17 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/120a6a75f9b757f20a7434d5cbb9d0cfe271a831 [^]
2018-01-16 18:16 caristu Review Assigned To => caristu
2018-01-19 07:59 alostale Tag Attached: Performance
2018-01-19 14:33 hgbot Checkin
2018-01-19 14:33 hgbot Note Added: 0101796
2018-01-19 14:34 caristu Note Added: 0101797
2018-01-19 14:34 caristu Status resolved => closed
2018-01-19 14:34 caristu Fixed in Version => 3.0PR18Q1
2018-01-22 11:17 caristu Fixed in Version 3.0PR18Q1 => 3.0PR18Q2
2018-02-22 18:18 hudsonbot Checkin
2018-02-22 18:18 hudsonbot Note Added: 0102659
2018-02-22 18:18 hudsonbot Checkin
2018-02-22 18:18 hudsonbot Note Added: 0102667


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker