You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2018/09/28 14:30:44 UTC

[sling-whiteboard] branch master updated: refactor

This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new e3cfb2a  refactor
e3cfb2a is described below

commit e3cfb2a8b3f9222b554debabde4bf211f41fc962
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Fri Sep 28 16:29:08 2018 +0200

    refactor
    
    * extracted IT in separate module (need to re-add jacoco)
    * made sure BRU dependencies are obtained with the correct bundle context
---
 .../pom.xml                                        |   6 +
 .../2.0.0/hello.html                               |   1 +
 .../README.md                                      |  18 ++
 .../pom.xml                                        | 213 ++------------
 .../junit/teleporter/customizers/ITCustomizer.java |   0
 .../resolver/internal/AbstractEndpointIT.java      |   0
 .../resolver/internal/BundledScriptTrackerIT.java  |   0
 .../scripting/resolver/internal/EndpointIT.java    |   0
 .../scripting/resolver/internal/ScriptMatchIT.java |   2 -
 .../src/test/provisioning/it-model.txt             |  35 +++
 .../org-apache-sling-scripting-resolver/pom.xml    | 305 +--------------------
 .../scripting/resolver/BundledRenderUnit.java      | 114 ++++++++
 .../internal/AbstractBundledRenderUnit.java        | 133 +++++++++
 .../resolver/internal/BundledScriptFinder.java     |   5 +-
 .../resolver/internal/BundledScriptServlet.java    |  42 ++-
 ...ScriptEngineExecutable.java => Executable.java} |  15 +-
 .../resolver/internal/PrecompiledScript.java       |  18 +-
 .../sling/scripting/resolver/internal/Script.java  |  10 +-
 .../resolver/internal/ScriptContextProvider.java   |  10 +-
 ...riptEngineExecutable.java => package-info.java} |  20 +-
 scripting-resolver/pom.xml                         |   5 +-
 .../sling-org-apache-sling-scripting-sightly       |   2 +-
 22 files changed, 383 insertions(+), 571 deletions(-)

diff --git a/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml b/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml
index c4be823..e7342e5 100644
--- a/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml
+++ b/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/pom.xml
@@ -138,6 +138,12 @@
             <version>1.0.54-1.4.0</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.settings</artifactId>
+            <version>1.3.10</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
 </project>
diff --git a/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html b/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html
index 7840f51..670e2cd 100644
--- a/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html
+++ b/scripting-resolver/examples/org-apache-sling-scripting-examplebundle-precompiled/src/main/scripts/javax.script/org.apache.sling.scripting.examplebundle.precompiled.hello/2.0.0/hello.html
@@ -18,3 +18,4 @@
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
 <h2>We're testing some serious scripting here in Version 2</h2>
 <span data-sly-resource="${ @ selectors='h'}"></span> <span data-sly-resource="${ @ selectors='w'}"></span>
+<div data-sly-use.slingSettings="org.apache.sling.settings.SlingSettingsService">${slingSettings.slingId}</div>
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver-it/README.md b/scripting-resolver/org-apache-sling-scripting-resolver-it/README.md
new file mode 100644
index 0000000..91fd661
--- /dev/null
+++ b/scripting-resolver/org-apache-sling-scripting-resolver-it/README.md
@@ -0,0 +1,18 @@
+Apache Sling Scripting Resolver (WIP, name not final)
+====
+
+## Integration Tests
+
+To run the integration tests do:
+
+```
+mvn clean verify -Pit
+```
+
+## Example
+
+To play around with a sling instance on localhost port 8080 (override with -Dhttp.port=<port>) that has the [examples](../examples) installed run:
+
+```
+mvn clean verify -Pexample
+``` 
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/pom.xml b/scripting-resolver/org-apache-sling-scripting-resolver-it/pom.xml
similarity index 60%
copy from scripting-resolver/org-apache-sling-scripting-resolver/pom.xml
copy to scripting-resolver/org-apache-sling-scripting-resolver-it/pom.xml
index 40c5c9d..6e36856 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/pom.xml
+++ b/scripting-resolver/org-apache-sling-scripting-resolver-it/pom.xml
@@ -28,9 +28,9 @@
     </parent>
     <modelVersion>4.0.0</modelVersion>
 
-    <artifactId>org.apache.sling.scripting.resolver</artifactId>
+    <artifactId>org.apache.sling.scripting.resolver.it</artifactId>
     <version>0.0.1-SNAPSHOT</version>
-    <packaging>bundle</packaging>
+    <packaging>slingstart</packaging>
 
     <properties>
         <sling.java.version>8</sling.java.version>
@@ -40,138 +40,59 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
+                <!-- the Sling instance is provisioned from the model in src/test/provisioning/it-model.txt -->
+                <groupId>org.apache.sling</groupId>
+                <artifactId>slingstart-maven-plugin</artifactId>
+                <version>1.7.16</version>
                 <extensions>true</extensions>
-                <executions>
-                    <execution>
-                        <id>scr-metadata</id>
-                        <goals>
-                            <goal>manifest</goal>
-                        </goals>
-                    </execution>
-                </executions>
                 <configuration>
-                    <exportScr>true</exportScr>
+                    <usePomDependencies>true</usePomDependencies>
                 </configuration>
             </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>findbugs-maven-plugin</artifactId>
-                <version>3.0.3</version>
-                <configuration>
-                    <effort>Max</effort>
-                    <xmlOutput>true</xmlOutput>
-                    <excludeFilterFile>src/test/resources/findbugs-exclude.xml</excludeFilterFile>
-                </configuration>
-                <executions>
-                    <execution>
-                        <id>find-bugs</id>
-                        <phase>process-classes</phase>
-                        <goals>
-                            <goal>check</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
         </plugins>
     </build>
 
     <dependencies>
         <dependency>
-            <groupId>biz.aQute.bnd</groupId>
-            <artifactId>biz.aQute.bndlib</artifactId>
-            <version>3.5.0</version>
-        </dependency>
-        <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.api</artifactId>
-            <version>2.16.4</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.osgi</artifactId>
-            <version>2.4.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>javax.servlet</groupId>
-            <artifactId>javax.servlet-api</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>osgi.core</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>osgi.cmpn</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.annotation.versioning</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <version>3.7</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.6</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
+            <artifactId>org.apache.sling.scripting.resolver</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.scripting.api</artifactId>
-            <version>2.2.0</version>
+            <artifactId>org.apache.sling.scripting.sightly</artifactId>
+            <version>1.0.55-1.4.0-exp-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.scripting.core</artifactId>
-            <version>2.0.54</version>
-            <scope>provided</scope>
-        </dependency>
-        <!-- TESTING -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.examplebundle</artifactId>
             <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.examplebundle.precompiled</artifactId>
             <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.examplebundle.classic</artifactId>
             <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.scripting.examplebundle.hi</artifactId>
             <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- TESTING -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -199,18 +120,6 @@
             <version>1.0.6</version>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-            <version>2.13.0</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.powermock</groupId>
-            <artifactId>powermock-reflect</artifactId>
-            <version>1.6.5</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
     <profiles>
@@ -274,91 +183,9 @@
                         </configuration>
                     </plugin>
                     <plugin>
-                        <groupId>org.jacoco</groupId>
-                        <artifactId>jacoco-maven-plugin</artifactId>
-                        <version>${jacoco.maven.plugin.version}</version>
-                        <executions>
-                            <execution>
-                                <id>prepare-agent</id>
-                                <goals>
-                                    <goal>prepare-agent</goal>
-                                </goals>
-                                <configuration>
-                                    <destFile>${project.build.directory}/jacoco-unit.exec</destFile>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>prepare-agent-integration</id>
-                                <goals>
-                                    <goal>prepare-agent-integration</goal>
-                                </goals>
-                                <configuration>
-                                    <propertyName>jacoco.agent</propertyName>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>merge-reports</id>
-                                <phase>verify</phase>
-                                <goals>
-                                    <goal>merge</goal>
-                                </goals>
-                                <configuration>
-                                    <fileSets>
-                                        <fileSet>
-                                            <directory>${project.build.directory}</directory>
-                                            <includes>
-                                                <include>jacoco-unit.exec</include>
-                                                <include>jacoco-it.exec</include>
-                                            </includes>
-                                        </fileSet>
-                                    </fileSets>
-                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>final-report</id>
-                                <phase>verify</phase>
-                                <goals>
-                                    <goal>report</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>check-coverage</id>
-                                <goals>
-                                    <goal>check</goal>
-                                </goals>
-                                <configuration>
-                                    <rules>
-                                        <rule>
-                                            <element>BUNDLE</element>
-                                            <limits>
-                                                <limit>
-                                                    <counter>INSTRUCTION</counter>
-                                                    <value>COVEREDRATIO</value>
-                                                    <minimum>0.80</minimum>
-                                                </limit>
-                                            </limits>
-                                        </rule>
-                                        <rule>
-                                            <element>CLASS</element>
-                                            <limits>
-                                                <limit>
-                                                    <counter>INSTRUCTION</counter>
-                                                    <value>COVEREDRATIO</value>
-                                                    <minimum>0.80</minimum>
-                                                </limit>
-                                            </limits>
-                                        </rule>
-                                    </rules>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
                         <!-- the Sling instance is provisioned from the model in src/test/provisioning/it-model.txt -->
                         <groupId>org.apache.sling</groupId>
                         <artifactId>slingstart-maven-plugin</artifactId>
-                        <version>1.7.16</version>
                         <extensions>true</extensions>
                         <executions>
                             <execution>
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java
similarity index 100%
rename from scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java
rename to scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/junit/teleporter/customizers/ITCustomizer.java
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/AbstractEndpointIT.java b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/AbstractEndpointIT.java
similarity index 100%
rename from scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/AbstractEndpointIT.java
rename to scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/AbstractEndpointIT.java
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/BundledScriptTrackerIT.java b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/BundledScriptTrackerIT.java
similarity index 100%
rename from scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/BundledScriptTrackerIT.java
rename to scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/BundledScriptTrackerIT.java
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/EndpointIT.java b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/EndpointIT.java
similarity index 100%
rename from scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/EndpointIT.java
rename to scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/EndpointIT.java
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/ScriptMatchIT.java b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/ScriptMatchIT.java
similarity index 99%
rename from scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/ScriptMatchIT.java
rename to scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/ScriptMatchIT.java
index 3b7e569..4dfc6d5 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/test/java/org/apache/sling/scripting/resolver/internal/ScriptMatchIT.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/java/org/apache/sling/scripting/resolver/internal/ScriptMatchIT.java
@@ -18,8 +18,6 @@
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 package org.apache.sling.scripting.resolver.internal;
 
-import java.net.URI;
-
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.Header;
 import org.apache.http.HttpResponse;
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/provisioning/it-model.txt b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/provisioning/it-model.txt
new file mode 100644
index 0000000..9cef862
--- /dev/null
+++ b/scripting-resolver/org-apache-sling-scripting-resolver-it/src/test/provisioning/it-model.txt
@@ -0,0 +1,35 @@
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+
+[feature name=scripting-resolver-it]
+
+# Dependencies
+[artifacts]
+  org.apache.sling/org.apache.sling.starter/11-SNAPSHOT/slingstart
+  org.apache.sling/org.apache.sling.scripting.sightly
+  org.apache.sling/org.apache.sling.scripting.resolver
+  org.apache.sling/org.apache.sling.scripting.examplebundle
+  org.apache.sling/org.apache.sling.scripting.examplebundle.precompiled
+  org.apache.sling/org.apache.sling.scripting.examplebundle.classic
+  org.apache.sling/org.apache.sling.scripting.examplebundle.hi
+  org.apache.sling/org.apache.sling.junit.core/1.0.26
+
+[configurations]
+  org.apache.sling.engine.impl.SlingMainServlet
+    sling.trace.allow=B"true"
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/pom.xml b/scripting-resolver/org-apache-sling-scripting-resolver/pom.xml
index 40c5c9d..e8552a3 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/pom.xml
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/pom.xml
@@ -84,6 +84,11 @@
             <version>3.5.0</version>
         </dependency>
         <dependency>
+            <groupId>org.jetbrains</groupId>
+            <artifactId>annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
             <version>2.16.4</version>
@@ -150,56 +155,8 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.scripting.examplebundle</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.scripting.examplebundle.precompiled</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.scripting.examplebundle.classic</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.scripting.examplebundle.hi</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.junit.teleporter</artifactId>
-            <version>1.0.16</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.clients</artifactId>
-            <version>1.1.12</version>
-            <scope>test</scope>
-        </dependency>
 
         <dependency>
-            <groupId>org.jsoup</groupId>
-            <artifactId>jsoup</artifactId>
-            <version>1.7.3</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.rules</artifactId>
-            <version>1.0.6</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
             <version>2.13.0</version>
@@ -213,256 +170,4 @@
         </dependency>
     </dependencies>
 
-    <profiles>
-        <profile>
-            <id>it</id>
-            <properties>
-                <http.host>localhost</http.host>
-                <sling.vm.options>-Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true</sling.vm.options>
-            </properties>
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.codehaus.mojo</groupId>
-                        <artifactId>build-helper-maven-plugin</artifactId>
-                        <executions>
-                            <execution>
-                                <id>reserve-network-port</id>
-                                <goals>
-                                    <!-- pre-integration-test is too late -->
-                                    <goal>reserve-network-port</goal>
-                                </goals>
-                                <phase>process-resources</phase>
-                                <configuration>
-                                    <portNames>
-                                        <portName>http.port.testing</portName>
-                                    </portNames>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-surefire-plugin</artifactId>
-                        <configuration>
-                            <argLine>@{argLine}</argLine>
-                        </configuration>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-failsafe-plugin</artifactId>
-                        <executions>
-                            <execution>
-                                <id>integration-test</id>
-                                <phase>integration-test</phase>
-                                <goals>
-                                    <goal>integration-test</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>verify</id>
-                                <phase>integration-test</phase>
-                                <goals>
-                                    <goal>verify</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                        <configuration>
-                            <systemPropertyVariables>
-                                <launchpad.http.server.url>http://${http.host}:${http.port.testing}/</launchpad.http.server.url>
-                            </systemPropertyVariables>
-                        </configuration>
-                    </plugin>
-                    <plugin>
-                        <groupId>org.jacoco</groupId>
-                        <artifactId>jacoco-maven-plugin</artifactId>
-                        <version>${jacoco.maven.plugin.version}</version>
-                        <executions>
-                            <execution>
-                                <id>prepare-agent</id>
-                                <goals>
-                                    <goal>prepare-agent</goal>
-                                </goals>
-                                <configuration>
-                                    <destFile>${project.build.directory}/jacoco-unit.exec</destFile>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>prepare-agent-integration</id>
-                                <goals>
-                                    <goal>prepare-agent-integration</goal>
-                                </goals>
-                                <configuration>
-                                    <propertyName>jacoco.agent</propertyName>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>merge-reports</id>
-                                <phase>verify</phase>
-                                <goals>
-                                    <goal>merge</goal>
-                                </goals>
-                                <configuration>
-                                    <fileSets>
-                                        <fileSet>
-                                            <directory>${project.build.directory}</directory>
-                                            <includes>
-                                                <include>jacoco-unit.exec</include>
-                                                <include>jacoco-it.exec</include>
-                                            </includes>
-                                        </fileSet>
-                                    </fileSets>
-                                    <destFile>${project.build.directory}/jacoco.exec</destFile>
-                                </configuration>
-                            </execution>
-                            <execution>
-                                <id>final-report</id>
-                                <phase>verify</phase>
-                                <goals>
-                                    <goal>report</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>check-coverage</id>
-                                <goals>
-                                    <goal>check</goal>
-                                </goals>
-                                <configuration>
-                                    <rules>
-                                        <rule>
-                                            <element>BUNDLE</element>
-                                            <limits>
-                                                <limit>
-                                                    <counter>INSTRUCTION</counter>
-                                                    <value>COVEREDRATIO</value>
-                                                    <minimum>0.80</minimum>
-                                                </limit>
-                                            </limits>
-                                        </rule>
-                                        <rule>
-                                            <element>CLASS</element>
-                                            <limits>
-                                                <limit>
-                                                    <counter>INSTRUCTION</counter>
-                                                    <value>COVEREDRATIO</value>
-                                                    <minimum>0.80</minimum>
-                                                </limit>
-                                            </limits>
-                                        </rule>
-                                    </rules>
-                                </configuration>
-                            </execution>
-                        </executions>
-                    </plugin>
-                    <plugin>
-                        <!-- the Sling instance is provisioned from the model in src/test/provisioning/it-model.txt -->
-                        <groupId>org.apache.sling</groupId>
-                        <artifactId>slingstart-maven-plugin</artifactId>
-                        <version>1.7.16</version>
-                        <extensions>true</extensions>
-                        <executions>
-                            <execution>
-                                <id>prepare-launchpad-package</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>prepare-package</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>build-launchpad-package</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>package</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>start-container-before-IT</id>
-                                <goals>
-                                    <goal>start</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>stop-container-after-IT</id>
-                                <goals>
-                                    <goal>stop</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                        <configuration>
-                            <usePomDependencies>true</usePomDependencies>
-                            <attachArtifact>false</attachArtifact>
-                             <!-- <shouldBlockUntilKeyIsPressed>true</shouldBlockUntilKeyIsPressed> -->
-                            <servers>
-                                <server>
-                                    <id>testinstance</id>
-                                    <port>${http.port.testing}</port>
-                                    <vmOpts>${sling.vm.options}</vmOpts>
-                                    <debug>${jacoco.agent}</debug>
-                                </server>
-                            </servers>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-        <profile>
-            <id>example</id>
-            <properties>
-                <http.host>localhost</http.host>
-                <http.port>8080</http.port>
-                <sling.vm.options>-Xmx1024m -XX:MaxPermSize=256m -Djava.awt.headless=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000</sling.vm.options>
-            </properties>
-            <build>
-                <plugins>
-                    <plugin>
-                        <!-- the Sling instance is provisioned from the model in src/test/provisioning/it-model.txt -->
-                        <groupId>org.apache.sling</groupId>
-                        <artifactId>slingstart-maven-plugin</artifactId>
-                        <version>1.7.16</version>
-                        <extensions>true</extensions>
-                        <executions>
-                            <execution>
-                                <id>prepare-launchpad-package</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>prepare-package</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>build-launchpad-package</id>
-                                <phase>pre-integration-test</phase>
-                                <goals>
-                                    <goal>package</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <id>start-container-before-IT</id>
-                                <goals>
-                                    <goal>start</goal>
-                                </goals>
-                            </execution>
-                            <execution>
-                                <goals>
-                                    <goal>stop</goal>
-                                </goals>
-                            </execution>
-                        </executions>
-                        <configuration>
-                            <usePomDependencies>true</usePomDependencies>
-                            <attachArtifact>false</attachArtifact>
-                            <shouldBlockUntilKeyIsPressed>true</shouldBlockUntilKeyIsPressed>
-                            <servers>
-                                <server>
-                                    <id>exampleinstance</id>
-                                    <port>${http.port}</port>
-                                    <vmOpts>${sling.vm.options}</vmOpts>
-                                </server>
-                            </servers>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
-
 </project>
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/BundledRenderUnit.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/BundledRenderUnit.java
new file mode 100644
index 0000000..01ee566
--- /dev/null
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/BundledRenderUnit.java
@@ -0,0 +1,114 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements.  See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership.  The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License.  You may obtain a copy of the License at
+ ~
+ ~   http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied.  See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+package org.apache.sling.scripting.resolver;
+
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.annotation.versioning.ProviderType;
+import org.osgi.framework.Bundle;
+
+/**
+ * <p>
+ * A {@code BundledRenderUnit} represents a pre-packaged script or precompiled script that will be executed in order to render a
+ * {@link org.apache.sling.api.SlingHttpServletRequest}.
+ * </p>
+ * <p>
+ * If the current {@link org.apache.sling.api.SlingHttpServletRequest} is served by a {@code BundledRenderUnit}, the
+ * {@code org.apache.sling.scripting.resolver} will set the {@code BundledRenderUnit} in the {@link javax.script.Bindings} map associated to the request,
+ * under the {@link #VARIABLE} key.
+ * </p>
+ */
+@ProviderType
+public interface BundledRenderUnit {
+
+    /**
+     * The variable available in the {@link javax.script.Bindings} associated to a {@link org.apache.sling.api.SlingHttpServletRequest}
+     * if that request is served by a {@code BundledRenderUnit}.
+     */
+    String VARIABLE = BundledRenderUnit.class.getName();
+
+    /**
+     * In case this {@code BundledRenderUnit} wraps a precompiled script, this method will return an instance of that object.
+     *
+     * @return a precompiled unit, if {@code this} unit wraps a precompiled script; {@code null} otherwise
+     */
+    @Nullable
+    default Object getUnit() {
+        return null;
+    }
+
+    /**
+     * Returns the name of {@code this BundledRenderUnit}. This can be the name of the wrapped script or precompiled script.
+     *
+     * @return the name {@code this BundledRenderUnit}
+     */
+    @NotNull String getName();
+
+    /**
+     * Returns an instance of the {@link ScriptEngine} that can execute the wrapped script or precompiled script, if the latter needs a
+     * specific runtime.
+     *
+     * @return an instance of the script's or precompiled script's associated {@link ScriptEngine}
+     */
+    @NotNull ScriptEngine getScriptEngine();
+
+    /**
+     * Returns the {@link Bundle} in which the script or precompiled script is packaged. This method can be useful for getting an
+     * instance of the bundle's classloader, when needed to load dependencies at run time. To do so the following code example can help:
+     *
+     * <pre>
+     * Bundle bundle = bundledRenderUnit.getBundle();
+     * Classloader bundleClassloader = bundle.adapt(BundleWiring.class).getClassLoader();
+     * </pre>
+     */
+    @NotNull Bundle getBundle();
+
+    /**
+     * Provided a {@link ScriptContext}, this method will execute / evaluate the wrapped script or precompiled script.
+     *
+     * @param context the {@link ScriptContext}
+     * @throws ScriptException if the execution leads to an error
+     */
+    void eval(@NotNull ScriptContext context) throws ScriptException;
+
+    /**
+     * Retrieves an OSGi runtime dependency of the wrapped script identified by the passed {@code className} parameter.
+     *
+     * @param className     the fully qualified class name
+     * @param <ServiceType> the expected service type
+     * @return an instance of the {@link ServiceType} or {@code null}
+     */
+    @Nullable <ServiceType> ServiceType getService(@NotNull String className);
+
+    /**
+     * Retrieves multiple instances of an OSGi runtime dependency of the wrapped script identified by the passed {@code className}
+     * parameter, filtered according to the passed {@code filter}.
+     *
+     * @param className     the fully qualified class name
+     * @param filter        a filter expression or {@code null} if all the instances should be returned; for more details about the {@code
+     *                      filter}'s syntax check {@link org.osgi.framework.BundleContext#getServiceReferences(String, String)}
+     * @param <ServiceType> the expected service type
+     * @return an instance of the {@link ServiceType} or {@code null}
+     */
+    @Nullable <ServiceType> ServiceType[] getServices(@NotNull String className, @Nullable String filter);
+}
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/AbstractBundledRenderUnit.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/AbstractBundledRenderUnit.java
new file mode 100644
index 0000000..8cdcf4c
--- /dev/null
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/AbstractBundledRenderUnit.java
@@ -0,0 +1,133 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements.  See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership.  The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License.  You may obtain a copy of the License at
+ ~
+ ~   http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied.  See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+package org.apache.sling.scripting.resolver.internal;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+abstract class AbstractBundledRenderUnit implements Executable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractBundledRenderUnit.class.getName());
+
+    private final Bundle bundle;
+    private final BundleContext bundleContext;
+    private List<ServiceReference> references;
+    private Map<String, Object> services;
+
+    AbstractBundledRenderUnit(@NotNull Bundle bundle) {
+        this.bundle = bundle;
+        bundleContext = bundle.getBundleContext();
+    }
+
+    @Override
+    @NotNull
+    public Bundle getBundle() {
+        return bundle;
+    }
+
+    @Override
+    @Nullable
+    @SuppressWarnings("unchecked")
+    public <ServiceType> ServiceType getService(@NotNull String className) {
+        LOG.debug("Attempting to load class {} as an OSGi service.", className);
+        ServiceType result = (this.services == null ? null : (ServiceType) this.services.get(className));
+        if (result == null) {
+            final ServiceReference ref = this.bundleContext.getServiceReference(className);
+            if (ref != null) {
+                result = (ServiceType) this.bundleContext.getService(ref);
+                if (result != null) {
+                    if (this.services == null) {
+                        this.services = new HashMap<>();
+                    }
+                    if (this.references == null) {
+                        this.references = new ArrayList<>();
+                    }
+                    this.references.add(ref);
+                    this.services.put(className, result);
+                    return result;
+                }
+            }
+        }
+        return null;
+    }
+
+    @Override
+    @Nullable
+    @SuppressWarnings("unchecked")
+    public <ServiceType> ServiceType[] getServices(@NotNull String className, @NotNull String filter) {
+        ServiceType[] result = null;
+        try {
+            final ServiceReference[] refs = this.bundleContext.getServiceReferences(className, filter);
+
+            if (refs != null) {
+                // sort by service ranking (lowest first) (see ServiceReference#compareTo(Object))
+                List<ServiceReference> references = Arrays.asList(refs);
+                Collections.sort(references);
+                // get the highest ranking first
+                Collections.reverse(references);
+
+                final List<ServiceType> objects = new ArrayList<>();
+                for (ServiceReference reference : references) {
+                    final ServiceType service = (ServiceType) this.bundleContext.getService(reference);
+                    if (service != null) {
+                        if (this.references == null) {
+                            this.references = new ArrayList<>();
+                        }
+                        this.references.add(reference);
+                        objects.add(service);
+                    }
+                }
+                if (objects.size() > 0) {
+                    ServiceType[] srv = (ServiceType[]) Array.newInstance(bundle.loadClass(className), objects.size());
+                    result = objects.toArray(srv);
+                }
+            }
+        } catch (Exception e) {
+            LOG.error(String.format("Unable to retrieve the services of type %s.", className), e);
+        }
+        return result;
+    }
+
+    @Override
+    public void releaseDependencies() {
+        if (references != null) {
+            for (ServiceReference reference : this.references) {
+                bundleContext.ungetService(reference);
+            }
+            references.clear();
+        }
+        if (services != null) {
+            services.clear();
+        }
+    }
+
+}
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptFinder.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptFinder.java
index 746b356..7493301 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptFinder.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptFinder.java
@@ -25,7 +25,6 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.regex.Pattern;
 
 import javax.script.ScriptEngineFactory;
 import javax.script.ScriptEngineManager;
@@ -49,11 +48,11 @@ public class BundledScriptFinder {
     @Reference
     private ScriptEngineManager scriptEngineManager;
 
-    ScriptEngineExecutable getScript(SlingHttpServletRequest request, Bundle bundle, boolean precompiledScripts) {
+    Executable getScript(SlingHttpServletRequest request, Bundle bundle, boolean precompiledScripts) {
         return getScript(request, bundle, precompiledScripts,null);
     }
 
-    ScriptEngineExecutable getScript(SlingHttpServletRequest request, Bundle bundle, boolean precompiledScripts, String delegatedResourceType) {
+    Executable getScript(SlingHttpServletRequest request, Bundle bundle, boolean precompiledScripts, String delegatedResourceType) {
         List<String> scriptMatches;
         if (StringUtils.isEmpty(delegatedResourceType)) {
             scriptMatches = buildScriptMatches(request);
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptServlet.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptServlet.java
index 8564120..e88004f 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptServlet.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/BundledScriptServlet.java
@@ -53,7 +53,7 @@ class BundledScriptServlet extends GenericServlet {
     private final Set<String> m_wiredResourceTypes;
     private final boolean m_precompiledScripts;
 
-    private Map<String, ScriptEngineExecutable> scriptsMap = new HashMap<>();
+    private Map<String, Executable> scriptsMap = new HashMap<>();
     private ReadWriteLock lock = new ReentrantReadWriteLock();
 
 
@@ -90,23 +90,23 @@ class BundledScriptServlet extends GenericServlet {
             }
 
             String scriptsMapKey = getScriptsMapKey(request);
-            ScriptEngineExecutable script;
+            Executable executable;
             lock.readLock().lock();
             try {
-                script = scriptsMap.get(scriptsMapKey);
-                if (script == null) {
+                executable = scriptsMap.get(scriptsMapKey);
+                if (executable == null) {
                     lock.readLock().unlock();
                     lock.writeLock().lock();
                     try {
-                        script = scriptsMap.get(scriptsMapKey);
-                        if (script == null) {
+                        executable = scriptsMap.get(scriptsMapKey);
+                        if (executable == null) {
                             if (StringUtils.isEmpty(m_delegatedResourceType)) {
-                                script = m_bundledScriptFinder.getScript(request, m_bundle, m_precompiledScripts);
+                                executable = m_bundledScriptFinder.getScript(request, m_bundle, m_precompiledScripts);
                             } else {
-                                script = m_bundledScriptFinder.getScript(request, m_bundle, m_precompiledScripts, m_delegatedResourceType);
+                                executable = m_bundledScriptFinder.getScript(request, m_bundle, m_precompiledScripts, m_delegatedResourceType);
                             }
-                            if (script != null) {
-                                scriptsMap.put(scriptsMapKey, script);
+                            if (executable != null) {
+                                scriptsMap.put(scriptsMapKey, executable);
                             }
                         }
                         lock.readLock().lock();
@@ -117,25 +117,23 @@ class BundledScriptServlet extends GenericServlet {
             } finally {
                 lock.readLock().unlock();
             }
-            if (script != null) {
+            if (executable != null) {
                 RequestWrapper requestWrapper = new RequestWrapper(request, m_wiredResourceTypes);
-                ScriptContext scriptContext = m_scriptContextProvider.prepareScriptContext(requestWrapper, response, script);
+                ScriptContext scriptContext = m_scriptContextProvider.prepareScriptContext(requestWrapper, response, executable);
                 try {
-                    script.eval(scriptContext);
+                    executable.eval(scriptContext);
                 } catch (ScriptException se) {
                     Throwable cause = (se.getCause() == null) ? se : se.getCause();
-                    throw new ScriptEvaluationException(script.getName(), se.getMessage(), cause);
+                    throw new ScriptEvaluationException(executable.getName(), se.getMessage(), cause);
                 } finally {
-                    if (scriptContext != null) {
-                        Bindings engineBindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
-                        if (engineBindings != null && engineBindings.containsKey(SlingBindings.SLING)) {
-                            Object scriptHelper = engineBindings.get(SlingBindings.SLING);
-                            if (scriptHelper instanceof ScriptHelper) {
-                                ((ScriptHelper) scriptHelper).cleanup();
-                            }
+                    Bindings engineBindings = scriptContext.getBindings(ScriptContext.ENGINE_SCOPE);
+                    if (engineBindings != null && engineBindings.containsKey(SlingBindings.SLING)) {
+                        Object scriptHelper = engineBindings.get(SlingBindings.SLING);
+                        if (scriptHelper instanceof ScriptHelper) {
+                            ((ScriptHelper) scriptHelper).cleanup();
                         }
-
                     }
+                    executable.releaseDependencies();
                 }
             } else {
                 throw new ServletException("Unable to locate a " + (m_precompiledScripts ? "class" : "script") + " for rendering.");
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptEngineExecutable.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Executable.java
similarity index 76%
copy from scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptEngineExecutable.java
copy to scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Executable.java
index a62188d..fd5616c 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptEngineExecutable.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Executable.java
@@ -18,19 +18,10 @@
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
 package org.apache.sling.scripting.resolver.internal;
 
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
+import org.apache.sling.scripting.resolver.BundledRenderUnit;
 
-import org.osgi.framework.Bundle;
+interface Executable extends BundledRenderUnit {
 
-interface ScriptEngineExecutable {
+    void releaseDependencies();
 
-    String getName();
-
-    ScriptEngine getScriptEngine();
-
-    Bundle getBundle();
-
-    void eval(ScriptContext context) throws ScriptException;
 }
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/PrecompiledScript.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/PrecompiledScript.java
index 99e2ba2..400adbd 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/PrecompiledScript.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/PrecompiledScript.java
@@ -26,40 +26,42 @@ import javax.script.ScriptException;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.sling.api.scripting.SlingScriptConstants;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.osgi.framework.Bundle;
 
-public class PrecompiledScript implements ScriptEngineExecutable {
+public class PrecompiledScript extends AbstractBundledRenderUnit {
 
     private static final StringReader EMPTY_READER = new StringReader(StringUtils.EMPTY);
 
     private final ScriptEngine scriptEngine;
     private final Object precompiledScript;
-    private final Bundle bundle;
 
-    PrecompiledScript(Bundle bundle, ScriptEngine scriptEngine, Object precompiledScript) {
+    PrecompiledScript(@NotNull Bundle bundle, @NotNull ScriptEngine scriptEngine, @NotNull Object precompiledScript) {
+        super(bundle);
         this.scriptEngine = scriptEngine;
         this.precompiledScript = precompiledScript;
-        this.bundle = bundle;
     }
 
     @Override
+    @NotNull
     public String getName() {
         return precompiledScript.getClass().getName();
     }
 
     @Override
+    @NotNull
     public ScriptEngine getScriptEngine() {
         return scriptEngine;
     }
 
     @Override
-    public void eval(ScriptContext context) throws ScriptException {
-        context.setAttribute("precompiled.unit", precompiledScript, SlingScriptConstants.SLING_SCOPE);
+    public void eval(@NotNull ScriptContext context) throws ScriptException {
         scriptEngine.eval(EMPTY_READER, context);
     }
 
     @Override
-    public Bundle getBundle() {
-        return bundle;
+    public @NotNull Object getUnit() {
+        return precompiledScript;
     }
 }
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Script.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Script.java
index 0d863e4..7d2a80d 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Script.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/Script.java
@@ -35,9 +35,8 @@ import org.apache.commons.io.IOUtils;
 import org.apache.sling.scripting.core.ScriptNameAwareReader;
 import org.osgi.framework.Bundle;
 
-class Script implements ScriptEngineExecutable {
+class Script extends AbstractBundledRenderUnit {
 
-    private final Bundle bundle;
     private final URL url;
     private final ScriptEngine scriptEngine;
     private String sourceCode;
@@ -47,7 +46,7 @@ class Script implements ScriptEngineExecutable {
 
 
     Script(Bundle bundle, URL url, ScriptEngine scriptEngine) {
-        this.bundle = bundle;
+        super(bundle);
         this.url = url;
         this.scriptEngine = scriptEngine;
     }
@@ -100,9 +99,4 @@ class Script implements ScriptEngineExecutable {
             throw new ScriptException(e);
         }
     }
-
-    @Override
-    public Bundle getBundle() {
-        return bundle;
-    }
 }
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptContextProvider.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptContextProvider.java
index efd2639..326253b 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptContextProvider.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptContextProvider.java
@@ -40,6 +40,7 @@ import org.apache.sling.scripting.api.BindingsValuesProvider;
 import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
 import org.apache.sling.scripting.api.resource.ScriptingResourceResolverProvider;
 import org.apache.sling.scripting.core.ScriptHelper;
+import org.apache.sling.scripting.resolver.BundledRenderUnit;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Reference;
 import org.slf4j.Logger;
@@ -49,7 +50,7 @@ import org.slf4j.LoggerFactory;
         service = ScriptContextProvider.class
 )
 public class ScriptContextProvider {
-    
+
     private static final Set<String> PROTECTED_BINDINGS = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
             SlingBindings.REQUEST,
             SlingBindings.RESPONSE,
@@ -59,7 +60,8 @@ public class ScriptContextProvider {
             SlingBindings.OUT,
             SlingBindings.LOG,
             SlingBindings.SLING,
-            ScriptEngine.FILENAME
+            ScriptEngine.FILENAME,
+            BundledRenderUnit.VARIABLE
     )));
 
     @Reference
@@ -68,7 +70,7 @@ public class ScriptContextProvider {
     @Reference
     private ScriptingResourceResolverProvider scriptingResourceResolverProvider;
 
-    ScriptContext prepareScriptContext(SlingHttpServletRequest request, SlingHttpServletResponse response, ScriptEngineExecutable executable)
+    ScriptContext prepareScriptContext(SlingHttpServletRequest request, SlingHttpServletResponse response, Executable executable)
             throws IOException {
         // prepare the SlingBindings
         Bindings bindings = new SimpleBindings();
@@ -81,6 +83,7 @@ public class ScriptContextProvider {
         Logger scriptLogger = LoggerFactory.getLogger(executable.getName());
         bindings.put(SlingBindings.LOG, scriptLogger);
         bindings.put(SlingBindings.SLING, new ScriptHelper(executable.getBundle().getBundleContext(), null, request, response));
+        bindings.put(BundledRenderUnit.VARIABLE, executable);
         bindings.put(ScriptEngine.FILENAME, executable.getName());
         bindings.put(ScriptEngine.FILENAME.replaceAll("\\.", "_"), executable.getName());
 
@@ -99,7 +102,6 @@ public class ScriptContextProvider {
         scriptContext.setWriter(response.getWriter());
         scriptContext.setErrorWriter(new LogWriter(scriptLogger));
         scriptContext.setReader(request.getReader());
-        scriptContext.setAttribute("org.apache.sling.scripting.resolver.provider.bundle", executable.getBundle(), SlingScriptConstants.SLING_SCOPE);
         return scriptContext;
     }
 
diff --git a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptEngineExecutable.java b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/package-info.java
similarity index 71%
rename from scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptEngineExecutable.java
rename to scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/package-info.java
index a62188d..c45b556 100644
--- a/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/internal/ScriptEngineExecutable.java
+++ b/scripting-resolver/org-apache-sling-scripting-resolver/src/main/java/org/apache/sling/scripting/resolver/package-info.java
@@ -16,21 +16,7 @@
  ~ specific language governing permissions and limitations
  ~ under the License.
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-package org.apache.sling.scripting.resolver.internal;
+@Version("0.1.0")
+package org.apache.sling.scripting.resolver;
 
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-
-import org.osgi.framework.Bundle;
-
-interface ScriptEngineExecutable {
-
-    String getName();
-
-    ScriptEngine getScriptEngine();
-
-    Bundle getBundle();
-
-    void eval(ScriptContext context) throws ScriptException;
-}
+import org.osgi.annotation.versioning.Version;
diff --git a/scripting-resolver/pom.xml b/scripting-resolver/pom.xml
index 09d90de..4ff5f58 100644
--- a/scripting-resolver/pom.xml
+++ b/scripting-resolver/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <artifactId>sling</artifactId>
         <groupId>org.apache.sling</groupId>
-        <version>33</version>
+        <version>34</version>
         <relativePath/>
     </parent>
     <modelVersion>4.0.0</modelVersion>
@@ -32,6 +32,8 @@
     <version>0.0.1-SNAPSHOT</version>
     <packaging>pom</packaging>
 
+    <name>Apache Sling Scripting Resolver Reactor</name>
+
     <modules>
         <module>org-apache-sling-scripting-maven-plugin</module>
         <module>examples/org-apache-sling-scripting-examplebundle</module>
@@ -40,6 +42,7 @@
         <module>examples/org-apache-sling-scripting-examplebundle.hi</module>
         <module>org-apache-sling-scripting-resolver</module>
         <module>sling-org-apache-sling-scripting-sightly</module>
+        <module>org-apache-sling-scripting-resolver-it</module>
     </modules>
 
     <build>
diff --git a/scripting-resolver/sling-org-apache-sling-scripting-sightly b/scripting-resolver/sling-org-apache-sling-scripting-sightly
index f491640..7b31afc 160000
--- a/scripting-resolver/sling-org-apache-sling-scripting-sightly
+++ b/scripting-resolver/sling-org-apache-sling-scripting-sightly
@@ -1 +1 @@
-Subproject commit f49164058cf2c81e5569a4849d60747c87c91f21
+Subproject commit 7b31afc95460eade4817445d2c92a201deff7dc9