This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.java-2.1.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-java.git
commit 65e3521c34323403d97238574150bbe2fa40a585 Author: Carsten Ziegeler <[email protected]> AuthorDate: Mon Oct 17 12:40:48 2016 +0000 SLING-5784 : Use service property to identify the ServletContext registered by Sling git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/java@1765260 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 2 +- .../scripting/java/impl/JavaScriptEngineFactory.java | 8 ++++---- .../apache/sling/scripting/java/impl/ServletCache.java | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 329dc8c..fc1d892 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.apache.sling</groupId> <artifactId>sling</artifactId> - <version>28</version> + <version>29</version> <relativePath /> </parent> diff --git a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java index 77a9309..851ec29 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/JavaScriptEngineFactory.java @@ -71,8 +71,8 @@ import org.slf4j.LoggerFactory; @Property(name=JavaScriptEngineFactory.PROPERTY_COMPILER_TARGET_V_M, value=JavaScriptEngineFactory.VERSION_AUTO), @Property(name=JavaScriptEngineFactory.PROPERTY_CLASSDEBUGINFO, boolValue=true), @Property(name=JavaScriptEngineFactory.PROPERTY_ENCODING, value="UTF-8"), - @Property(name = ResourceChangeListener.CHANGES, value = {"CHANGED","REMOVED"}), - @Property(name = ResourceChangeListener.PATHS, value = {"glob:."}, propertyPrivate = true) + @Property(name = ResourceChangeListener.CHANGES, value = {"CHANGED", "REMOVED"}), + @Property(name = ResourceChangeListener.PATHS, value = {"."}, propertyPrivate = true) }) public class JavaScriptEngineFactory extends AbstractScriptEngineFactory @@ -93,7 +93,7 @@ public class JavaScriptEngineFactory @Reference private JavaCompiler javaCompiler; - @Reference + @Reference(target="(name=org.apache.sling)") private ServletContext slingServletContext; private SlingIOProvider ioProvider; @@ -254,7 +254,7 @@ public class JavaScriptEngineFactory } private void handleModification(final String scriptName, final boolean remove) { - this.ioProvider.getServletCache().removeWrapper(scriptName); + this.ioProvider.getServletCache().removeWrapper(scriptName, remove); } private static class JavaScriptEngine extends AbstractSlingScriptEngine { diff --git a/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java b/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java index 7f6aaab..0484283 100644 --- a/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java +++ b/src/main/java/org/apache/sling/scripting/java/impl/ServletCache.java @@ -18,6 +18,7 @@ package org.apache.sling.scripting.java.impl; import java.util.Iterator; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** @@ -58,16 +59,26 @@ public final class ServletCache { * Remove a ServletWrapper. * * @param servletUri Servlet URI + * @param isRemove Is a remove */ - public void removeWrapper(final String servletUri) { + public void removeWrapper(final String servletUri, final boolean isRemove) { final ServletWrapper wrapper = servlets.remove(servletUri); if ( wrapper != null ) { wrapper.destroy(); + } else if ( isRemove ) { + final Iterator<Map.Entry<String, ServletWrapper>> iter = servlets.entrySet().iterator(); + while ( iter.hasNext() ) { + final Map.Entry<String, ServletWrapper> entry = iter.next(); + if ( entry.getKey().startsWith(servletUri) ) { + iter.remove(); + entry.getValue().destroy(); + } + } } } /** - * Process a "destory" event for this web application context. + * Process a "destroy" event for this web application context. */ public void destroy() { Iterator<ServletWrapper> i = this.servlets.values().iterator(); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
