SLING-6165 - Expose a service for Sling Scripting that provides request-scoped Resource Resolvers for scripting dependencies

* moved the API in its own sub-package so that changes to the org.apache.sling.api.resource API don't force
artificial changes for org.apache.sling.scripting.api
* emphasised the fact that request based resolvers should be used only in a Servlet Request API context
* switched the implementation to listen for ServletRequestEvents instead of SlingRequestEvents
* removed useless synchronised block
* adapted unit tests

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1771115 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 3522b77..138f392 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,7 +57,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.api</artifactId>
-            <version>2.9.0</version>
+            <version>2.11.0</version>
             <scope>provided</scope>
         </dependency>
     </dependencies>
diff --git a/src/main/java/org/apache/sling/scripting/api/package-info.java b/src/main/java/org/apache/sling/scripting/api/package-info.java
index 8b61c4a..0f0017a 100644
--- a/src/main/java/org/apache/sling/scripting/api/package-info.java
+++ b/src/main/java/org/apache/sling/scripting/api/package-info.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  ******************************************************************************/
-@Version("2.4.0")
+@Version("2.3.0")
 package org.apache.sling.scripting.api;
 
 import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/scripting/api/ScriptingResourceResolverFactory.java b/src/main/java/org/apache/sling/scripting/api/resolver/ScriptingResourceResolverFactory.java
similarity index 90%
rename from src/main/java/org/apache/sling/scripting/api/ScriptingResourceResolverFactory.java
rename to src/main/java/org/apache/sling/scripting/api/resolver/ScriptingResourceResolverFactory.java
index 8f8cdfb..94144f6 100644
--- a/src/main/java/org/apache/sling/scripting/api/ScriptingResourceResolverFactory.java
+++ b/src/main/java/org/apache/sling/scripting/api/resolver/ScriptingResourceResolverFactory.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  ******************************************************************************/
-package org.apache.sling.scripting.api;
+package org.apache.sling.scripting.api.resolver;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
@@ -37,6 +37,9 @@
      * ResourceResolver} should not be closed by consumers (calling {@link ResourceResolver#close} doesn't do anything), since this
      * service will handle the closing operation automatically. The {@code ResourceResolver} will be shared between scripting
      * dependencies that render parts of the response for the same request.</p>
+     *
+     * <p><b>NOTE:</b> Usage of this {@link ResourceResolver} outside of a Servlet Request API context might lead to improper cleaning
+     * (e.g. reusing the same resolver for multiple threads).</p>
      */
     ResourceResolver getRequestScopedResourceResolver();
 
diff --git a/src/main/java/org/apache/sling/scripting/api/resolver/package-info.java b/src/main/java/org/apache/sling/scripting/api/resolver/package-info.java
new file mode 100644
index 0000000..dc35606
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/api/resolver/package-info.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+/**
+ * <p>The {@code org.apache.sling.scripting.api.resolver} package provides a unified API for scripting bundles that need to perform script
+ * resolution across the {@link org.apache.sling.api.resource.Resource} space.</p>
+ *
+ * <p>Some API methods might indicate that they are <i>request-bound</i>. In this case it should be noted that <i>usage outside of the
+ * context of a Servlet API Request might lead to improper cleaning of objects whose life-cycle should not be longer than the request to
+ * which they're bound to (for example per-thread objects)</i>.</p>
+ *
+ * <p>This package depends on the {@link org.apache.sling.api.resource} API, version 2.9.0 (bundle {@code org.apache.sling.api}, version
+ * 2.11.0).</p>
+ */
+@Version("1.0.0")
+package org.apache.sling.scripting.api.resolver;
+
+import org.osgi.annotation.versioning.Version;