incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1169802 - /sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
Date Mon, 12 Sep 2011 15:37:48 GMT
Author: justin
Date: Mon Sep 12 15:37:48 2011
New Revision: 1169802

URL: http://svn.apache.org/viewvc?rev=1169802&view=rev
Log:
SLING-2218 - invalidating tag files on modification; thanks to Julian Sedding for the patch!

Modified:
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java?rev=1169802&r1=1169801&r2=1169802&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
Mon Sep 12 15:37:48 2011
@@ -69,6 +69,11 @@ public final class JspRuntimeContext {
     // Logger
     private Log log = LogFactory.getLog(JspRuntimeContext.class);
 
+    /**
+     * Prefixes, in which repository paths and script paths can differ.
+     */
+    private static final String[] PATH_PREFIXES = {"", "/WEB-INF/tags"};
+
     /*
      * Counts how many times the webapp's JSPs have been reloaded.
      */
@@ -279,17 +284,19 @@ public final class JspRuntimeContext {
     }
 
     private void invalidate(final JspServletWrapper jsw) {
+        log.debug("Invalidating script " + jsw.getJspUri());
         jsw.clearLastModificationTest();
     }
 
-    public void handleModification(final String scriptName) {
+    public void handleModification(final String repositoryPath) {
+        final String scriptName = getScriptPath(repositoryPath);
         synchronized ( this ) {
             // first check if jsps contains this
             JspServletWrapper wrapper = jsps.get(scriptName);
             if ( wrapper != null ) {
                 invalidate(wrapper);
             }
-            if ( wrapper == null ) {
+            if (wrapperIsValid(wrapper)) {
                 synchronized ( depToJsp ) {
                     final Set<String> deps = depToJsp.get(scriptName);
                     if ( deps != null ) {
@@ -305,6 +312,20 @@ public final class JspRuntimeContext {
         }
     }
 
+    private String getScriptPath(String repositoryPath) {
+        for (final String prefix : PATH_PREFIXES) {
+            final String path = prefix + repositoryPath;
+            if (depToJsp.containsKey(path)) {
+                return path;
+            }
+        }
+        return repositoryPath;
+    }
+
+    private boolean wrapperIsValid(JspServletWrapper wrapper) {
+        return wrapper == null || wrapper.getLastModificationTest() == -1;
+    }
+
     /**
      * Add a new JspServletWrapper.
      *
@@ -313,6 +334,7 @@ public final class JspRuntimeContext {
      */
     public void addWrapper(String jspUri, JspServletWrapper jsw) {
         jsps.put(jspUri, jsw);
+        addJspDependencies(jsw);
     }
 
     /**



Mime
View raw message