Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 85291 invoked from network); 30 Jul 2010 21:37:08 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Jul 2010 21:37:08 -0000 Received: (qmail 58970 invoked by uid 500); 30 Jul 2010 21:37:08 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 58921 invoked by uid 500); 30 Jul 2010 21:37:08 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 58914 invoked by uid 99); 30 Jul 2010 21:37:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jul 2010 21:37:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jul 2010 21:37:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2C81923889E9; Fri, 30 Jul 2010 21:35:49 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r980972 - /sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java Date: Fri, 30 Jul 2010 21:35:49 -0000 To: commits@sling.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100730213549.2C81923889E9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Fri Jul 30 21:35:48 2010 New Revision: 980972 URL: http://svn.apache.org/viewvc?rev=980972&view=rev Log: SLING-1004 Add support for the sling.home.prefix system property for the Sling web application. This property may be used to define root location for sling.home folders for Sling web applications deployed without a sling.home init-param Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java?rev=980972&r1=980971&r2=980972&view=diff ============================================================================== --- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java (original) +++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java Fri Jul 30 21:35:48 2010 @@ -60,6 +60,24 @@ public class SlingServlet extends Generi */ private static final int MAX_START_FAILURES = 20; + /** + * The name of the system property which may be set to define the default + * prefix for the sling.home value generated from the Sling servlet context + * path. + * + * @see #toSlingHome(String) + */ + private static final String SLING_HOME_PREFIX = "sling.home.prefix"; + + /** + * The default value to be used as the prefix for the sling.home value + * generated from the Sling servlet context path if the + * {@link #SLING_HOME_PREFIX sling.home.prefix} system property is not set. + * + * @see #toSlingHome(String) + */ + private static final String SLING_HOME_PREFIX_DEFAULT = "sling/"; + private String slingHome; private Loader loader; @@ -418,9 +436,26 @@ public class SlingServlet extends Generi return slingHome; } - // convert the servlet context path to a directory path for sling.home + /** + * Converts the servlet context path to a path used for the sling.home + * property. The servlet context path is converted to a simple name by + * replacing all slash characters in the path with underscores (or a single + * underscore for the root context path being empty or null). Next the + * result is prefixed with either value of the + * sling.home.prefix system property or the (default prefix) + * sling/. + * + * @param contextPath + * @return + */ private String toSlingHome(String contextPath) { - String prefix = "sling/"; + String prefix = System.getProperty(SLING_HOME_PREFIX, + SLING_HOME_PREFIX_DEFAULT); + + if (!prefix.endsWith("/")) { + prefix = prefix.concat("/"); + } + if (contextPath == null || contextPath.length() == 0) { return prefix + "_"; }