You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2008/02/27 19:24:25 UTC

svn commit: r631669 - in /incubator/sling/trunk: api/src/main/java/org/apache/sling/api/ api/src/main/java/org/apache/sling/api/scripting/ api/src/main/java/org/apache/sling/api/services/ api/src/main/java/org/apache/sling/api/servlets/ api/src/main/ja...

Author: cziegeler
Date: Wed Feb 27 10:24:23 2008
New Revision: 631669

URL: http://svn.apache.org/viewvc?rev=631669&view=rev
Log:
IN PROGRESS - issue SLING-279: ServiceLocator clean up 
https://issues.apache.org/jira/browse/SLING-279
Remove ServiceLocator interface and from request.

Removed:
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/services/ServiceLocator.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/services/ServiceLocatorImpl.java
Modified:
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptResolver.java
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/ServletResolver.java
    incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxFileUploadHandler.java
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostProcessor.java
    incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
    incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/builtin-objects.esp
    incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
    incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
    incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
    incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/RequestData.java
    incubator/sling/trunk/sling/servlets-default/src/test/java/org/apache/sling/servlets/MockSlingHttpServletRequest.java

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/SlingHttpServletRequest.java Wed Feb 27 10:24:23 2008
@@ -33,7 +33,6 @@
 import org.apache.sling.api.request.RequestProgressTracker;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.services.ServiceLocator;
 
 /**
  * The <code>SlingHttpServletRequest</code> defines the interface to provide
@@ -58,7 +57,7 @@
 
     /**
      * Returns the {@link Resource} object on whose behalf the servlet acts.
-     * 
+     *
      * @return The <code>Resource</code> object of this request.
      */
     Resource getResource();
@@ -66,14 +65,14 @@
     /**
      * Returns the {@link ResourceResolver} which resolved the
      * {@link #getResource() resource} of this request.
-     * 
+     *
      * @return The resource resolver
      */
     ResourceResolver getResourceResolver();
 
     /**
      * Returns the {@link RequestPathInfo} pertaining to this request.
-     * 
+     *
      * @return the request path info.
      */
     RequestPathInfo getRequestPathInfo();
@@ -92,7 +91,7 @@
      * <p>
      * This method is a shortcut for
      * <code>getRequestParameterMap().getValue(String)</code>.
-     * 
+     *
      * @param name a <code>String</code> specifying the name of the parameter
      * @return a {@link RequestParameter} representing the single value of the
      *         parameter
@@ -111,7 +110,7 @@
      * <p>
      * This method is a shortcut for
      * <code>getRequestParameterMap().getValues(String)</code>.
-     * 
+     *
      * @param name a <code>String</code> containing the name of the parameter
      *            the value of which is requested
      * @return an array of {@link RequestParameter} objects containing the
@@ -129,7 +128,7 @@
      * {@link RequestParameter} array (<code>RequestParameter[]</code>).
      * <p>
      * If no parameters exist this method returns an empty <code>Map</code>.
-     * 
+     *
      * @return an immutable <code>Map</code> containing parameter names as
      *         keys and parameter values as map values, or an empty
      *         <code>Map</code> if no parameters exist. The keys in the
@@ -146,7 +145,7 @@
      * <p>
      * Returns <code>null</code> if a <code>RequestDispatcher</code> cannot
      * be returned for any reason.
-     * 
+     *
      * @param path a <code>String</code> specifying the pathname to the
      *            resource. If it is relative, it must be relative against the
      *            current servlet.
@@ -166,7 +165,7 @@
      * <p>
      * Returns <code>null</code> if a <code>RequestDispatcher</code> cannot
      * be returned for any reason.
-     * 
+     *
      * @param resource The {@link Resource} instance whose response content may
      *            be included by the returned dispatcher.
      * @param options influence the rendering of the included Resource
@@ -186,7 +185,7 @@
     /**
      * Returns the named cookie from the HTTP request or <code>null</code> if
      * no such cookie exists in the request.
-     * 
+     *
      * @param name The name of the cookie to return.
      * @return The named cookie or <code>null</code> if no such cookie exists.
      */
@@ -199,7 +198,7 @@
      * For included resources this method will returned the same string as
      * returned by the <code>ServletResponse.getContentType()</code> without
      * the character set.
-     * 
+     *
      * @return preferred MIME type of the response
      */
     String getResponseContentType();
@@ -214,14 +213,14 @@
      * containing a single entry which is the same string as returned by the
      * <code>ServletResponse.getContentType()</code> without the character
      * set.
-     * 
+     *
      * @return ordered list of MIME types for the response
      */
     Enumeration<String> getResponseContentTypes();
 
     /**
      * Returns the resource bundle for the given locale.
-     * 
+     *
      * @param locale the locale for which to retrieve the resource bundle. If
      *            this is <code>null</code>, the locale returned by
      *            {@link #getLocale()} is used to select the resource bundle.
@@ -233,13 +232,4 @@
      * Returns the {@link RequestProgressTracker} of this request.
      */
     RequestProgressTracker getRequestProgressTracker();
-
-    /**
-     * Returns a {@link ServiceLocator} instance which may be queried for helper
-     * services such as the
-     * {@link org.apache.sling.api.resource.ResourceResolver},
-     * {@link org.apache.sling.api.scripting.SlingScriptResolver} and
-     * {@link org.apache.sling.api.servlets.ServletResolver}.
-     */
-    ServiceLocator getServiceLocator();
 }

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptResolver.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptResolver.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/scripting/SlingScriptResolver.java Wed Feb 27 10:24:23 2008
@@ -39,9 +39,6 @@
  * resolver as resolution of the servlets to process requests and sub-requests
  * through a <code>RequestDispatcher</code> is handled by the Sling Framework.
  * <p>
- * The servlet resolver service is available from the
- * {@link org.apache.sling.api.services.ServiceLocator} using the interface
- * class as parameter.
  */
 public interface SlingScriptResolver {
 

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/ServletResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/ServletResolver.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/ServletResolver.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/servlets/ServletResolver.java Wed Feb 27 10:24:23 2008
@@ -31,9 +31,6 @@
  * resolver as resolution of the servlets to process requests and sub-requests
  * through a <code>RequestDispatcher</code> is handled by the Sling Framework.
  * <p>
- * The servlet resolver service is available from the
- * {@link org.apache.sling.api.services.ServiceLocator} using the interface
- * class as parameter.
  */
 public interface ServletResolver {
 

Modified: incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java (original)
+++ incubator/sling/trunk/api/src/main/java/org/apache/sling/api/wrappers/SlingHttpServletRequestWrapper.java Wed Feb 27 10:24:23 2008
@@ -34,7 +34,6 @@
 import org.apache.sling.api.request.RequestProgressTracker;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.services.ServiceLocator;
 
 /**
  * The <code>SlingHttpServletRequestWrapper</code> class is a default wrapper
@@ -114,9 +113,4 @@
     public Enumeration<String> getResponseContentTypes() {
         return getSlingRequest().getResponseContentTypes();
     }
-
-    public ServiceLocator getServiceLocator() {
-        return getSlingRequest().getServiceLocator();
-    }
-
 }

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxFileUploadHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxFileUploadHandler.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxFileUploadHandler.java (original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxFileUploadHandler.java Wed Feb 27 10:24:23 2008
@@ -16,10 +16,6 @@
  */
 package org.apache.sling.ujax;
 
-import org.apache.jackrabbit.util.Text;
-import org.apache.sling.api.request.RequestParameter;
-import org.apache.sling.commons.mime.MimeTypeService;
-
 import java.io.IOException;
 import java.util.Calendar;
 
@@ -28,6 +24,10 @@
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
 
+import org.apache.jackrabbit.util.Text;
+import org.apache.sling.api.request.RequestParameter;
+import org.apache.sling.commons.mime.MimeTypeService;
+
 /**
  * Handles file uploads.
  * <p/>
@@ -65,7 +65,7 @@
  * this will create a new node with the type my:file below admin. if the hinted
  * type extends from nt:file an intermediate file node is created otherwise
  * directly a resource node.
- * 
+ *
  * @version $Rev$, $Date$
  */
 public class UjaxFileUploadHandler {
@@ -94,11 +94,17 @@
     private final UjaxPostProcessor ctx;
 
     /**
+     * The mime type service
+     */
+    private final MimeTypeService mimeTypeService;
+
+    /**
      * Constructs file upload handler
      * @param ctx the post processor
      */
-    public UjaxFileUploadHandler(UjaxPostProcessor ctx) {
+    public UjaxFileUploadHandler(UjaxPostProcessor ctx, MimeTypeService mts) {
         this.ctx = ctx;
+        this.mimeTypeService = mts;
     }
 
     /**
@@ -146,7 +152,7 @@
                 typeHint = null;
             }
         }
-        
+
         // also create an nt:file if the name contains an extension
         // the rationale is that if the file name is "important" we want
         // an nt:file, and an image name with an extension is probably "important"
@@ -172,7 +178,7 @@
             name = JCR_CONTENT;
             typeHint = NT_RESOURCE;
         }
-        
+
         // create resource node
         Node res = parent.addNode(name, typeHint);
         ctx.getChangeLog().onCreated(res.getPath());
@@ -187,9 +193,8 @@
         }
         if (contentType == null || contentType.equals("application/octet-stream")) {
             // try to find a better content type
-            MimeTypeService svc = ctx.getRequest().getServiceLocator().getService(MimeTypeService.class);
-            if (svc != null) {
-                contentType = svc.getMimeType(value.getFileName());
+            if (this.mimeTypeService != null) {
+                contentType = this.mimeTypeService.getMimeType(value.getFileName());
             }
             if (contentType == null || contentType.equals("application/octet-stream")) {
                 contentType = "application/octet-stream";

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostProcessor.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostProcessor.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostProcessor.java (original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostProcessor.java Wed Feb 27 10:24:23 2008
@@ -27,6 +27,7 @@
 import org.apache.sling.api.request.RequestParameter;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.wrappers.SlingRequestPaths;
+import org.apache.sling.commons.mime.MimeTypeService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -114,7 +115,8 @@
      */
     public UjaxPostProcessor(SlingHttpServletRequest request, Session session,
                              NodeNameGenerator nodeNameGenerator,
-                             DateParser dateParser) {
+                             DateParser dateParser,
+                             MimeTypeService mimeTypeService) {
         this.request = request;
         this.session = session;
 
@@ -165,7 +167,7 @@
         this.nodeNameGenerator = nodeNameGenerator;
         this.dateParser = dateParser;
         propHandler = new UjaxPropertyValueHandler(this);
-        uploadHandler = new UjaxFileUploadHandler(this);
+        uploadHandler = new UjaxFileUploadHandler(this, mimeTypeService);
     }
 
     /**

Modified: incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java (original)
+++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java Wed Feb 27 10:24:23 2008
@@ -24,31 +24,32 @@
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.jcr.resource.JcrResourceUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * POST servlet that implements the ujax "protocol"
- * 
+ *
  * @scr.service
  *  interface="javax.servlet.Servlet"
- *  
- * @scr.component 
- *  immediate="true" 
+ *
+ * @scr.component
+ *  immediate="true"
  *  metatype="false"
- *  
- * @scr.property 
+ *
+ * @scr.property
  *  name="service.description"
  *  value="ujax Post Servlet"
- *  
- * @scr.property 
- *  name="service.vendor" 
+ *
+ * @scr.property
+ *  name="service.vendor"
  *  value="The Apache Software Foundation"
  *
- * Use this as the default servlet for POST requests for Sling 
- * @scr.property 
- *  name="sling.servlet.resourceTypes" 
+ * Use this as the default servlet for POST requests for Sling
+ * @scr.property
+ *  name="sling.servlet.resourceTypes"
  *  value="sling/servlet/default"
  * @scr.property
  *  name="sling.servlet.methods"
@@ -145,6 +146,11 @@
     private final NodeNameGenerator nodeNameGenerator = new NodeNameGenerator();
 
     /**
+     * @scr.reference
+     */
+    private MimeTypeService mimeTypeService;
+
+    /**
      * utility class for parsing date strings
      */
     private final DateParser dateParser = new DateParser(); {
@@ -193,7 +199,7 @@
         }
 
         // create the post context
-        return new UjaxPostProcessor(request, s, nodeNameGenerator, dateParser);
+        return new UjaxPostProcessor(request, s, nodeNameGenerator, dateParser, mimeTypeService);
     }
 
     /**

Modified: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/builtin-objects.esp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/builtin-objects.esp?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/builtin-objects.esp (original)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/builtin-objects.esp Wed Feb 27 10:24:23 2008
@@ -12,7 +12,7 @@
 		available 
 	-->
 	<%
-		var sc = request.getServiceLocator().getService(Packages.java.lang.String);
+		var sc = sling.getService(Packages.java.lang.String);
 	%>
 	<p>sc:<%= sc %></p>
 	

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java (original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTEI.java Wed Feb 27 10:24:23 2008
@@ -22,7 +22,7 @@
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_NAME;
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESOURCE_RESOLVER_NAME;
 import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_RESPONSE_NAME;
-import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_SERVICE_LOCATOR_NAME;
+import static org.apache.sling.scripting.jsp.taglib.DefineObjectsTag.DEFAULT_SLING_NAME;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -36,7 +36,7 @@
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.services.ServiceLocator;
+import org.apache.sling.api.scripting.SlingScriptHelper;
 
 /**
  * This class defines the scripting variables that are created by the
@@ -82,9 +82,9 @@
 
     /**
      * The name of the tag attribute used to define the name of the
-     * ServiceLocator scripting variable (value is "serviceLocatorName").
+     * SlingScriptHelper scripting variable (value is "slingName").
      */
-    public static final String ATTR_SERVICE_LOCATOR_NAME = "serviceLocatorName";
+    public static final String ATTR_SLING_NAME = "slingName";
 
     /**
      * The name of the tag attribute used to define the name of the
@@ -102,7 +102,7 @@
 
     private static final String NODE_CLASS = Node.class.getName();
 
-    private static final String SERVICE_LOCATOR_CLASS = ServiceLocator.class.getName();
+    private static final String SLING_CLASS = SlingScriptHelper.class.getName();
 
     /**
      * Returns an Array of <code>VariableInfo</code> objects describing
@@ -131,8 +131,8 @@
         addVar(varInfos, data, ATTR_RESOURCE_RESOLVER_NAME,
             DEFAULT_RESOURCE_RESOLVER_NAME, RESOURCE_RESOLVER_CLASS);
 
-        addVar(varInfos, data, ATTR_SERVICE_LOCATOR_NAME,
-            DEFAULT_SERVICE_LOCATOR_NAME, SERVICE_LOCATOR_CLASS);
+        addVar(varInfos, data, ATTR_SLING_NAME,
+            DEFAULT_SLING_NAME, SLING_CLASS);
 
         return varInfos.toArray(new VariableInfo[varInfos.size()]);
 

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java (original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/DefineObjectsTag.java Wed Feb 27 10:24:23 2008
@@ -23,6 +23,7 @@
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.scripting.jsp.util.TagUtil;
 
 /**
@@ -72,9 +73,9 @@
 
     /**
      * Default name for the scripting variable referencing the current
-     * <code>ServiceLocator</code> (value is "serviceLocator").
+     * <code>SlingScriptHelper</code> (value is "sling").
      */
-    public static final String DEFAULT_SERVICE_LOCATOR_NAME = "serviceLocator";
+    public static final String DEFAULT_SLING_NAME = "sling";
 
     private String requestName = DEFAULT_REQUEST_NAME;
 
@@ -90,7 +91,7 @@
 
     private String resourceResolverName = DEFAULT_RESOURCE_RESOLVER_NAME;
 
-    private String serviceLocatorName = DEFAULT_SERVICE_LOCATOR_NAME;
+    private String slingName = DEFAULT_SLING_NAME;
 
     /**
      * Default constructor.
@@ -106,7 +107,7 @@
      * <li>current <code>Resource</code>
      * <li>current <code>Node</code> (if resource is a NodeProvider)
      * <li>current <code>ResourceResolver</code>
-     * <li>current <code>ServiceLocator</code>
+     * <li>current <code>SlingScriptHelper</code>
      * </ul>
      *
      * @return always {@link #EVAL_PAGE}.
@@ -122,7 +123,7 @@
         pageContext.setAttribute(responseName, res);
         pageContext.setAttribute(resourceName, resource);
         pageContext.setAttribute(resourceResolverName, resourceResolver);
-        pageContext.setAttribute(serviceLocatorName, req.getServiceLocator());
+        pageContext.setAttribute(slingName, req.getAttribute(SlingScriptHelper.class.getName()));
 
         Node node = resource.adaptTo(Node.class);
         if (node != null) {
@@ -170,7 +171,7 @@
         this.resourceResolverName = name;
     }
 
-    public void setServiceLocatorName(String name) {
-        this.serviceLocatorName = name;
+    public void setSlingName(String name) {
+        this.slingName = name;
     }
 }

Modified: incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld (original)
+++ incubator/sling/trunk/scripting/jsp-taglib/src/main/resources/META-INF/taglib.tld Wed Feb 27 10:24:23 2008
@@ -134,7 +134,7 @@
             <rtexprvalue>false</rtexprvalue>
         </attribute>
         <attribute>
-            <name>serviceLocatorName</name>
+            <name>slingName</name>
             <required>false</required>
             <rtexprvalue>false</rtexprvalue>
         </attribute>

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=631669&r1=631668&r2=631669&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 Wed Feb 27 10:24:23 2008
@@ -52,8 +52,9 @@
      *             request parameter has an illegal value.
      */
     public void service(SlingScriptHelper scriptHelper) {
+        SlingHttpServletRequest request = scriptHelper.getRequest();
         try {
-            SlingHttpServletRequest request = scriptHelper.getRequest();
+            request.setAttribute(SlingScriptHelper.class.getName(), scriptHelper);
             service(request, scriptHelper.getResponse(), preCompile(request));
         } catch (SlingException se) {
             // rethrow as is
@@ -62,6 +63,8 @@
             throw new SlingIOException(ioe);
         } catch (ServletException se) {
             throw new SlingServletException(se);
+        } finally {
+            request.removeAttribute(SlingScriptHelper.class.getName());
         }
     }
 
@@ -73,7 +76,7 @@
      * trigger parsing all of the request parameters, and not give a servlet the
      * opportunity to call <code>request.setCharacterEncoding()</code> first.
      * </p>
-     * 
+     *
      * @param request The servlet requset we are processing
      * @throws IllegalArgumentException if an invalid parameter value for the
      *             <code>jsp_precompile</code> parameter name is specified

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingHttpServletRequestImpl.java Wed Feb 27 10:24:23 2008
@@ -43,7 +43,6 @@
 import org.apache.sling.api.request.RequestProgressTracker;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.services.ServiceLocator;
 import org.apache.sling.core.impl.parameters.ParameterSupport;
 import org.apache.sling.core.impl.request.RequestData;
 import org.apache.sling.core.impl.request.SlingRequestDispatcher;
@@ -82,10 +81,6 @@
         return getRequestData().getResourceResolver();
     }
 
-    public ServiceLocator getServiceLocator() {
-        return getRequestData().getServiceLocator();
-    }
-
     public RequestProgressTracker getRequestProgressTracker() {
         return getRequestData().getRequestProgressTracker();
     }
@@ -119,7 +114,7 @@
             RequestDispatcherOptions options) {
         return (path != null) ? new SlingRequestDispatcher(path, options) : null;
     }
-    
+
     /**
      * @see javax.servlet.ServletRequestWrapper#getLocale()
      */
@@ -228,13 +223,13 @@
     @SuppressWarnings("unchecked")
     public Enumeration<String> getResponseContentTypes() {
         List<String> result = new ArrayList<String>();
-        
+
         // TODO for now this returns a single value
         final String singleType = getResponseContentType();
         if(singleType!=null) {
             result.add(singleType);
         }
-        
+
         return Collections.enumeration(result);
     }
 

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingMainServlet.java Wed Feb 27 10:24:23 2008
@@ -53,7 +53,6 @@
 import org.apache.sling.api.request.RequestPathInfo;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceNotFoundException;
-import org.apache.sling.api.services.ServiceLocator;
 import org.apache.sling.api.servlets.ServletResolver;
 import org.apache.sling.commons.mime.MimeTypeService;
 import org.apache.sling.core.impl.auth.MissingRepositoryException;
@@ -65,7 +64,6 @@
 import org.apache.sling.core.impl.helper.SlingServletContext;
 import org.apache.sling.core.impl.request.ContentData;
 import org.apache.sling.core.impl.request.RequestData;
-import org.apache.sling.core.impl.services.ServiceLocatorImpl;
 import org.apache.sling.core.servlets.AbstractServiceReferenceConfig;
 import org.apache.sling.core.servlets.ErrorHandler;
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
@@ -145,8 +143,6 @@
 
     private String slingRoot;
 
-    private ServiceLocatorImpl slingServiceLocator;
-
     private SlingAuthenticator slingAuthenticator;
 
     public static final String INCLUDE_COUNTER = "Sling.ScriptHelper.include.counter";
@@ -493,10 +489,6 @@
         return osgiComponentContext.getBundleContext();
     }
 
-    public ServiceLocator getServiceLocator() {
-        return slingServiceLocator;
-    }
-
     public SlingAuthenticator getSlingAuthenticator() {
         return slingAuthenticator;
     }
@@ -558,7 +550,6 @@
 
         // setup servlet request processing helpers
         SlingServletContext tmpServletContext = new SlingServletContext(this);
-        slingServiceLocator = new ServiceLocatorImpl(bundleContext);
         slingAuthenticator = new SlingAuthenticator(bundleContext);
 
         // register the servlet and resources
@@ -631,10 +622,6 @@
         if (slingAuthenticator != null) {
             slingAuthenticator.dispose();
             slingAuthenticator = null;
-        }
-        if (slingServiceLocator != null) {
-            slingServiceLocator.dispose();
-            slingServiceLocator = null;
         }
 
         this.slingServletContext = null;

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/RequestData.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/RequestData.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/RequestData.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/request/RequestData.java Wed Feb 27 10:24:23 2008
@@ -47,7 +47,6 @@
 import org.apache.sling.api.request.RequestProgressTracker;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.api.services.ServiceLocator;
 import org.apache.sling.api.servlets.ServletResolver;
 import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
 import org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper;
@@ -542,10 +541,6 @@
 
     public RequestProgressTracker getRequestProgressTracker() {
         return requestProgressTracker;
-    }
-
-    public ServiceLocator getServiceLocator() {
-        return slingMainServlet.getServiceLocator();
     }
 
     /**

Modified: incubator/sling/trunk/sling/servlets-default/src/test/java/org/apache/sling/servlets/MockSlingHttpServletRequest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlets-default/src/test/java/org/apache/sling/servlets/MockSlingHttpServletRequest.java?rev=631669&r1=631668&r2=631669&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlets-default/src/test/java/org/apache/sling/servlets/MockSlingHttpServletRequest.java (original)
+++ incubator/sling/trunk/sling/servlets-default/src/test/java/org/apache/sling/servlets/MockSlingHttpServletRequest.java Wed Feb 27 10:24:23 2008
@@ -39,7 +39,6 @@
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.SyntheticResource;
-import org.apache.sling.api.services.ServiceLocator;
 
 class MockSlingHttpServletRequest implements SlingHttpServletRequest {
 
@@ -116,10 +115,6 @@
     }
 
     public Enumeration<String> getResponseContentTypes() {
-        return null;
-    }
-
-    public ServiceLocator getServiceLocator() {
         return null;
     }
 



Re: svn commit: r631669 - in /incubator/sling/trunk: api/src/main/java/org/apache/sling/api/ api/src/main/java/org/apache/sling/api/scripting/ api/src/main/java/org/apache/sling/api/services/ api/src/main/java/org/apache/sling/api/servlets/ api/src/main/ja...

Posted by Felix Meschberger <Fe...@day.com>.
Hi,

Am Mittwoch, den 27.02.2008, 18:24 +0000 schrieb cziegeler@apache.org:
> Author: cziegeler
> Date: Wed Feb 27 10:24:23 2008
> New Revision: 631669
> 
> URL: http://svn.apache.org/viewvc?rev=631669&view=rev
> Log:
> IN PROGRESS - issue SLING-279: ServiceLocator clean up 
> https://issues.apache.org/jira/browse/SLING-279
> Remove ServiceLocator interface and from request.
> 
> ...
> Modified:
> incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java
> URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java?rev=631669&r1=631668&r2=631669&view=diff
> ==============================================================================
> --- incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java (original)
> +++ incubator/sling/trunk/launchpad/launchpad-servlets/src/main/java/org/apache/sling/ujax/UjaxPostServlet.java Wed Feb 27 10:24:23 2008
> @@ -145,6 +146,11 @@
>      private final NodeNameGenerator nodeNameGenerator = new NodeNameGenerator();
>  
>      /**
> +     * @scr.reference
> +     */
> +    private MimeTypeService mimeTypeService;
> +
> +    /**
>       * utility class for parsing date strings
>       */
>      private final DateParser dateParser = new DateParser(); {

This makes the MimeTypeService reference a static mandatory, that is the
UjaxPostServlet will only be available when the MimeTypeService is
available (which it generally is but from the use inside the
UjaxFileUploadHandler is not required).

I think, we can safely define this reference optional as in:

   @scr.reference cardinality="0..1" policy="dynamic"

WDYT ?

Regards
Felix