Hi Stefan,

> On 27 Apr 2018, at 23:29, Stefan Seifert <[email protected]> wrote:
> 
> i think running scripts directly from the bundle without having to import it 
> into the repository is a big advantage for complex projects.
> i hope this capability mechanism squales well when you have thousands of 
> scripts in your system.

The only extra object we have, compared to a script in the repository, is a 
servlet registration. However, there are two major advantages that this 
architecture brings in terms of performance / flow:
we’ve eliminated repository look-ups for script resolution, reducing the 
pressure on Oak for things that are not actually content
there’s no need to maintain an external ScriptCache [4], with 3 ways of 
invalidation; if the ScriptCache is not needed we again optimise the flow in a 
Sling application by not needing yet another ResourceChangeListener / 
EventHandler 
> 
> on questions concering scripts & java classes accessed from the scripts (e.g. 
> HTL script accessing a sling model):
> - in the current scenario it's required to export all model classes via OSGi 
> to be able to use them from the HTL script
> - is it possibe with this new approach to keep them private to the bundle, 
> and still use them from the scripts included and served from this bundle?
> 
> stefan

True. This was more or less my decision, in order to unify the behaviours of 
the JavaUseProvider [5] and SlingModelsUseProvider [6]. If at some point we 
decide to use this new scripting add-on we can obviously enhance the 
SlingModelsUseProvider to use the script’s bundle class loader for trying to 
load a model. At the same time some of the scripting engines might need to also 
be adapted to work better with this way of resolving scripts.

Regards,
Radu


[4] - 
https://github.com/apache/sling-org-apache-sling-scripting-core/blob/master/src/main/java/org/apache/sling/scripting/core/impl/ScriptCacheImpl.java
 
<https://github.com/apache/sling-org-apache-sling-scripting-core/blob/master/src/main/java/org/apache/sling/scripting/core/impl/ScriptCacheImpl.java>
[5] - 
https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/master/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java
 
<https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/master/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java>
[6] - 
https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/master/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java
 
<https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/master/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java>

Reply via email to