sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r599941 [1/25] - in /incubator/sling/trunk/scripting/jsp: ./ src/main/java/org/apache/sling/scripting/jsp/ src/main/java/org/apache/sling/scripting/jsp/jasper/ src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ src/main/java/org/...
Date Fri, 30 Nov 2007 20:11:05 GMT
Author: fmeschbe
Date: Fri Nov 30 12:10:51 2007
New Revision: 599941

URL: http://svn.apache.org/viewvc?rev=599941&view=rev
Log:
SLING-116 Reintroduce compilation to repository
   - Bring back the RepositoryIOProvider, slightly modified
      - Make use of ResourceResolver to read resources using
          request user session
      - Always write to the rpository using administrative
          session
   - Add patched Jasper 6.0.14, using the same path as reported
          for Tomcat bug 43979 but refactored below the
          org.apache.sling.scripting.jsp package
   

Added:
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/EmbeddedServletOptions.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JasperException.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/Options.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/BeanRepository.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Collector.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/DefaultErrorHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Dumper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELFunctionMapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELNode.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ELParser.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorDispatcher.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ErrorHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Generator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ImplicitTagLibraryInfo.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JasperTagInfo.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JavacErrorDetail.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspConfig.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspDocumentParser.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspReader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspRuntimeContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JspUtil.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Localizer.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Mark.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Node.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageDataImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageInfo.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Parser.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ParserController.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ScriptingVariabler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/ServletWriter.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/SmapGenerator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/SmapStratum.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/SmapUtil.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagConstants.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagLibraryInfoImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagPluginManager.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TextOptimizer.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TldLocationsCache.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Validator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/tagplugin/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/tagplugin/TagPlugin.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/tagplugin/TagPluginContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/ELContextImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/ELContextWrapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/ELResolverImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/ExpressionEvaluatorImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/ExpressionImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/FunctionMapperImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/JspELException.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/JspMethodExpression.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/JspMethodNotFoundException.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/JspPropertyNotFoundException.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/JspPropertyNotWritableException.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/JspValueExpression.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/el/VariableResolverImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/AnnotationHelper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/AnnotationProcessor.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/BodyContentImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/HttpJspBase.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspApplicationContextImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspContextWrapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFactoryImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspFragmentHelper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspRuntimeLibrary.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspSourceDependent.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/JspWriterImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PageContextImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PerThreadTagHandlerPool.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/PeriodicEventListener.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/ProtectedFunctionMapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/ServletResponseWrapperInclude.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/runtime/TagHandlerPool.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/security/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/security/SecurityClassLoad.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/security/SecurityUtil.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JasperLoader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspCServletContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServlet.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/Util.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Catch.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Choose.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/ForEach.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/ForTokens.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/If.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Import.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Otherwise.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Out.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Param.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Redirect.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Remove.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Set.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/Url.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/core/When.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/util/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/util/Enumerator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/ASCIIReader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/EncodingMap.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/ParserUtils.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/SymbolTable.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/TreeNode.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/UCSReader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/UTF8Reader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLChar.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLEncodingDetector.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLString.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/xmlparser/XMLStringBuffer.java
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/resources/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/resources/LocalStrings.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/resources/LocalStrings_es.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/resources/LocalStrings_fr.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/resources/LocalStrings_ja.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/servlet/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/servlet/mbeans-descriptors.xml
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/tagplugins/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/sling/scripting/jsp/jasper/tagplugins/jstl/tagPlugins.xml
Modified:
    incubator/sling/trunk/scripting/jsp/pom.xml
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java

Modified: incubator/sling/trunk/scripting/jsp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/pom.xml?rev=599941&r1=599940&r2=599941&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/pom.xml (original)
+++ incubator/sling/trunk/scripting/jsp/pom.xml Fri Nov 30 12:10:51 2007
@@ -64,20 +64,21 @@
                 <configuration>
                     <instructions>
                         <Export-Package>
-                            org.apache.sling.scripting.jsp.util,
+                            org.apache.sling.scripting.jsp.jasper.runtime;
+                            org.apache.sling.scripting.jsp.util;version=${pom.version},
                             javax.el; javax.servlet.jsp;
                             javax.servlet.jsp.el;
                             javax.servlet.jsp.tagext;version=2.1,
-                            org.apache;
-                            org.apache.jasper.runtime
                         </Export-Package>
                         <Private-Package>
-                            org.apache.sling.scripting.jsp.*
+                            org.apache.sling.scripting.jsp,
+                            !org.apache.sling.scripting.jsp.jasper.runtime,
+                            org.apache.sling.scripting.jsp.jasper.*
                         </Private-Package>
                         <DynamicImport-Package>*</DynamicImport-Package>
 
                         <Import-Package>
-                            !org.apache.tools.ant.*, !org.eclipse.*, *
+                            !org.eclipse.*, *
                         </Import-Package>
 
                         <!-- Embed Jasper completely -->
@@ -115,7 +116,13 @@
 
         <dependency>
             <groupId>org.apache.tomcat</groupId>
-            <artifactId>jasper</artifactId>
+            <artifactId>servlet-api</artifactId>
+            <version>6.0.14</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>jsp-api</artifactId>
             <version>6.0.14</version>
         </dependency>
         <dependency>

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java?rev=599941&r1=599940&r2=599941&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java (original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java Fri Nov 30 12:10:51 2007
@@ -23,14 +23,15 @@
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
 
-import org.apache.jasper.JasperException;
-import org.apache.jasper.Options;
-import org.apache.jasper.compiler.JspRuntimeContext;
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.scripting.SlingScript;
 import org.apache.sling.api.scripting.SlingScriptEngine;
 import org.apache.sling.api.scripting.SlingScriptHelper;
+import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.classloader.RepositoryClassLoaderProvider;
+import org.apache.sling.scripting.jsp.jasper.JasperException;
+import org.apache.sling.scripting.jsp.jasper.Options;
+import org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,7 +54,7 @@
  * @scr.property name="jasper.mappedfile" value="true" type="Boolean"
  * @scr.property name="jasper.modificationTestInterval" value="4" type="Integer"
  * @scr.property name="jasper.reloading" value="false" type="Boolean"
- * @scr.property name="jasper.scratchdir" value="classes"
+ * @scr.property name="jasper.scratchdir" value="/classes"
  * @scr.property name="jasper.trimSpaces" value="false" type="Boolean"
  * @scr.property name="jasper.displaySourceFragments" value="true"
  *               type="Boolean"
@@ -67,6 +68,9 @@
     ComponentContext componentContext;
 
     /** @scr.reference */
+    private SlingRepository repository;
+
+    /** @scr.reference */
     private ServletContext slingServletContext;
 
     /**
@@ -75,6 +79,8 @@
      */
     private ClassLoader jspClassLoader;
 
+    private RepositoryIOProvider ioProvider;
+
     private SlingTldLocationsCache tldLocationsCache;
 
     private JspRuntimeContext jspRuntimeContext;
@@ -108,12 +114,12 @@
             throws SlingException, IOException {
         SlingScriptHelper ssh = (SlingScriptHelper) props.get(SLING);
         if (ssh != null) {
-            jspServletContext.setRequestResourceResolver(ssh.getRequest().getResourceResolver());
+            ioProvider.setRequestResourceResolver(ssh.getRequest().getResourceResolver());
             try {
                 JspServletWrapperAdapter jsp = getJspWrapperAdapter(ssh);
                 jsp.service(ssh);
             } finally {
-                jspServletContext.resetRequestResourceResolver();
+                ioProvider.resetRequestResourceResolver();
             }
         }
     }
@@ -163,19 +169,25 @@
         Thread.currentThread().setContextClassLoader(jspClassLoader);
 
         try {
+            ioProvider = new RepositoryIOProvider(repository);
+
             tldLocationsCache = new SlingTldLocationsCache(slingServletContext,
                 componentContext.getBundleContext());
 
             // return options which use the jspClassLoader
-            options = new JspServletOptions(slingServletContext,
+            options = new JspServletOptions(slingServletContext, ioProvider,
                 componentContext, jspClassLoader, tldLocationsCache);
 
             // Initialize the JSP Runtime Context
             jspRuntimeContext = new JspRuntimeContext(slingServletContext,
                 options);
 
-            jspServletContext = new JspServletContext(slingServletContext,
-                tldLocationsCache);
+            // by default access the repository
+            jspRuntimeContext.setIOProvider(ioProvider);
+
+
+            jspServletContext = new JspServletContext(ioProvider,
+                slingServletContext, tldLocationsCache);
 
             servletConfig = new JspServletConfig(jspServletContext,
                 componentContext.getProperties());
@@ -194,7 +206,7 @@
 
     }
 
-    protected void deactivate(ComponentContext componentContext) {
+    protected void deactivate(ComponentContext oldComponentContext) {
         if (log.isDebugEnabled()) {
             log.debug("JspScriptHandler.deactivate()");
         }
@@ -209,7 +221,8 @@
             tldLocationsCache = null;
         }
 
-        this.componentContext = null;
+        ioProvider = null;
+        componentContext = null;
     }
 
     protected void bindRepositoryClassLoaderProvider(

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java?rev=599941&r1=599940&r2=599941&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java (original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java Fri Nov 30 12:10:51 2007
@@ -27,11 +27,6 @@
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
-import org.apache.sling.api.SlingException;
-import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.resource.StreamProvider;
-import org.apache.sling.api.resource.URLProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,23 +38,15 @@
     /** default log */
     private static final Logger log = LoggerFactory.getLogger(JspServletContext.class);
 
+    private final RepositoryIOProvider ioProvider;
     private final ServletContext delegatee;
     private final SlingTldLocationsCache tcs;
 
-    private ThreadLocal<ResourceResolver> requestResourceResolver;
-
-    JspServletContext(ServletContext componentContext, SlingTldLocationsCache tcs) {
+    JspServletContext(RepositoryIOProvider ioProvider, ServletContext componentContext,
+            SlingTldLocationsCache tcs) {
+        this.ioProvider = ioProvider;
         this.delegatee = componentContext;
         this.tcs = tcs;
-        this.requestResourceResolver = new ThreadLocal<ResourceResolver>();
-    }
-
-    void setRequestResourceResolver(ResourceResolver resolver) {
-        requestResourceResolver.set(resolver);
-    }
-
-    void resetRequestResourceResolver() {
-        requestResourceResolver.remove();
     }
 
     //---------- implemented methods ------------------------------------------
@@ -70,20 +57,9 @@
     public URL getResource(String path) throws MalformedURLException {
 
         if (path.startsWith("/")) {
-            try {
-                Resource res = getResourceInternal(path);
-                if (res instanceof URLProvider) {
-                    return ((URLProvider) res).getURL();
-                }
-
-                // TODO: is this correct or should we try another one ??
-                return null;
-            } catch (MalformedURLException mue) {
-                // rethrow this
-                throw mue;
-            } catch (Exception ex) {
-                // SlingException or RepositoryException
-                log.error("getResource: Problem getting resource " + path, ex);
+            URL url = ioProvider.getURL(path);
+            if (url != null) {
+                return url;
             }
         }
 
@@ -95,18 +71,16 @@
      * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
      */
     public InputStream getResourceAsStream(String path) {
+        // path might be an URL, so only check resource provider in case of an
+        // absolute path - assuming URLs have no leading slash at all, we
+        // don't care for the scheme separating colon here
         if (path.startsWith("/")) {
             try {
-                Resource res = getResourceInternal(path);
-                if (res instanceof StreamProvider) {
-                    return ((StreamProvider) res).getInputStream();
-                }
-
-                // TODO: is this correct or should we try another one ??
-                return null;
+                return ioProvider.getInputStream(path);
             } catch (Exception ex) {
-                // SlingException or IOException
-                log.error("getResource: Problem getting resource " + path, ex);
+                // FileNotFoundException or IOException
+                log.debug("getResourceAsStream: Cannot get resource {}: {}",
+                    path, ex.getMessage());
             }
         }
 
@@ -126,6 +100,10 @@
         return null;
     }
 
+    public Set<?> getResourcePaths(String path) {
+        return ioProvider.getResourcePaths(path);
+    }
+
     public void log(String msg) {
         log.info(msg);
     }
@@ -193,10 +171,6 @@
         return delegatee.getRequestDispatcher(path);
     }
 
-    public Set<?> getResourcePaths(String path) {
-        return null;
-    }
-
     public String getServerInfo() {
         return delegatee.getServerInfo();
     }
@@ -226,15 +200,6 @@
     }
 
     //---------- internal -----------------------------------------------------
-
-    private Resource getResourceInternal(String path) throws SlingException {
-        ResourceResolver resolver = requestResourceResolver.get();
-        if (resolver != null) {
-            return resolver.getResource(path);
-        }
-
-        return null;
-    }
 
     private URL getUrlForResource(String path) {
         int cs = path.indexOf(":/");

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java?rev=599941&r1=599940&r2=599941&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java (original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletOptions.java Fri Nov 30 12:10:51 2007
@@ -16,7 +16,6 @@
  */
 package org.apache.sling.scripting.jsp;
 
-import java.io.File;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Map;
@@ -24,12 +23,12 @@
 
 import javax.servlet.ServletContext;
 
-import org.apache.jasper.Options;
-import org.apache.jasper.compiler.JspConfig;
-import org.apache.jasper.compiler.Localizer;
-import org.apache.jasper.compiler.TagPluginManager;
-import org.apache.jasper.compiler.TldLocationsCache;
-import org.apache.sling.core.CoreConstants;
+import org.apache.sling.scripting.jsp.jasper.IOProvider;
+import org.apache.sling.scripting.jsp.jasper.Options;
+import org.apache.sling.scripting.jsp.jasper.compiler.JspConfig;
+import org.apache.sling.scripting.jsp.jasper.compiler.Localizer;
+import org.apache.sling.scripting.jsp.jasper.compiler.TagPluginManager;
+import org.apache.sling.scripting.jsp.jasper.compiler.TldLocationsCache;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -116,7 +115,7 @@
     /**
      * I want to see my generated servlets. Which directory are they in?
      */
-    private File scratchDir;
+    private String scratchDir;
 
     /**
      * Need to have this as is for versions 4 and 5 of IE. Can be set from the
@@ -282,7 +281,7 @@
     /**
      * What is my scratch dir?
      */
-    public File getScratchDir() {
+    public String getScratchDir() {
         return this.scratchDir;
     }
 
@@ -387,8 +386,8 @@
      * ServletConfig and ServletContext.
      */
     public JspServletOptions(ServletContext servletContext,
-            ComponentContext componentContext, ClassLoader jspClassLoader,
-            TldLocationsCache tldLocationsCache) {
+            IOProvider ioProvider, ComponentContext componentContext,
+            ClassLoader jspClassLoader, TldLocationsCache tldLocationsCache) {
 
         this.jspClassLoader = jspClassLoader;
 
@@ -609,31 +608,8 @@
         }
 
         String dir = getProperty("scratchdir");
-        this.scratchDir = new File((dir != null) ? dir : "classes");
-        if (!scratchDir.isAbsolute()) {
-            String slingHome = componentContext.getBundleContext().getProperty(
-                CoreConstants.SLING_HOME);
-            if (slingHome != null) {
-                scratchDir = new File(slingHome, scratchDir.getPath());
-            } else {
-                File tmp = componentContext.getBundleContext().getDataFile(
-                    scratchDir.getPath());
-                if (tmp != null) {
-                    scratchDir = tmp;
-                }
-            }
-            scratchDir = scratchDir.getAbsoluteFile();
-        }
-
-        if (scratchDir.exists()) {
-            if (!scratchDir.isDirectory()) {
-                // TODO ERROR
-            }
-        } else {
-            if (!scratchDir.mkdirs()) {
-                // TODO ERROR
-            }
-        }
+        this.scratchDir = (dir != null) ? dir : "/classes";
+        ioProvider.mkdirs(this.scratchDir);
 
         String compilerTargetVM = getProperty("compilerTargetVM");
         if (compilerTargetVM != null) {

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java?rev=599941&r1=599940&r2=599941&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java (original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java Fri Nov 30 12:10:51 2007
@@ -22,14 +22,14 @@
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 
-import org.apache.jasper.Constants;
-import org.apache.jasper.JasperException;
-import org.apache.jasper.Options;
-import org.apache.jasper.compiler.JspRuntimeContext;
-import org.apache.jasper.servlet.JspServletWrapper;
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.scripting.SlingScriptHelper;
+import org.apache.sling.scripting.jsp.jasper.Constants;
+import org.apache.sling.scripting.jsp.jasper.JasperException;
+import org.apache.sling.scripting.jsp.jasper.Options;
+import org.apache.sling.scripting.jsp.jasper.compiler.JspRuntimeContext;
+import org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper;
 
 /**
  * The <code>JspServletWrapperAdapter</code> TODO

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java?rev=599941&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/RepositoryIOProvider.java Fri Nov 30 12:10:51 2007
@@ -0,0 +1,398 @@
+/*
+ * 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.jsp;
+
+import static org.apache.sling.api.resource.ResourceMetadata.MODIFICATION_TIME;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.StreamProvider;
+import org.apache.sling.api.resource.URLProvider;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.scripting.jsp.jasper.IOProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>RepositoryIOProvider</code> TODO
+ */
+class RepositoryIOProvider implements IOProvider {
+
+    /** default log */
+    private static final Logger log = LoggerFactory.getLogger(RepositoryIOProvider.class);
+
+    private final SlingRepository repository;
+
+    private ThreadLocal<ResourceResolver> requestResourceResolver;
+
+    // private session for write access
+    private ThreadLocal<Session> privateSession;
+
+    RepositoryIOProvider(SlingRepository repository) {
+        this.repository = repository;
+        this.requestResourceResolver = new ThreadLocal<ResourceResolver>();
+        this.privateSession = new ThreadLocal<Session>();
+    }
+
+    void setRequestResourceResolver(ResourceResolver resolver) {
+        requestResourceResolver.set(resolver);
+    }
+
+    void resetRequestResourceResolver() {
+        requestResourceResolver.remove();
+
+        // at the same time logout this thread's session
+        Session session = privateSession.get();
+        if (session != null) {
+            if (session.isLive()) {
+                session.logout();
+            }
+            privateSession.remove();
+        }
+    }
+
+    // ---------- IOProvider interface -----------------------------------------
+
+    /**
+     * Returns an InputStream for the file name which is looked up with the
+     * ResourceProvider and retrieved from the Resource if the StreamProvider
+     * interface is implemented.
+     */
+    public InputStream getInputStream(String fileName)
+            throws FileNotFoundException, IOException {
+        try {
+            Resource resource = getResourceInternal(fileName);
+            if (!(resource instanceof StreamProvider)) {
+                throw new FileNotFoundException("Cannot find " + fileName);
+            }
+
+            return ((StreamProvider) resource).getInputStream();
+
+        } catch (SlingException se) {
+            throw (IOException) new IOException(
+                "Failed to get InputStream for " + fileName).initCause(se);
+        }
+    }
+
+    /**
+     * Returns the value of the last modified meta data field of the resource
+     * found at file name or zero if the meta data field is not set. If the
+     * resource does not exist or an error occurrs finding the resource, -1 is
+     * returned.
+     */
+    public long lastModified(String fileName) {
+        try {
+            Resource resource = getResourceInternal(fileName);
+            if (resource != null) {
+                ResourceMetadata meta = resource.getResourceMetadata();
+                Long modTime = (Long) meta.get(MODIFICATION_TIME);
+                return (modTime != null) ? modTime.longValue() : 0;
+            }
+
+        } catch (SlingException se) {
+            log.error("Cannot get last modification time for " + fileName, se);
+        }
+
+        // fallback to "non-existant" in case of problems
+        return -1;
+    }
+
+    /**
+     * Removes the named item from the repository.
+     */
+    public boolean delete(String fileName) {
+        Node parentNode = null;
+        try {
+            fileName = cleanPath(fileName);
+            Session session = getPrivateSession();
+            if (session.itemExists(fileName)) {
+                Item fileItem = session.getItem(fileName);
+                parentNode = fileItem.getParent();
+                fileItem.remove();
+                parentNode.save();
+                return true;
+            }
+        } catch (RepositoryException re) {
+            log.error("Cannot remove " + fileName, re);
+        } finally {
+            checkNode(parentNode, fileName);
+        }
+
+        // fall back to false if item does not exist or in case of error
+        return false;
+    }
+
+    /**
+     * Returns an output stream to write to the repository.
+     */
+    public OutputStream getOutputStream(String fileName) {
+        fileName = cleanPath(fileName);
+        return new RepositoryOutputStream(this, fileName);
+    }
+
+    /**
+     * Renames a node in the repository.
+     */
+    public boolean rename(String oldFileName, String newFileName) {
+        try {
+            oldFileName = cleanPath(oldFileName);
+            newFileName = cleanPath(newFileName);
+
+            Session session = getPrivateSession();
+            session.getWorkspace().move(oldFileName, newFileName);
+            return true;
+        } catch (RepositoryException re) {
+            log.error("Cannot rename " + oldFileName + " to " + newFileName, re);
+        }
+
+        // fallback to false in case of error or non-existence of oldFileName
+        return false;
+    }
+
+    /**
+     * Creates a folder hierarchy in the repository.
+     */
+    public boolean mkdirs(String path) {
+        Node parentNode = null;
+        try {
+            Session session = getPrivateSession();
+
+            // quick test
+            path = cleanPath(path);
+            if (session.itemExists(path) && session.getItem(path).isNode()) {
+                return true;
+            }
+
+            // check path walking it down
+            Node current = session.getRootNode();
+            String[] names = path.split("/");
+            for (int i = 0; i < names.length; i++) {
+                if (names[i] == null || names[i].length() == 0) {
+                    continue;
+                } else if (current.hasNode(names[i])) {
+                    current = current.getNode(names[i]);
+                } else {
+                    if (parentNode == null) {
+                        parentNode = current;
+                    }
+                    current = current.addNode(names[i], "nt:folder");
+                }
+            }
+
+            if (parentNode != null) {
+                parentNode.save();
+                return true;
+            }
+
+        } catch (RepositoryException re) {
+            log.error("Cannot create folder path " + path, re);
+        } finally {
+            checkNode(parentNode, path);
+        }
+
+        // false in case of error or no need to create
+        return false;
+    }
+
+    // ---------- Helper Methods for JspServletContext -------------------------
+
+    /* package */URL getURL(String path) throws MalformedURLException {
+        try {
+            Resource resource = getResourceInternal(path);
+            if (resource instanceof URLProvider) {
+                return ((URLProvider) resource).getURL();
+            }
+
+        } catch (SlingException se) {
+            throw (MalformedURLException) new MalformedURLException(
+                "Cannot get URL for " + path).initCause(se);
+        }
+
+        return null;
+    }
+
+    /* package */ Set<String> getResourcePaths(String path) {
+        Set<String> paths = new HashSet<String>();
+
+        ResourceResolver resolver = requestResourceResolver.get();
+        if (resolver != null) {
+            try {
+                Resource resource = resolver.getResource(cleanPath(path));
+                if (resource != null) {
+                    Iterator<Resource> entries = resolver.listChildren(resource);
+                    while (entries.hasNext()) {
+                        paths.add(entries.next().getURI());
+                    }
+                }
+            } catch (SlingException se) {
+                log.warn("getResourcePaths: Cannot list children of " + path, se);
+            }
+        }
+
+        return paths.isEmpty() ? null : paths;
+    }
+
+    private Resource getResourceInternal(String path) throws SlingException {
+        ResourceResolver resolver = requestResourceResolver.get();
+        if (resolver != null) {
+            return resolver.getResource(cleanPath(path));
+        }
+
+        return null;
+    }
+
+    // ---------- internal -----------------------------------------------------
+
+    private Session getPrivateSession() throws RepositoryException {
+        Session session = privateSession.get();
+        if (session == null) {
+            session = repository.loginAdministrative(null);
+            privateSession.set(session);
+        }
+
+        return session;
+    }
+
+    private static void checkNode(Node node, String path) {
+        if (node != null && node.isModified()) {
+            try {
+                node.refresh(false);
+            } catch (RepositoryException re) {
+                log.error("Cannot refresh node for " + path
+                    + " after failed save", re);
+            }
+        }
+    }
+
+    private String cleanPath(String path) {
+        // replace backslash by slash
+        path = path.replace('\\', '/');
+
+        // cut off trailing slash
+        while (path.endsWith("/")) {
+            path = path.substring(0, path.length() - 1);
+        }
+
+        return path;
+    }
+
+    private static class RepositoryOutputStream extends ByteArrayOutputStream {
+
+        private final RepositoryIOProvider repositoryOutputProvider;
+
+        private final String fileName;
+
+        RepositoryOutputStream(RepositoryIOProvider repositoryOutputProvider,
+                String fileName) {
+            this.repositoryOutputProvider = repositoryOutputProvider;
+            this.fileName = fileName;
+        }
+
+        public void close() throws IOException {
+            super.close();
+
+            Node parentNode = null;
+            try {
+                Session session = repositoryOutputProvider.getPrivateSession();
+                Node fileNode = null;
+                Node contentNode = null;
+                if (session.itemExists(fileName)) {
+                    Item item = session.getItem(fileName);
+                    if (item.isNode()) {
+                        Node node = item.isNode()
+                                ? (Node) item
+                                : item.getParent();
+                        if ("jcr:content".equals(node.getName())) {
+                            // replace the content properties of the jcr:content
+                            // node
+                            parentNode = node;
+                            contentNode = node;
+                        } else if (node.isNodeType("nt:file")) {
+                            // try to set the content properties of jcr:content
+                            // node
+                            parentNode = node;
+                            contentNode = node.getNode("jcr:content");
+                        } else { // fileName is a node
+                            // try to set the content properties of the node
+                            parentNode = node;
+                            contentNode = node;
+                        }
+                    } else {
+                        // replace property with an nt:file node (if possible)
+                        parentNode = item.getParent();
+                        String name = item.getName();
+                        fileNode = parentNode.addNode(name, "nt:file");
+                        item.remove();
+                    }
+                } else {
+                    int lastSlash = fileName.lastIndexOf('/');
+                    if (lastSlash <= 0) {
+                        parentNode = session.getRootNode();
+                    } else {
+                        Item parent = session.getItem(fileName.substring(
+                            0, lastSlash));
+                        if (!parent.isNode()) {
+                            // TODO: fail
+                        }
+                        parentNode = (Node) parent;
+                    }
+                    String name = fileName.substring(lastSlash + 1);
+                    fileNode = parentNode.addNode(name, "nt:file");
+                }
+
+                // if we have a file node, create the contentNode
+                if (fileNode != null) {
+                    contentNode = fileNode.addNode("jcr:content", "nt:resource");
+                }
+
+                contentNode.setProperty("jcr:lastModified",
+                    System.currentTimeMillis());
+                contentNode.setProperty("jcr:data", new ByteArrayInputStream(
+                    buf, 0, size()));
+                contentNode.setProperty("jcr:mimeType",
+                    "application/octet-stream");
+
+                parentNode.save();
+            } catch (RepositoryException re) {
+                log.error("Cannot write file " + fileName, re);
+                throw new IOException("Cannot write file " + fileName
+                    + ", reason: " + re.toString());
+            } finally {
+                checkNode(parentNode, fileName);
+            }
+        }
+    }
+}

Modified: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java?rev=599941&r1=599940&r2=599941&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java (original)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/SlingTldLocationsCache.java Fri Nov 30 12:10:51 2007
@@ -25,10 +25,10 @@
 
 import javax.servlet.ServletContext;
 
-import org.apache.jasper.JasperException;
-import org.apache.jasper.compiler.TldLocationsCache;
-import org.apache.jasper.xmlparser.ParserUtils;
-import org.apache.jasper.xmlparser.TreeNode;
+import org.apache.sling.scripting.jsp.jasper.JasperException;
+import org.apache.sling.scripting.jsp.jasper.compiler.TldLocationsCache;
+import org.apache.sling.scripting.jsp.jasper.xmlparser.ParserUtils;
+import org.apache.sling.scripting.jsp.jasper.xmlparser.TreeNode;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java?rev=599941&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/Constants.java Fri Nov 30 12:10:51 2007
@@ -0,0 +1,202 @@
+/*
+ * 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.jsp.jasper;
+
+
+/**
+ * Some constants and other global data that are used by the compiler and the runtime.
+ *
+ * @author Anil K. Vijendran
+ * @author Harish Prabandham
+ * @author Shawn Bayern
+ * @author Mark Roth
+ */
+public class Constants {
+    
+    /**
+     * The base class of the generated servlets. 
+     */
+    public static final String JSP_SERVLET_BASE = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.JSP_SERVLET_BASE", "org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase");
+
+    /**
+     * _jspService is the name of the method that is called by 
+     * HttpJspBase.service(). This is where most of the code generated
+     * from JSPs go.
+     */
+    public static final String SERVICE_METHOD_NAME = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.SERVICE_METHOD_NAME", "_jspService");
+
+    /**
+     * Default servlet content type.
+     */
+    public static final String SERVLET_CONTENT_TYPE = "text/html";
+
+    /**
+     * These classes/packages are automatically imported by the
+     * generated code. 
+     */
+    public static final String[] STANDARD_IMPORTS = { 
+	"javax.servlet.*", 
+	"javax.servlet.http.*", 
+	"javax.servlet.jsp.*"
+    };
+
+    /**
+     * ServletContext attribute for classpath. This is tomcat specific. 
+     * Other servlet engines may choose to support this attribute if they 
+     * want to have this JSP engine running on them. 
+     */
+    public static final String SERVLET_CLASSPATH = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.SERVLET_CLASSPATH", "org.apache.catalina.jsp_classpath");
+
+    /**
+     * Request attribute for <code>&lt;jsp-file&gt;</code> element of a
+     * servlet definition.  If present on a request, this overrides the
+     * value returned by <code>request.getServletPath()</code> to select
+     * the JSP page to be executed.
+     */
+    public static final String JSP_FILE = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.JSP_FILE", "org.apache.catalina.jsp_file");
+
+
+    /**
+     * Default size of the JSP buffer.
+     */
+    public static final int DEFAULT_BUFFER_SIZE = 8 * 1024;
+
+    /**
+     * Default size for the tag buffers.
+     */
+    public static final int DEFAULT_TAG_BUFFER_SIZE = 512;
+
+    /**
+     * Default tag handler pool size.
+     */
+    public static final int MAX_POOL_SIZE = 5;
+
+    /**
+     * The query parameter that causes the JSP engine to just
+     * pregenerated the servlet but not invoke it. 
+     */
+    public static final String PRECOMPILE = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.PRECOMPILE", "jsp_precompile");
+
+    /**
+     * The default package name for compiled jsp pages.
+     */
+    public static final String JSP_PACKAGE_NAME = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.JSP_PACKAGE_NAME", "org.apache.jsp");
+
+    /**
+     * The default package name for tag handlers generated from tag files
+     */
+    public static final String TAG_FILE_PACKAGE_NAME = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.TAG_FILE_PACKAGE_NAME", "org.apache.jsp.tag");
+
+    /**
+     * Servlet context and request attributes that the JSP engine
+     * uses. 
+     */
+    public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
+    public static final String TMP_DIR = "javax.servlet.context.tempdir";
+
+    // Must be kept in sync with org/apache/catalina/Globals.java
+    public static final String ALT_DD_ATTR = 
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.ALT_DD_ATTR", "org.apache.catalina.deploy.alt_dd");
+
+    /**
+     * Public Id and the Resource path (of the cached copy) 
+     * of the DTDs for tag library descriptors. 
+     */
+    public static final String TAGLIB_DTD_PUBLIC_ID_11 = 
+	"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
+    public static final String TAGLIB_DTD_RESOURCE_PATH_11 = 
+	"/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
+    public static final String TAGLIB_DTD_PUBLIC_ID_12 = 
+	"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
+    public static final String TAGLIB_DTD_RESOURCE_PATH_12 = 
+	"/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
+
+    /**
+     * Public Id and the Resource path (of the cached copy) 
+     * of the DTDs for web application deployment descriptors
+     */
+    public static final String WEBAPP_DTD_PUBLIC_ID_22 = 
+	"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
+    public static final String WEBAPP_DTD_RESOURCE_PATH_22 = 
+	"/javax/servlet/resources/web-app_2_2.dtd";
+    public static final String WEBAPP_DTD_PUBLIC_ID_23 = 
+	"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
+    public static final String WEBAPP_DTD_RESOURCE_PATH_23 = 
+	"/javax/servlet/resources/web-app_2_3.dtd";
+
+    /**
+     * List of the Public IDs that we cache, and their
+     * associated location. This is used by 
+     * an EntityResolver to return the location of the
+     * cached copy of a DTD.
+     */
+    public static final String[] CACHED_DTD_PUBLIC_IDS = {
+	TAGLIB_DTD_PUBLIC_ID_11,
+	TAGLIB_DTD_PUBLIC_ID_12,
+	WEBAPP_DTD_PUBLIC_ID_22,
+	WEBAPP_DTD_PUBLIC_ID_23,
+    };
+    public static final String[] CACHED_DTD_RESOURCE_PATHS = {
+	TAGLIB_DTD_RESOURCE_PATH_11,
+	TAGLIB_DTD_RESOURCE_PATH_12,
+	WEBAPP_DTD_RESOURCE_PATH_22,
+	WEBAPP_DTD_RESOURCE_PATH_23,
+    };
+    
+    /**
+     * Default URLs to download the pluging for Netscape and IE.
+     */
+    public static final String NS_PLUGIN_URL = 
+        "http://java.sun.com/products/plugin/";
+
+    public static final String IE_PLUGIN_URL = 
+        "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
+
+    /**
+     * Prefix to use for generated temporary variable names
+     */
+    public static final String TEMP_VARIABLE_NAME_PREFIX =
+        System.getProperty("org.apache.sling.scripting.jsp.jasper.Constants.TEMP_VARIABLE_NAME_PREFIX", "_jspx_temp");
+
+    /**
+     * A replacement char for "\$".
+     * XXX This is a hack to avoid changing EL interpreter to recognize "\$"
+     */
+    public static final char ESC = '\u001b';
+    public static final String ESCStr = "'\\u001b'";
+
+    /**
+     * Has security been turned on?
+     */
+    public static final boolean IS_SECURITY_ENABLED = 
+        (System.getSecurityManager() != null);
+
+    /**
+     * The name of the path parameter used to pass the session identifier
+     * back and forth with the client.
+     */
+    public static final String SESSION_PARAMETER_NAME = "jsessionid";
+
+}

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/EmbeddedServletOptions.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/EmbeddedServletOptions.java?rev=599941&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/EmbeddedServletOptions.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/EmbeddedServletOptions.java Fri Nov 30 12:10:51 2007
@@ -0,0 +1,700 @@
+/*
+ * 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.jsp.jasper;
+
+import java.io.File;
+import java.util.*;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.sling.scripting.jsp.jasper.compiler.JspConfig;
+import org.apache.sling.scripting.jsp.jasper.compiler.Localizer;
+import org.apache.sling.scripting.jsp.jasper.compiler.TagPluginManager;
+import org.apache.sling.scripting.jsp.jasper.compiler.TldLocationsCache;
+import org.apache.sling.scripting.jsp.jasper.xmlparser.ParserUtils;
+
+/**
+ * A class to hold all init parameters specific to the JSP engine. 
+ *
+ * @author Anil K. Vijendran
+ * @author Hans Bergsten
+ * @author Pierre Delisle
+ */
+public final class EmbeddedServletOptions implements Options {
+    
+    // Logger
+    private Log log = LogFactory.getLog(EmbeddedServletOptions.class);
+    
+    private Properties settings = new Properties();
+    
+    /**
+     * Is Jasper being used in development mode?
+     */
+    private boolean development = true;
+    
+    /**
+     * Should Ant fork its java compiles of JSP pages.
+     */
+    public boolean fork = true;
+    
+    /**
+     * Do you want to keep the generated Java files around?
+     */
+    private boolean keepGenerated = true;
+    
+    /**
+     * Should white spaces between directives or actions be trimmed?
+     */
+    private boolean trimSpaces = false;
+    
+    /**
+     * Determines whether tag handler pooling is enabled.
+     */
+    private boolean isPoolingEnabled = true;
+    
+    /**
+     * Do you want support for "mapped" files? This will generate
+     * servlet that has a print statement per line of the JSP file.
+     * This seems like a really nice feature to have for debugging.
+     */
+    private boolean mappedFile = true;
+    
+    /**
+     * Do you want stack traces and such displayed in the client's
+     * browser? If this is false, such messages go to the standard
+     * error or a log file if the standard error is redirected. 
+     */
+    private boolean sendErrorToClient = false;
+    
+    /**
+     * Do we want to include debugging information in the class file?
+     */
+    private boolean classDebugInfo = true;
+    
+    /**
+     * Background compile thread check interval in seconds.
+     */
+    private int checkInterval = 0;
+    
+    /**
+     * Is the generation of SMAP info for JSR45 debuggin suppressed?
+     */
+    private boolean isSmapSuppressed = false;
+    
+    /**
+     * Should SMAP info for JSR45 debugging be dumped to a file?
+     */
+    private boolean isSmapDumped = false;
+    
+    /**
+     * Are Text strings to be generated as char arrays?
+     */
+    private boolean genStringAsCharArray = false;
+    
+    private boolean errorOnUseBeanInvalidClassAttribute = true;
+    
+    /**
+     * I want to see my generated servlets. Which directory are they
+     * in?
+     */
+    private String scratchDir;
+    
+    /**
+     * Need to have this as is for versions 4 and 5 of IE. Can be set from
+     * the initParams so if it changes in the future all that is needed is
+     * to have a jsp initParam of type ieClassId="<value>"
+     */
+    private String ieClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
+    
+    /**
+     * What classpath should I use while compiling generated servlets?
+     */
+    private String classpath = null;
+    
+    /**
+     * Compiler to use.
+     */
+    private String compiler = null;
+    
+    /**
+     * Compiler target VM.
+     */
+    private String compilerTargetVM = "1.5";
+    
+    /**
+     * The compiler source VM.
+     */
+    private String compilerSourceVM = "1.5";
+    
+    /**
+     * The compiler class name.
+     */
+    private String compilerClassName = null;
+    
+    /**
+     * Cache for the TLD locations
+     */
+    private TldLocationsCache tldLocationsCache = null;
+    
+    /**
+     * Jsp config information
+     */
+    private JspConfig jspConfig = null;
+    
+    /**
+     * TagPluginManager
+     */
+    private TagPluginManager tagPluginManager = null;
+    
+    /**
+     * Java platform encoding to generate the JSP
+     * page servlet.
+     */
+    private String javaEncoding = "UTF8";
+    
+    /**
+     * Modification test interval.
+     */
+    private int modificationTestInterval = 4;
+    
+    /**
+     * Is generation of X-Powered-By response header enabled/disabled?
+     */
+    private boolean xpoweredBy;
+    
+    /**
+     * Should we include a source fragment in exception messages, which could be displayed
+     * to the developer ?
+     */
+    private boolean displaySourceFragment = true;
+
+    
+    public String getProperty(String name ) {
+        return settings.getProperty( name );
+    }
+    
+    public void setProperty(String name, String value ) {
+        if (name != null && value != null){ 
+            settings.setProperty( name, value );
+        }
+    }
+    
+    /**
+     * Are we keeping generated code around?
+     */
+    public boolean getKeepGenerated() {
+        return keepGenerated;
+    }
+    
+    /**
+     * Should white spaces between directives or actions be trimmed?
+     */
+    public boolean getTrimSpaces() {
+        return trimSpaces;
+    }
+    
+    public boolean isPoolingEnabled() {
+        return isPoolingEnabled;
+    }
+    
+    /**
+     * Are we supporting HTML mapped servlets?
+     */
+    public boolean getMappedFile() {
+        return mappedFile;
+    }
+    
+    /**
+     * Should errors be sent to client or thrown into stderr?
+     */
+    public boolean getSendErrorToClient() {
+        return sendErrorToClient;
+    }
+    
+    /**
+     * Should class files be compiled with debug information?
+     */
+    public boolean getClassDebugInfo() {
+        return classDebugInfo;
+    }
+    
+    /**
+     * Background JSP compile thread check intervall
+     */
+    public int getCheckInterval() {
+        return checkInterval;
+    }
+    
+    /**
+     * Modification test interval.
+     */
+    public int getModificationTestInterval() {
+        return modificationTestInterval;
+    }
+    
+    /**
+     * Is Jasper being used in development mode?
+     */
+    public boolean getDevelopment() {
+        return development;
+    }
+    
+    /**
+     * Is the generation of SMAP info for JSR45 debuggin suppressed?
+     */
+    public boolean isSmapSuppressed() {
+        return isSmapSuppressed;
+    }
+    
+    /**
+     * Should SMAP info for JSR45 debugging be dumped to a file?
+     */
+    public boolean isSmapDumped() {
+        return isSmapDumped;
+    }
+    
+    /**
+     * Are Text strings to be generated as char arrays?
+     */
+    public boolean genStringAsCharArray() {
+        return this.genStringAsCharArray;
+    }
+    
+    /**
+     * Class ID for use in the plugin tag when the browser is IE. 
+     */
+    public String getIeClassId() {
+        return ieClassId;
+    }
+    
+    /**
+     * What is my scratch dir?
+     */
+    public String getScratchDir() {
+        return scratchDir;
+    }
+    
+    /**
+     * What classpath should I use while compiling the servlets
+     * generated from JSP files?
+     */
+    public String getClassPath() {
+        return classpath;
+    }
+    
+    /**
+     * Return <code>null</code> to force use of the <code>JasperLoader</code>.
+     */
+    public ClassLoader getJspClassLoader() {
+        return null;
+    }
+    
+    /**
+     * Is generation of X-Powered-By response header enabled/disabled?
+     */
+    public boolean isXpoweredBy() {
+        return xpoweredBy;
+    }
+    
+    /**
+     * Compiler to use.
+     */
+    public String getCompiler() {
+        return compiler;
+    }
+    
+    /**
+     * @see Options#getCompilerTargetVM
+     */
+    public String getCompilerTargetVM() {
+        return compilerTargetVM;
+    }
+    
+    /**
+     * @see Options#getCompilerSourceVM
+     */
+    public String getCompilerSourceVM() {
+        return compilerSourceVM;
+    }
+    
+    /**
+     * Java compiler class to use.
+     */
+    public String getCompilerClassName() {
+        return compilerClassName;
+    }
+
+    public boolean getErrorOnUseBeanInvalidClassAttribute() {
+        return errorOnUseBeanInvalidClassAttribute;
+    }
+    
+    public void setErrorOnUseBeanInvalidClassAttribute(boolean b) {
+        errorOnUseBeanInvalidClassAttribute = b;
+    }
+    
+    public TldLocationsCache getTldLocationsCache() {
+        return tldLocationsCache;
+    }
+    
+    public void setTldLocationsCache( TldLocationsCache tldC ) {
+        tldLocationsCache = tldC;
+    }
+    
+    public String getJavaEncoding() {
+        return javaEncoding;
+    }
+    
+    public boolean getFork() {
+        return fork;
+    }
+    
+    public JspConfig getJspConfig() {
+        return jspConfig;
+    }
+    
+    public TagPluginManager getTagPluginManager() {
+        return tagPluginManager;
+    }
+    
+    public boolean isCaching() {
+        return false;
+    }
+    
+    public Map getCache() {
+        return null;
+    }
+
+    /**
+     * Should we include a source fragment in exception messages, which could be displayed
+     * to the developer ?
+     */
+    public boolean getDisplaySourceFragment() {
+        return displaySourceFragment;
+    }
+
+    /**
+     * Create an EmbeddedServletOptions object using data available from
+     * ServletConfig and ServletContext. 
+     */
+    public EmbeddedServletOptions(ServletConfig config,
+            ServletContext context) {
+        
+        // JVM version numbers
+        try {
+            if (Float.parseFloat(System.getProperty("java.specification.version")) > 1.4) {
+                compilerSourceVM = compilerTargetVM = "1.5";
+            } else {
+                compilerSourceVM = compilerTargetVM = "1.4";
+            }
+        } catch (NumberFormatException e) {
+            // Ignore
+        }
+        
+        Enumeration enumeration=config.getInitParameterNames();
+        while( enumeration.hasMoreElements() ) {
+            String k=(String)enumeration.nextElement();
+            String v=config.getInitParameter( k );
+            setProperty( k, v);
+        }
+        
+        // quick hack
+        String validating=config.getInitParameter( "validating");
+        if( "false".equals( validating )) ParserUtils.validating=false;
+        
+        String keepgen = config.getInitParameter("keepgenerated");
+        if (keepgen != null) {
+            if (keepgen.equalsIgnoreCase("true")) {
+                this.keepGenerated = true;
+            } else if (keepgen.equalsIgnoreCase("false")) {
+                this.keepGenerated = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.keepgen"));
+                }
+            }
+        }
+        
+        
+        String trimsp = config.getInitParameter("trimSpaces"); 
+        if (trimsp != null) {
+            if (trimsp.equalsIgnoreCase("true")) {
+                trimSpaces = true;
+            } else if (trimsp.equalsIgnoreCase("false")) {
+                trimSpaces = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.trimspaces"));
+                }
+            }
+        }
+        
+        this.isPoolingEnabled = true;
+        String poolingEnabledParam
+        = config.getInitParameter("enablePooling"); 
+        if (poolingEnabledParam != null
+                && !poolingEnabledParam.equalsIgnoreCase("true")) {
+            if (poolingEnabledParam.equalsIgnoreCase("false")) {
+                this.isPoolingEnabled = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.enablePooling"));
+                }		       	   
+            }
+        }
+        
+        String mapFile = config.getInitParameter("mappedfile"); 
+        if (mapFile != null) {
+            if (mapFile.equalsIgnoreCase("true")) {
+                this.mappedFile = true;
+            } else if (mapFile.equalsIgnoreCase("false")) {
+                this.mappedFile = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.mappedFile"));
+                }
+            }
+        }
+        
+        String senderr = config.getInitParameter("sendErrToClient");
+        if (senderr != null) {
+            if (senderr.equalsIgnoreCase("true")) {
+                this.sendErrorToClient = true;
+            } else if (senderr.equalsIgnoreCase("false")) {
+                this.sendErrorToClient = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.sendErrToClient"));
+                }
+            }
+        }
+        
+        String debugInfo = config.getInitParameter("classdebuginfo");
+        if (debugInfo != null) {
+            if (debugInfo.equalsIgnoreCase("true")) {
+                this.classDebugInfo  = true;
+            } else if (debugInfo.equalsIgnoreCase("false")) {
+                this.classDebugInfo  = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.classDebugInfo"));
+                }
+            }
+        }
+        
+        String checkInterval = config.getInitParameter("checkInterval");
+        if (checkInterval != null) {
+            try {
+                this.checkInterval = Integer.parseInt(checkInterval);
+            } catch(NumberFormatException ex) {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.checkInterval"));
+                }
+            }
+        }
+        
+        String modificationTestInterval = config.getInitParameter("modificationTestInterval");
+        if (modificationTestInterval != null) {
+            try {
+                this.modificationTestInterval = Integer.parseInt(modificationTestInterval);
+            } catch(NumberFormatException ex) {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.modificationTestInterval"));
+                }
+            }
+        }
+        
+        String development = config.getInitParameter("development");
+        if (development != null) {
+            if (development.equalsIgnoreCase("true")) {
+                this.development = true;
+            } else if (development.equalsIgnoreCase("false")) {
+                this.development = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.development"));
+                }
+            }
+        }
+        
+        String suppressSmap = config.getInitParameter("suppressSmap");
+        if (suppressSmap != null) {
+            if (suppressSmap.equalsIgnoreCase("true")) {
+                isSmapSuppressed = true;
+            } else if (suppressSmap.equalsIgnoreCase("false")) {
+                isSmapSuppressed = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.suppressSmap"));
+                }
+            }
+        }
+        
+        String dumpSmap = config.getInitParameter("dumpSmap");
+        if (dumpSmap != null) {
+            if (dumpSmap.equalsIgnoreCase("true")) {
+                isSmapDumped = true;
+            } else if (dumpSmap.equalsIgnoreCase("false")) {
+                isSmapDumped = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.dumpSmap"));
+                }
+            }
+        }
+        
+        String genCharArray = config.getInitParameter("genStrAsCharArray");
+        if (genCharArray != null) {
+            if (genCharArray.equalsIgnoreCase("true")) {
+                genStringAsCharArray = true;
+            } else if (genCharArray.equalsIgnoreCase("false")) {
+                genStringAsCharArray = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.genchararray"));
+                }
+            }
+        }
+        
+        String errBeanClass =
+            config.getInitParameter("errorOnUseBeanInvalidClassAttribute");
+        if (errBeanClass != null) {
+            if (errBeanClass.equalsIgnoreCase("true")) {
+                errorOnUseBeanInvalidClassAttribute = true;
+            } else if (errBeanClass.equalsIgnoreCase("false")) {
+                errorOnUseBeanInvalidClassAttribute = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.errBean"));
+                }
+            }
+        }
+        
+        String ieClassId = config.getInitParameter("ieClassId");
+        if (ieClassId != null)
+            this.ieClassId = ieClassId;
+        
+        String classpath = config.getInitParameter("classpath");
+        if (classpath != null)
+            this.classpath = classpath;
+        
+        /*
+         * scratchdir
+         */
+        File scratchDir;
+        String dir = config.getInitParameter("scratchdir"); 
+        if (dir != null) {
+            scratchDir = new File(dir);
+        } else {
+            // First try the Servlet 2.2 javax.servlet.context.tempdir property
+            scratchDir = (File) context.getAttribute(Constants.TMP_DIR);
+            if (scratchDir == null) {
+                // Not running in a Servlet 2.2 container.
+                // Try to get the JDK 1.2 java.io.tmpdir property
+                dir = System.getProperty("java.io.tmpdir");
+                if (dir != null)
+                    scratchDir = new File(dir);
+            }
+        }      
+        if (scratchDir == null) {
+            log.fatal(Localizer.getMessage("jsp.error.no.scratch.dir"));
+            return;
+        }
+        
+        if (!(scratchDir.exists() && scratchDir.canRead() &&
+                scratchDir.canWrite() && scratchDir.isDirectory()))
+            log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir",
+                    scratchDir.getAbsolutePath()));
+        
+        this.scratchDir = scratchDir.getAbsolutePath();
+        this.compiler = config.getInitParameter("compiler");
+        
+        String compilerTargetVM = config.getInitParameter("compilerTargetVM");
+        if(compilerTargetVM != null) {
+            this.compilerTargetVM = compilerTargetVM;
+        }
+        
+        String compilerSourceVM = config.getInitParameter("compilerSourceVM");
+        if(compilerSourceVM != null) {
+            this.compilerSourceVM = compilerSourceVM;
+        }
+        
+        String javaEncoding = config.getInitParameter("javaEncoding");
+        if (javaEncoding != null) {
+            this.javaEncoding = javaEncoding;
+        }
+        
+        String compilerClassName = config.getInitParameter("compilerClassName");
+        if (compilerClassName != null) {
+            this.compilerClassName = compilerClassName;
+        }
+        
+        String fork = config.getInitParameter("fork");
+        if (fork != null) {
+            if (fork.equalsIgnoreCase("true")) {
+                this.fork = true;
+            } else if (fork.equalsIgnoreCase("false")) {
+                this.fork = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.fork"));
+                }
+            }
+        }
+        
+        String xpoweredBy = config.getInitParameter("xpoweredBy"); 
+        if (xpoweredBy != null) {
+            if (xpoweredBy.equalsIgnoreCase("true")) {
+                this.xpoweredBy = true;
+            } else if (xpoweredBy.equalsIgnoreCase("false")) {
+                this.xpoweredBy = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.xpoweredBy"));
+                }
+            }
+        }
+        
+        String displaySourceFragment = config.getInitParameter("displaySourceFragment"); 
+        if (displaySourceFragment != null) {
+            if (displaySourceFragment.equalsIgnoreCase("true")) {
+                this.displaySourceFragment = true;
+            } else if (displaySourceFragment.equalsIgnoreCase("false")) {
+                this.displaySourceFragment = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.displaySourceFragment"));
+                }
+            }
+        }
+        
+        // Setup the global Tag Libraries location cache for this
+        // web-application.
+        tldLocationsCache = new TldLocationsCache(context);
+        
+        // Setup the jsp config info for this web app.
+        jspConfig = new JspConfig(context);
+        
+        // Create a Tag plugin instance
+        tagPluginManager = new TagPluginManager(context);
+    }
+    
+}
+

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java?rev=599941&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/IOProvider.java Fri Nov 30 12:10:51 2007
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ *
+ * Licensed 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.jsp.jasper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * The <code>IOProvider</code> is an interface to provide more control of
+ * sending output from JSP Java and Class generation phases as well as cleaning
+ * up in case of problems.
+ */
+public interface IOProvider {
+
+    /**
+     * The default output provider, which is based on the OS filesystem
+     */
+    public static final IOProvider DEFAULT = new IOProvider() {
+        public OutputStream getOutputStream(String fileName) throws IOException {
+            File file = new File(fileName);
+            file.getParentFile().mkdirs(); // ensure parent path exists
+            return new FileOutputStream(fileName);
+        }
+        public InputStream getInputStream(String fileName)
+                throws FileNotFoundException, IOException {
+            return new FileInputStream(fileName);
+        }
+        public boolean delete(String fileName) {
+            return new File(fileName).delete();
+        }
+        public boolean rename(String oldFileName, String newFileName) {
+            return new File(oldFileName).renameTo(new File(newFileName));
+        }
+        public boolean mkdirs(String path) {
+            File dirFile = new File(path);
+            return dirFile.isDirectory() || dirFile.mkdirs();
+        }
+        public long lastModified(String path) {
+            File checkFile = new File(path);
+            return (checkFile.exists()) ? checkFile.lastModified() : -1L;
+        }
+    };
+
+    /**
+     * @param fileName The absolute path name of the destination into which to
+     *      write the output. The semantics of this path depends on the
+     *      implementation of this interface.
+     *
+     * @return an <code>OutputStream</code> into which to write the generated
+     *      output.
+     *
+     * @throws IOException If the output stream cannot be created for the file.
+     */
+    OutputStream getOutputStream(String fileName) throws IOException;
+
+    /**
+     * Returns an input stream to a file which has been written through a
+     * stream obtained form {@link #getOutputStream(String)}
+     *
+     * @param fileName The absolute path name of the source from which to
+     *      read the input. The semantics of this path depends on the
+     *      implementation of this interface.
+     *
+     * @return an <code>InputStream</code> from which to read the input.
+     *
+     * @throws FileNotFoundException If the file cannot be found
+     * @throws IOException If any other error occurs.
+     */
+    InputStream getInputStream(String fileName)
+            throws FileNotFoundException, IOException;
+
+    /**
+     * Remove a generated output.
+     *
+     * @param fileName The absolute path name of the item to remove. The
+     *      semantics of this path depends on the implementation of this
+     *      interface.
+     *
+     * @return <code>true</code> if the item could be removed, otherwise
+     *      <code>false</code> is removed.
+     */
+    boolean delete(String fileName);
+
+    /**
+     * Renames the the file from the old file to the new file name
+     * @param oldFileName
+     * @param newFileName
+     * @return <code>true</code> if renaming succeeded
+     */
+    boolean rename(String oldFileName, String newFileName);
+
+    /**
+     * Creates folders (folder like) structures, such that a container for data
+     * is available at the given path.
+     * <p>
+     * In the case of a OS Filesystem implementation, this method would be
+     * implemented by means of <code>new java.io.File(path).mkdirs()</code>.
+     *
+     * @param path The absolute path of the folder to create.
+     *
+     * @return <code>true</code> if and only if the folder was created, along
+     *         with all necessary parent directories; <code>false</code>
+     *         otherwise.
+     */
+    boolean mkdirs(String path);
+
+    /**
+     * Returns the last modification time stamp of the resource (generally a
+     * file) at the given absolute location.
+     *
+     * @param fileName The absolute path to the file whose last modification
+     *      time stamp is to be returned.
+     *
+     * @return The last modification time stamp of the resource in milliseconds
+     *      since the epoch or -1 if no resource exists at the given location.
+     */
+    long lastModified(String fileName);
+}



Mime
View raw message