incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1396762 - in /sling/trunk/bundles/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/apache/s...
Date Wed, 10 Oct 2012 19:51:05 GMT
Author: justin
Date: Wed Oct 10 19:51:04 2012
New Revision: 1396762

URL: http://svn.apache.org/viewvc?rev=1396762&view=rev
Log:
SLING-2618 - allowing the default session availability to be configured

Modified:
    sling/trunk/bundles/scripting/jsp/pom.xml
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageInfo.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
    sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
    sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties

Modified: sling/trunk/bundles/scripting/jsp/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/pom.xml?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/pom.xml (original)
+++ sling/trunk/bundles/scripting/jsp/pom.xml Wed Oct 10 19:51:04 2012
@@ -76,7 +76,10 @@
 
                         <!-- Embed Jasper completely -->
                         <Embed-Dependency>
-                            jasper*,el-api,jsp-api
+                            jasper*,
+                            el-api,
+                            jsp-api,
+                            org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/PropertiesUtil.*"
                         </Embed-Dependency>
                         <Embed-StripGroup>true</Embed-StripGroup>
                     </instructions>
@@ -122,6 +125,13 @@
             <version>1.3.0</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        
 
         <dependency>
             <groupId>org.apache.tomcat</groupId>

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptEngineFactory.java
Wed Oct 10 19:51:04 2012
@@ -47,6 +47,7 @@ import org.apache.sling.api.scripting.Sl
 import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.commons.classloader.ClassLoaderWriter;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.apache.sling.commons.osgi.PropertiesUtil;
 import org.apache.sling.scripting.api.AbstractScriptEngineFactory;
 import org.apache.sling.scripting.api.AbstractSlingScriptEngine;
 import org.apache.sling.scripting.jsp.jasper.Options;
@@ -86,6 +87,9 @@ public class JspScriptEngineFactory
     extends AbstractScriptEngineFactory
     implements EventHandler {
 
+    @Property(boolValue = true)
+    private static final String PROP_DEFAULT_IS_SESSION = "default.is.session";
+
     /** Default logger */
     private final Logger logger = LoggerFactory.getLogger(JspScriptEngineFactory.class);
 
@@ -115,6 +119,8 @@ public class JspScriptEngineFactory
 
     private ServiceRegistration eventHandlerRegistration;
 
+    private boolean defaultIsSession;
+
     /** The handler for the jsp factories. */
     private JspRuntimeContext.JspFactoryHandler jspFactoryHandler;
 
@@ -254,7 +260,7 @@ public class JspScriptEngineFactory
         }
 
         wrapper = new JspServletWrapper(servletConfig, options,
-                scriptName, false, rctxt);
+                scriptName, false, rctxt, defaultIsSession);
         wrapper = rctxt.addWrapper(scriptName, wrapper);
 
         return wrapper;
@@ -273,6 +279,9 @@ public class JspScriptEngineFactory
      * Activate this component
      */
     protected void activate(final ComponentContext componentContext) {
+        Dictionary<?, ?> properties = componentContext.getProperties();
+        this.defaultIsSession = PropertiesUtil.toBoolean(properties.get(PROP_DEFAULT_IS_SESSION),
true);
+
         // set the current class loader as the thread context loader for
         // the setup of the JspRuntimeContext
         final ClassLoader old = Thread.currentThread().getContextClassLoader();
@@ -294,7 +303,7 @@ public class JspScriptEngineFactory
                 slingServletContext, tldLocationsCache);
 
             servletConfig = new JspServletConfig(jspServletContext,
-                componentContext.getProperties());
+                properties);
 
         } finally {
             // make sure the context loader is reset after setting up the

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/JspCompilationContext.java
Wed Oct 10 19:51:04 2012
@@ -79,12 +79,15 @@ public class JspCompilationContext {
     private TagInfo tagInfo;
     private URL tagFileJarUrl;
 
+    private final boolean defaultIsSession;
+
     // jspURI _must_ be relative to the context
     public JspCompilationContext(String jspUri,
                                  boolean isErrPage,
                                  Options options,
                                  ServletContext context,
-                                 JspRuntimeContext rctxt) {
+                                 JspRuntimeContext rctxt,
+                                 boolean defaultIsSession) {
 
         this.jspUri = canonicalURI(jspUri);
         this.isErrPage = isErrPage;
@@ -107,6 +110,7 @@ public class JspCompilationContext {
         this.rctxt = rctxt;
         this.tagFileJarUrls = new HashMap<String, URL>();
         this.basePackageName = Constants.JSP_PACKAGE_NAME;
+        this.defaultIsSession = defaultIsSession;
     }
 
     public JspCompilationContext(String tagfile,
@@ -114,8 +118,9 @@ public class JspCompilationContext {
                                  Options options,
                                  ServletContext context,
                                  JspRuntimeContext rctxt,
+                                 boolean defaultIsSession,
                                  URL tagFileJarUrl) {
-        this(tagfile, false, options, context, rctxt);
+        this(tagfile, false, options, context, rctxt, defaultIsSession);
         this.isTagFile = true;
         this.tagInfo = tagInfo;
         this.tagFileJarUrl = tagFileJarUrl;
@@ -193,7 +198,7 @@ public class JspCompilationContext {
         if (jspCompiler != null ) {
             return jspCompiler;
         }
-        jspCompiler = new JDTCompiler();
+        jspCompiler = new JDTCompiler(defaultIsSession);
         jspCompiler.init(this);
         return jspCompiler;
     }

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/Compiler.java
Wed Oct 10 19:51:04 2012
@@ -57,8 +57,14 @@ public abstract class Compiler {
 
     protected Node.Nodes pageNodes;
 
+    protected final boolean defaultIsSession;
+
     // ------------------------------------------------------------ Constructor
 
+    public Compiler(boolean defaultIsSession) {
+        this.defaultIsSession = defaultIsSession;
+    }
+
     public void init(final JspCompilationContext ctxt) {
         this.ctxt = ctxt;
         this.options = ctxt.getOptions();
@@ -97,7 +103,7 @@ public abstract class Compiler {
 
         // Setup page info area
         pageInfo = new PageInfo(new BeanRepository(ctxt.getClassLoader(),
-                errDispatcher), ctxt.getJspFile());
+                errDispatcher), ctxt.getJspFile(), defaultIsSession);
 
         JspConfig jspConfig = options.getJspConfig();
         JspConfig.JspProperty jspProperty = jspConfig.findJspProperty(ctxt

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/JDTCompiler.java
Wed Oct 10 19:51:04 2012
@@ -58,6 +58,9 @@ import org.eclipse.jdt.internal.compiler
  */
 public class JDTCompiler extends org.apache.sling.scripting.jsp.jasper.compiler.Compiler
{
 
+    public JDTCompiler(boolean defaultIsSession) {
+        super(defaultIsSession);
+    }
 
     /**
      * Compile the servlet from .java file to .class file

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageInfo.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageInfo.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/PageInfo.java
Wed Oct 10 19:51:04 2012
@@ -94,7 +94,7 @@ class PageInfo {
     private Vector pluginDcls;      // Id's for tagplugin declarations
 
 
-    PageInfo(BeanRepository beanRepository, String jspFile) {
+    PageInfo(BeanRepository beanRepository, String jspFile, boolean isSession) {
 
         this.jspFile = jspFile;
         this.beanRepository = beanRepository;
@@ -109,6 +109,8 @@ class PageInfo {
         this.pluginDcls = new Vector();
         this.prefixes = new HashSet();
 
+        this.isSession = isSession;
+
         // Enter standard imports
         for(int i = 0; i < Constants.STANDARD_IMPORTS.length; i++)
             imports.add(Constants.STANDARD_IMPORTS[i]);

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/compiler/TagFileProcessor.java
Wed Oct 10 19:51:04 2012
@@ -538,7 +538,8 @@ class TagFileProcessor {
         if (wrapper == null) {
             wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
                     .getOptions(), tagFilePath, tagInfo, ctxt
-                    .getRuntimeContext(), ctxt.getTagFileJarUrl(tagFilePath));
+                    .getRuntimeContext(), compiler.defaultIsSession,
+                     ctxt.getTagFileJarUrl(tagFilePath));
             wrapper = rctxt.addWrapper(tagFilePath, wrapper);
 
             // Use same classloader and classpath for compiling tag files
@@ -564,6 +565,7 @@ class TagFileProcessor {
                 JspServletWrapper tempWrapper = new JspServletWrapper(ctxt
                         .getServletContext(), ctxt.getOptions(),
                         tagFilePath, tagInfo, ctxt.getRuntimeContext(),
+                        compiler.defaultIsSession,
                         ctxt.getTagFileJarUrl(tagFilePath));
                 tagClazz = tempWrapper.loadTagFilePrototype();
                 tempVector.add(tempWrapper.getJspEngineContext()

Modified: sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/jasper/servlet/JspServletWrapper.java
Wed Oct 10 19:51:04 2012
@@ -103,14 +103,15 @@ public class JspServletWrapper {
             final Options options,
             final String jspUri,
             final boolean isErrorPage,
-            final JspRuntimeContext rctxt) {
+            final JspRuntimeContext rctxt,
+            final boolean defaultIsSession) {
 	    this.isTagFile = false;
         this.config = config;
         this.options = options;
         this.jspUri = jspUri;
         this.ctxt = new JspCompilationContext(jspUri, isErrorPage, options,
 					 config.getServletContext(),
-					 rctxt);
+					 rctxt, defaultIsSession);
         if ( log.isDebugEnabled() ) {
             log.debug("Creating new wrapper for servlet " + jspUri);
         }
@@ -124,6 +125,7 @@ public class JspServletWrapper {
 			     final String tagFilePath,
 			     final TagInfo tagInfo,
 			     final JspRuntimeContext rctxt,
+			     final boolean defaultIsSession,
 			     final URL tagFileJarUrl)
     throws JasperException {
         this.isTagFile = true;
@@ -131,7 +133,7 @@ public class JspServletWrapper {
         this.options = options;
         this.jspUri = tagFilePath;
         this.ctxt = new JspCompilationContext(jspUri, tagInfo, options,
-					 servletContext, rctxt,
+					 servletContext, rctxt, defaultIsSession,
 					 tagFileJarUrl);
         if ( log.isDebugEnabled() ) {
             log.debug("Creating new wrapper for tagfile " + jspUri);

Modified: sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1396762&r1=1396761&r2=1396762&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
(original)
+++ sling/trunk/bundles/scripting/jsp/src/main/resources/OSGI-INF/metatype/metatype.properties
Wed Oct 10 19:51:04 2012
@@ -63,3 +63,7 @@ jasper.trimSpaces.description = Should w
 jasper.displaySourceFragments.name = Display Source Fragments
 jasper.displaySourceFragments.description = Should we include a source fragment \
  in exception messages, which could be displayed to the developer
+
+default.is.session.name = Default Session Value
+default.is.session.description = Should a session be created by default for every \
+ JSP page?



Mime
View raw message