sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r593170 [2/4] - in /incubator/sling/trunk/sling/core: ./ src/main/java/org/apache/sling/core/ src/main/java/org/apache/sling/core/auth/ src/main/java/org/apache/sling/core/components/ src/main/java/org/apache/sling/core/content/ src/main/ja...
Date Thu, 08 Nov 2007 14:38:26 GMT
Copied: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingServletContextImpl.java (from r593045, incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/ComponentContextImpl.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingServletContextImpl.java?p2=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingServletContextImpl.java&p1=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/ComponentContextImpl.java&r1=593045&r2=593170&rev=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/ComponentContextImpl.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/SlingServletContextImpl.java Thu Nov  8 06:38:21 2007
@@ -32,33 +32,30 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.sling.component.ComponentContext;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentRequestDispatcher;
-import org.apache.sling.component.ComponentResponse;
-import org.apache.sling.component.Content;
-import org.apache.sling.content.ContentManager;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.request.RequestPathInfo;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.core.impl.helper.RequestData;
 import org.apache.sling.core.impl.resolver.ResolvedURLImpl;
 import org.apache.sling.core.resolver.ContentResolver;
-import org.apache.sling.core.resolver.ResolvedURL;
+import org.osgi.service.component.ComponentException;
 import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The <code>ComponentContextImpl</code> TODO
+ * The <code>SlingServletContextImpl</code> TODO
  */
-public class ComponentContextImpl implements ComponentContext {
+public class SlingServletContextImpl implements ServletContext {
 
     /** default log */
-    private final Logger log = LoggerFactory.getLogger(ComponentContextImpl.class);
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private ComponentRequestHandlerImpl requestHandler;
+    private SlingMainServlet requestHandler;
 
     private ServiceTracker contentResolver;
 
-    ComponentContextImpl(ComponentRequestHandlerImpl requestHandler) {
+    SlingServletContextImpl(SlingMainServlet requestHandler) {
         this.requestHandler = requestHandler;
 
         this.contentResolver = new ServiceTracker(
@@ -83,7 +80,8 @@
     /**
      * @see javax.servlet.ServletContext#getAttributeNames()
      */
-    public Enumeration getAttributeNames() {
+    @SuppressWarnings("unchecked")
+    public Enumeration<String> getAttributeNames() {
         return getServletContext().getAttributeNames();
     }
 
@@ -97,7 +95,8 @@
     /**
      * @see javax.servlet.ServletContext#getInitParameterNames()
      */
-    public Enumeration getInitParameterNames() {
+    @SuppressWarnings("unchecked")
+    public Enumeration<String> getInitParameterNames() {
         return getServletContext().getInitParameterNames();
     }
 
@@ -122,20 +121,15 @@
         return getServletContext().getMinorVersion();
     }
 
-    /**
-     * @see org.apache.sling.core.component.ComponentContext#getRequestDispatcher(org.apache.sling.core.component.Content)
-     */
-    public ComponentRequestDispatcher getRequestDispatcher(Content content) {
+    public RequestDispatcher getRequestDispatcher(Resource resource) {
         // return no dispatcher if content is null
-        if (content == null) {
+        if (resource == null) {
             log.error("getRequestDispatcher: No content, cannot create request dispatcher");
             return null;
         }
 
-        ResolvedURL resolvedURL = new ResolvedURLImpl(content.getPath(),
-            content);
-
-        return new ComponentRequestDispatcherImpl(resolvedURL);
+        RequestPathInfo resolvedURL = new ResolvedURLImpl(resource.getURI());
+        return new ComponentRequestDispatcherImpl(resource, resolvedURL);
     }
 
     public RequestDispatcher getRequestDispatcher(String path) {
@@ -216,34 +210,37 @@
         return getServletContext().getRealPath(path);
     }
 
-    public Servlet getServlet(String name) throws ServletException {
-        return getServletContext().getServlet(name);
-    }
-
     public String getServletContextName() {
         return getServletContext().getServletContextName();
     }
 
-    public Enumeration getServletNames() {
-        return getServletContext().getServletNames();
+    @Deprecated
+    public Servlet getServlet(String name) {
+        return null;
     }
 
-    public Enumeration getServlets() {
-        return getServletContext().getServlets();
+    @Deprecated
+    public Enumeration<?> getServletNames() {
+        return null;
+    }
+
+    @Deprecated
+    public Enumeration<?> getServlets() {
+        return null;
     }
 
     // ---------- Inner class --------------------------------------------------
 
     private class ComponentRequestDispatcherImpl implements
-            ComponentRequestDispatcher {
+            RequestDispatcher {
 
-        private ResolvedURL resolvedURL;
+        private RequestPathInfo resolvedURL;
 
         private final String path;
 
-        private ComponentRequestDispatcherImpl(ResolvedURL resolvedURL) {
+        private ComponentRequestDispatcherImpl(Resource resource, RequestPathInfo resolvedURL) {
             this.resolvedURL = resolvedURL;
-            this.path = resolvedURL.getOriginalURL();
+            this.path = resolvedURL.getResourcePath();
         }
 
         private ComponentRequestDispatcherImpl(String path) {
@@ -259,7 +256,7 @@
                 // this may throw an exception in case loading fails, which is
                 // ok here, if no content is available at that path null is
                 // return, which results in using the servlet container
-                ComponentRequest cRequest = RequestData.unwrap(request);
+                SlingHttpServletRequest cRequest = RequestData.unwrap(request);
                 String absPath = getAbsolutePath(cRequest, path);
 
                 ContentResolver cr = (ContentResolver) contentResolver.getService();
@@ -276,29 +273,20 @@
             }
         }
 
-        public void include(ComponentRequest request, ComponentResponse response)
-                throws ComponentException, IOException {
-            try {
-                include((ServletRequest) request, (ServletResponse) response);
-            } catch (ServletException se) {
-                throw new ComponentException(se);
-            }
-        }
-
         public void forward(ServletRequest request, ServletResponse response)
                 throws ServletException, IOException {
             // TODO Auto-generated method stub
             // TODO, use servlet container dispatcher !!
         }
 
-        private String getAbsolutePath(ComponentRequest request, String path) {
+        private String getAbsolutePath(SlingHttpServletRequest request, String path) {
             // path is already absolute
             if (path.startsWith("/")) {
                 return path;
             }
 
             // get parent of current request
-            String uri = request.getContent().getPath();
+            String uri = request.getResource().getURI();
             int lastSlash = uri.lastIndexOf('/');
             if (lastSlash >= 0) {
                 uri = uri.substring(0, lastSlash);

Added: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletRequestAdapter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletRequestAdapter.java?rev=593170&view=auto
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletRequestAdapter.java (added)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletRequestAdapter.java Thu Nov  8 06:38:21 2007
@@ -0,0 +1,331 @@
+/*
+ * $Url: $
+ * $Id: $
+ *
+ * Copyright 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.sling.core.impl.adapter;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper;
+
+/**
+ * The <code>SlingServletRequestAdapter</code> class is a
+ * <code>ComponentRequestWrapper</code> which does not delegate to a wrapped
+ * <code>ComponentRequest</code> but to a wrapped
+ * <code>HttpServletRequest</code>. This is required if any user of the
+ * <code>RequestDispatcher.include</code> method uses a
+ * <code>HttpServletRequestWrapper</code> instead of a
+ * <code>ComponentRequestWrapper</code>.
+ */
+public class SlingServletRequestAdapter extends SlingHttpServletRequestWrapper {
+
+    private final HttpServletRequest request;
+
+    public SlingServletRequestAdapter(SlingHttpServletRequest delegatee,
+            HttpServletRequest request) {
+        super(delegatee);
+        this.request = request;
+    }
+
+    @Override
+    public String getLocalAddr() {
+        return request.getLocalAddr();
+    }
+
+    @Override
+    public String getLocalName() {
+        return request.getLocalName();
+    }
+
+    @Override
+    public int getLocalPort() {
+        return request.getLocalPort();
+    }
+
+    @Override
+    public int getRemotePort() {
+        return request.getRemotePort();
+    }
+
+    @Override
+    public String getAuthType() {
+        return request.getAuthType();
+    }
+
+    @Override
+    public String getContextPath() {
+        return request.getContextPath();
+    }
+
+    @Override
+    public Cookie[] getCookies() {
+        return request.getCookies();
+    }
+
+    @Override
+    public long getDateHeader(String name) {
+        return request.getDateHeader(name);
+    }
+
+    @Override
+    public String getHeader(String name) {
+        return request.getHeader(name);
+    }
+
+    @Override
+    public Enumeration<?> getHeaderNames() {
+        return request.getHeaderNames();
+    }
+
+    @Override
+    public Enumeration<?> getHeaders(String name) {
+        return request.getHeaders(name);
+    }
+
+    @Override
+    public int getIntHeader(String name) {
+        return request.getIntHeader(name);
+    }
+
+    @Override
+    public String getMethod() {
+        return request.getMethod();
+    }
+
+    @Override
+    public String getPathInfo() {
+        return request.getPathInfo();
+    }
+
+    @Override
+    public String getPathTranslated() {
+        return request.getPathTranslated();
+    }
+
+    @Override
+    public String getQueryString() {
+        return request.getQueryString();
+    }
+
+    @Override
+    public String getRemoteUser() {
+        return request.getRemoteUser();
+    }
+
+    @Override
+    public String getRequestURI() {
+        return request.getRequestURI();
+    }
+
+    @Override
+    public StringBuffer getRequestURL() {
+        return request.getRequestURL();
+    }
+
+    @Override
+    public String getRequestedSessionId() {
+        return request.getRequestedSessionId();
+    }
+
+    @Override
+    public String getServletPath() {
+        return request.getServletPath();
+    }
+
+    @Override
+    public HttpSession getSession() {
+        return request.getSession();
+    }
+
+    @Override
+    public HttpSession getSession(boolean create) {
+        return request.getSession(create);
+    }
+
+    @Override
+    public Principal getUserPrincipal() {
+        return request.getUserPrincipal();
+    }
+
+    @Override
+    public boolean isRequestedSessionIdFromCookie() {
+        return request.isRequestedSessionIdFromCookie();
+    }
+
+    @Override
+    public boolean isRequestedSessionIdFromURL() {
+        return request.isRequestedSessionIdFromURL();
+    }
+
+    @Override
+    @Deprecated
+    public boolean isRequestedSessionIdFromUrl() {
+        return request.isRequestedSessionIdFromUrl();
+    }
+
+    @Override
+    public boolean isRequestedSessionIdValid() {
+        return request.isRequestedSessionIdValid();
+    }
+
+    @Override
+    public boolean isUserInRole(String role) {
+        return request.isUserInRole(role);
+    }
+
+    @Override
+    public Object getAttribute(String name) {
+        return request.getAttribute(name);
+    }
+
+    @Override
+    public Enumeration<?> getAttributeNames() {
+        return request.getAttributeNames();
+    }
+
+    @Override
+    public String getCharacterEncoding() {
+        return request.getCharacterEncoding();
+    }
+
+    @Override
+    public int getContentLength() {
+        return request.getContentLength();
+    }
+
+    @Override
+    public String getContentType() {
+        return request.getContentType();
+    }
+
+    @Override
+    public ServletInputStream getInputStream() throws IOException {
+        return request.getInputStream();
+    }
+
+    @Override
+    public Locale getLocale() {
+        return request.getLocale();
+    }
+
+    @Override
+    public Enumeration<?> getLocales() {
+        return request.getLocales();
+    }
+
+    @Override
+    public String getParameter(String name) {
+        return request.getParameter(name);
+    }
+
+    @Override
+    public Map<?, ?> getParameterMap() {
+        return request.getParameterMap();
+    }
+
+    @Override
+    public Enumeration<?> getParameterNames() {
+        return request.getParameterNames();
+    }
+
+    @Override
+    public String[] getParameterValues(String name) {
+        return request.getParameterValues(name);
+    }
+
+    @Override
+    public String getProtocol() {
+        return request.getProtocol();
+    }
+
+    @Override
+    public BufferedReader getReader() throws IOException {
+        return request.getReader();
+    }
+
+    @Override
+    @Deprecated
+    public String getRealPath(String path) {
+        return request.getRealPath(path);
+    }
+
+    @Override
+    public String getRemoteAddr() {
+        return request.getRemoteAddr();
+    }
+
+    @Override
+    public String getRemoteHost() {
+        return request.getRemoteHost();
+    }
+
+    @Override
+    public ServletRequest getRequest() {
+        return request;
+    }
+
+    @Override
+    public RequestDispatcher getRequestDispatcher(String path) {
+        return request.getRequestDispatcher(path);
+    }
+
+    @Override
+    public String getScheme() {
+        return request.getScheme();
+    }
+
+    @Override
+    public String getServerName() {
+        return request.getServerName();
+    }
+
+    @Override
+    public int getServerPort() {
+        return request.getServerPort();
+    }
+
+    @Override
+    public boolean isSecure() {
+        return request.isSecure();
+    }
+
+    @Override
+    public void removeAttribute(String name) {
+        request.removeAttribute(name);
+    }
+
+    @Override
+    public void setAttribute(String name, Object o) {
+        request.setAttribute(name, o);
+    }
+
+    @Override
+    public void setCharacterEncoding(String enc)
+            throws UnsupportedEncodingException {
+        request.setCharacterEncoding(enc);
+    }
+}

Added: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletResponseAdapter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletResponseAdapter.java?rev=593170&view=auto
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletResponseAdapter.java (added)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/adapter/SlingServletResponseAdapter.java Thu Nov  8 06:38:21 2007
@@ -0,0 +1,216 @@
+/*
+ * $Url: $
+ * $Id: $
+ *
+ * Copyright 1997-2005 Day Management AG
+ * Barfuesserplatz 6, 4001 Basel, Switzerland
+ * All Rights Reserved.
+ *
+ * This software is the confidential and proprietary information of
+ * Day Management AG, ("Confidential Information"). You shall not
+ * disclose such Confidential Information and shall use it only in
+ * accordance with the terms of the license agreement you entered into
+ * with Day.
+ */
+package org.apache.sling.core.impl.adapter;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper;
+
+/**
+ * The <code>SlingServletResponseAdapter</code> class is a
+ * <code>ComponentResponseWrapper</code> which does not delegate to a wrapped
+ * <code>ComponentResponse</code> but to a wrapped
+ * <code>HttpServletResponse</code>. This is required if any user of the
+ * <code>RequestDispatcher.include</code> method uses a
+ * <code>HttpServletResponseWrapper</code> instead of a
+ * <code>ComponentResponseWrapper</code>. One such case is the Jasper runtime
+ * which does this.
+ */
+public class SlingServletResponseAdapter extends SlingHttpServletResponseWrapper {
+
+    private final HttpServletResponse response;
+
+    public SlingServletResponseAdapter(SlingHttpServletResponse delegatee,
+            HttpServletResponse response) {
+        super(delegatee);
+        this.response = response;
+    }
+
+    @Override
+    public String getContentType() {
+        return response.getContentType();
+    }
+
+    @Override
+    public void setCharacterEncoding(String charset) {
+        response.setCharacterEncoding(charset);
+    }
+
+    @Override
+    public void addCookie(Cookie cookie) {
+        response.addCookie(cookie);
+    }
+
+    @Override
+    public void addDateHeader(String name, long date) {
+        response.addDateHeader(name, date);
+    }
+
+    @Override
+    public void addHeader(String name, String value) {
+        response.addHeader(name, value);
+    }
+
+    @Override
+    public void addIntHeader(String name, int value) {
+        response.addIntHeader(name, value);
+    }
+
+    @Override
+    public boolean containsHeader(String name) {
+        return response.containsHeader(name);
+    }
+
+    @Override
+    @Deprecated
+    public String encodeRedirectUrl(String url) {
+        return response.encodeRedirectUrl(url);
+    }
+
+    @Override
+    public String encodeRedirectURL(String url) {
+        return response.encodeRedirectURL(url);
+    }
+
+    @Override
+    @Deprecated
+    public String encodeUrl(String url) {
+        return response.encodeUrl(url);
+    }
+
+    @Override
+    public String encodeURL(String url) {
+        return response.encodeURL(url);
+    }
+
+    @Override
+    public void sendError(int sc, String msg) throws IOException {
+        response.sendError(sc, msg);
+    }
+
+    @Override
+    public void sendError(int sc) throws IOException {
+        response.sendError(sc);
+    }
+
+    @Override
+    public void sendRedirect(String location) throws IOException {
+        response.sendRedirect(location);
+    }
+
+    @Override
+    public void setDateHeader(String name, long date) {
+        response.setDateHeader(name, date);
+    }
+
+    @Override
+    public void setHeader(String name, String value) {
+        response.setHeader(name, value);
+    }
+
+    @Override
+    public void setIntHeader(String name, int value) {
+        response.setIntHeader(name, value);
+    }
+
+    @Override
+    @Deprecated
+    public void setStatus(int sc, String sm) {
+        response.setStatus(sc, sm);
+    }
+
+    @Override
+    public void setStatus(int sc) {
+        response.setStatus(sc);
+    }
+
+    @Override
+    public void flushBuffer() throws IOException {
+        response.flushBuffer();
+    }
+
+    @Override
+    public int getBufferSize() {
+        return response.getBufferSize();
+    }
+
+    @Override
+    public String getCharacterEncoding() {
+        return response.getCharacterEncoding();
+    }
+
+    @Override
+    public Locale getLocale() {
+        return response.getLocale();
+    }
+
+    @Override
+    public ServletOutputStream getOutputStream() throws IOException {
+        return response.getOutputStream();
+    }
+
+    @Override
+    public ServletResponse getResponse() {
+        return response;
+    }
+
+    @Override
+    public PrintWriter getWriter() throws IOException {
+        return response.getWriter();
+    }
+
+    @Override
+    public boolean isCommitted() {
+        return response.isCommitted();
+    }
+
+    @Override
+    public void reset() {
+        response.reset();
+    }
+
+    @Override
+    public void resetBuffer() {
+        response.resetBuffer();
+    }
+
+    @Override
+    public void setBufferSize(int size) {
+        response.setBufferSize(size);
+    }
+
+    @Override
+    public void setContentLength(int len) {
+        response.setContentLength(len);
+    }
+
+    @Override
+    public void setContentType(String type) {
+        response.setContentType(type);
+    }
+
+    @Override
+    public void setLocale(Locale loc) {
+        response.setLocale(loc);
+    }
+}

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthenticationFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthenticationFilter.java?rev=593170&r1=593169&r2=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthenticationFilter.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthenticationFilter.java Thu Nov  8 06:38:21 2007
@@ -27,20 +27,21 @@
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.sling.component.ComponentContext;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilter;
-import org.apache.sling.component.ComponentFilterChain;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
-import org.apache.sling.core.RequestUtil;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.core.auth.AuthenticationHandler;
-import org.apache.sling.core.impl.RequestData;
-import org.apache.sling.jcr.SlingRepository;
-import org.apache.sling.jcr.TooManySessionsException;
+import org.apache.sling.core.impl.helper.RequestData;
+import org.apache.sling.jcr.api.SlingRepository;
+import org.apache.sling.jcr.api.TooManySessionsException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -84,7 +85,7 @@
  * @scr.property name="filter.order" value="-900" type="Integer" private="true"
  * @scr.service
  */
-public class AuthenticationFilter implements ComponentFilter {
+public class AuthenticationFilter implements Filter {
 
     /**
      * The name of the request attribute containing the AuthenticationHandler
@@ -159,9 +160,13 @@
 
     // ----------- AbstractCoreFilter ------------------------------------------
 
-    public void doFilter(ComponentRequest request, ComponentResponse response,
-            ComponentFilterChain filterChain) throws IOException,
-            ComponentException {
+    public void doFilter(ServletRequest sRequest, ServletResponse sResponse,
+            FilterChain filterChain) throws IOException,
+            ServletException {
+
+        SlingHttpServletRequest request = (SlingHttpServletRequest) sRequest;
+        SlingHttpServletResponse response = (SlingHttpServletResponse) sResponse;
+
         Session session = this.authenticate(request, response);
         if (session != null) {
             try {
@@ -185,7 +190,7 @@
         }
     }
 
-    public void init(ComponentContext context) {}
+    public void init(FilterConfig config) {}
     public void destroy() {}
 
     // ----------- SCR Integration ---------------------------------------------
@@ -253,10 +258,13 @@
                 // remove this handler
                 AuthenticationHandler[] newHandlers = new AuthenticationHandler[this.handlers.length - 1];
 
-                if (i > 0) System.arraycopy(this.handlers, 0, newHandlers, 0, i);
-                if (i < newHandlers.length)
+                if (i > 0) {
+                    System.arraycopy(this.handlers, 0, newHandlers, 0, i);
+                }
+                if (i < newHandlers.length) {
                     System.arraycopy(this.handlers, i + 1, newHandlers, i,
                         newHandlers.length - i);
+                }
 
                 this.handlers = newHandlers;
             }
@@ -291,7 +299,7 @@
      *         be assumed, that during this method enough response information
      *         has been sent to the client.
      */
-    private Session authenticate(ComponentRequest req, ComponentResponse res) {
+    private Session authenticate(SlingHttpServletRequest req, SlingHttpServletResponse res) {
 
         // 0. Get package for request and be anonymous if none configured
         AuthenticationHandler handler = this.getAuthHandler(req);
@@ -363,7 +371,7 @@
      * @return true if the information could be requested or false, if the
      *         request should fail with the appropriate error status
      */
-    public boolean requestAuthentication(ComponentRequest req, ComponentResponse res) {
+    public boolean requestAuthentication(SlingHttpServletRequest req, SlingHttpServletResponse res) {
 
         AuthenticationHandler handler = this.getAuthHandler(req);
         if (handler != null) {
@@ -379,7 +387,7 @@
 
     // ---------- internal ----------------------------------------------------
 
-    private AuthenticationHandler getAuthHandler(ComponentRequest req) {
+    private AuthenticationHandler getAuthHandler(SlingHttpServletRequest req) {
         AuthenticationHandler[] local = this.handlers;
         for (int i = 0; i < local.length; i++) {
             if (local[i].handles(req)) {
@@ -410,7 +418,7 @@
     // }
 
     // TODO
-    private Session getAnonymousSession(ComponentRequest req, ComponentResponse res) {
+    private Session getAnonymousSession(SlingHttpServletRequest req, SlingHttpServletResponse res) {
         // login anonymously, log the exact cause in case of failure
         if (this.anonymousAllowed) {
             try {
@@ -436,7 +444,7 @@
     }
 
     // TODO
-    private void sendFailure(ComponentResponse res) {
+    private void sendFailure(SlingHttpServletResponse res) {
         try {
             res.sendError(HttpServletResponse.SC_FORBIDDEN, "Access Denied");
         } catch (IOException ioe) {
@@ -518,7 +526,7 @@
      *            temporary cookie to be deleted when the browser exits.
      * @param path The cookie path to use. If empty or <code>null</code> the
      */
-    private void sendCookie(ComponentResponse response, String name, String value,
+    private void sendCookie(SlingHttpServletResponse response, String name, String value,
             int maxAge, String path) {
 
         if (path == null || path.length() == 0) {
@@ -562,11 +570,11 @@
      * @see Ticket#impersonate for details on the user configuration
      *      requirements for impersonation.
      */
-    private Session handleImpersonation(ComponentRequest req, ComponentResponse res,
+    private Session handleImpersonation(SlingHttpServletRequest req, SlingHttpServletResponse res,
             Session session) throws LoginException, RepositoryException {
 
         // the current state of impersonation
-        Cookie sudoCookie = RequestUtil.getCookie(req, this.sudoCookieName);
+        Cookie sudoCookie = req.getCookie(sudoCookieName);
         String currentSudo = (sudoCookie == null)
                 ? null
                 : sudoCookie.getValue();

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthorizationHeaderAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthorizationHeaderAuthenticator.java?rev=593170&r1=593169&r2=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthorizationHeaderAuthenticator.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/auth/AuthorizationHeaderAuthenticator.java Thu Nov  8 06:38:21 2007
@@ -27,8 +27,8 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.core.auth.AuthenticationHandler;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
@@ -74,7 +74,7 @@
 
     // ----------- AuthenticationHandler interface ----------------------------
 
-    public boolean handles(ComponentRequest request) {
+    public boolean handles(SlingHttpServletRequest request) {
         return true;
     }
 
@@ -118,8 +118,8 @@
      *         information. In case of DOING_AUTH, the method must have sent a
      *         response indicating that fact to the client.
      */
-    public Credentials authenticate(ComponentRequest request,
-            ComponentResponse response) {
+    public Credentials authenticate(SlingHttpServletRequest request,
+            SlingHttpServletResponse response) {
         return this.extractAuthentication(request);
     }
 
@@ -140,8 +140,8 @@
      * @return true if the information could be requested or false, if the
      *         request should fail with the appropriate error status
      */
-    public boolean requestAuthentication(ComponentRequest request,
-            ComponentResponse response) {
+    public boolean requestAuthentication(SlingHttpServletRequest request,
+            SlingHttpServletResponse response) {
 
         // if the response is already committed, we have a problem !!
         if (response.isCommitted()) {
@@ -183,7 +183,7 @@
     /**
      * Extract the Base64 authentication string from the request
      */
-    protected Credentials extractAuthentication(ComponentRequest request) {
+    protected Credentials extractAuthentication(SlingHttpServletRequest request) {
 
         // Return immediately if the header is missing
         String authHeader = request.getHeader(HEADER_AUTHORIZATION);

Copied: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractSlingFilterChain.java (from r593045, incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractComponentFilterChain.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractSlingFilterChain.java?p2=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractSlingFilterChain.java&p1=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractComponentFilterChain.java&r1=593045&r2=593170&rev=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractComponentFilterChain.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/AbstractSlingFilterChain.java Thu Nov  8 06:38:21 2007
@@ -20,27 +20,29 @@
 
 import java.io.IOException;
 
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilter;
-import org.apache.sling.component.ComponentFilterChain;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 
-public abstract class AbstractComponentFilterChain implements ComponentFilterChain {
+public abstract class AbstractSlingFilterChain implements FilterChain {
+
+    private Filter[] filters;
 
-    private ComponentFilter[] filters;
     private int current;
 
-    protected AbstractComponentFilterChain(ComponentFilter[] filters) {
+    protected AbstractSlingFilterChain(Filter[] filters) {
         this.filters = filters;
         this.current = -1;
     }
 
     /**
-     * @see org.apache.sling.core.component.ComponentFilterChain#doFilter(org.apache.sling.core.component.ComponentRequest, org.apache.sling.core.component.ComponentResponse)
+     * @see org.apache.sling.core.component.ComponentFilterChain#doFilter(org.apache.sling.core.component.ComponentRequest,
+     *      org.apache.sling.core.component.ComponentResponse)
      */
-    public void doFilter(ComponentRequest request, ComponentResponse response)
-            throws IOException, ComponentException {
+    public void doFilter(ServletRequest request, ServletResponse response)
+            throws ServletException, IOException {
         this.current++;
 
         if (this.current < this.filters.length) {
@@ -50,5 +52,6 @@
         }
     }
 
-    protected abstract void render(ComponentRequest request, ComponentResponse response) throws IOException, ComponentException;
+    protected abstract void render(ServletRequest request,
+            ServletResponse response) throws IOException, ServletException;
 }

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ErrorHandlerFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ErrorHandlerFilter.java?rev=593170&r1=593169&r2=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ErrorHandlerFilter.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ErrorHandlerFilter.java Thu Nov  8 06:38:21 2007
@@ -21,81 +21,92 @@
 import java.io.IOException;
 import java.util.Iterator;
 
+import javax.servlet.FilterChain;
+import javax.servlet.Servlet;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.sling.component.Component;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilterChain;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
-import org.apache.sling.component.ComponentResponseWrapper;
-import org.apache.sling.core.Constants;
-import org.apache.sling.core.components.ErrorHandlerComponent;
-import org.apache.sling.core.impl.ContentData;
-import org.apache.sling.core.impl.RequestData;
+import org.apache.sling.api.SlingConstants;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.wrappers.SlingHttpServletResponseWrapper;
+import org.apache.sling.core.impl.helper.ContentData;
+import org.apache.sling.core.impl.helper.RequestData;
+import org.apache.sling.core.servlets.ErrorHandlerServlet;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * The <code>ErrorHandlerFilter</code> TODO
  *
  * @scr.component immediate="true" label="%errhandler.name"
- *      description="%errhandler.description"
+ *                description="%errhandler.description"
  * @scr.property name="service.description" value="Error Handler Filter"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="filter.scope" value="request" private="true"
  * @scr.property name="filter.order" value="-1000" type="Integer" private="true"
  * @scr.service
- * @scr.reference name="Components" interface="org.apache.sling.component.Component"
+ * @scr.reference name="Servlets"
+ *                interface="org.apache.sling.core.servlets.ErrorHandlerServlet"
  *                cardinality="0..n" policy="dynamic"
  */
-public class ErrorHandlerFilter extends ComponentBindingFilter {
+public class ErrorHandlerFilter extends ServletBindingFilter {
 
     /** default log */
     private static final Logger log = LoggerFactory.getLogger(ErrorHandlerFilter.class);
 
-    public void doFilter(ComponentRequest request, ComponentResponse response,
-            ComponentFilterChain filterChain) throws IOException,
-            ComponentException {
+    public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain)
+            throws IOException {
+
+        SlingHttpServletRequest request = (SlingHttpServletRequest) req;
+        SlingHttpServletResponse response = (SlingHttpServletResponse) res;
 
         try {
             filterChain.doFilter(request, new ErrorHandlerResponse(request,
                 response));
         } catch (Throwable throwable) {
             log.error("Error during request processing.", throwable);
-            this.handleError(throwable, request, response);
+            handleError(throwable, request, response);
         }
 
     }
 
-    protected boolean accept(Component component) {
-        return component instanceof ErrorHandlerComponent;
+    @Override
+    protected void servletBound(ServiceReference reference, Servlet servlet) {
+    }
+
+    @Override
+    protected void servletUnbound(ServiceReference reference, Servlet servlet) {
     }
 
     // ---------- internal -----------------------------------------------------
 
-    // TODO: this must be called from ComponentResponseImpl...
-    private void handleError(int status, String message, ComponentRequest request,
-            ComponentResponse response) throws IOException {
+    // TODO: this must be called from SlingHttpServletResponseImpl...
+    private void handleError(int status, String message,
+            SlingHttpServletRequest request, SlingHttpServletResponse response)
+            throws IOException {
 
         // do not handle, if already handling ....
-        if (request.getAttribute(Constants.ERROR_REQUEST_URI) == null) {
+        if (request.getAttribute(SlingConstants.ERROR_REQUEST_URI) == null) {
 
             // find the error handler component
             int checkStatus = status;
             int filter = 10;
             for (;;) {
-                for (Iterator hi = this.getComponents(); hi.hasNext();) {
-                    ErrorHandlerComponent handler = (ErrorHandlerComponent) hi.next();
+                for (Iterator<Servlet> hi = getServlets(); hi.hasNext();) {
+                    ErrorHandlerServlet handler = (ErrorHandlerServlet) hi.next();
                     if (handler.canHandle(checkStatus)) {
 
                         // set the message properties
-                        request.setAttribute(Constants.ERROR_STATUS,
+                        request.setAttribute(SlingConstants.ERROR_STATUS,
                             new Integer(status));
-                        request.setAttribute(Constants.ERROR_MESSAGE, message);
+                        request.setAttribute(SlingConstants.ERROR_MESSAGE,
+                            message);
 
-                        if (this.handleError(handler, request, response)) {
+                        if (handleError(handler, request, response)) {
                             return;
                         }
                     }
@@ -117,29 +128,31 @@
         response.sendError(status, message);
     }
 
-    private void handleError(Throwable throwable, ComponentRequest request,
-            ComponentResponse response) throws ComponentException, IOException {
+    private void handleError(Throwable throwable,
+            SlingHttpServletRequest request, SlingHttpServletResponse response)
+            throws ComponentException, IOException {
 
         // do not handle, if already handling ....
-        if (request.getAttribute(Constants.ERROR_REQUEST_URI) == null) {
+        if (request.getAttribute(SlingConstants.ERROR_REQUEST_URI) == null) {
 
             // find the error handler component
-            Class tClass = throwable.getClass();
+            Class<?> tClass = throwable.getClass();
             while (tClass != null) {
                 String tClassName = tClass.getName();
-                for (Iterator hi = this.getComponents(); hi.hasNext();) {
-                    ErrorHandlerComponent handler = (ErrorHandlerComponent) hi.next();
+                for (Iterator<Servlet> hi = getServlets(); hi.hasNext();) {
+                    ErrorHandlerServlet handler = (ErrorHandlerServlet) hi.next();
                     if (handler.canHandle(tClassName)) {
 
                         // set the message properties
-                        request.setAttribute(Constants.ERROR_EXCEPTION,
+                        request.setAttribute(SlingConstants.ERROR_EXCEPTION,
                             throwable);
-                        request.setAttribute(Constants.ERROR_EXCEPTION_TYPE,
+                        request.setAttribute(
+                            SlingConstants.ERROR_EXCEPTION_TYPE,
                             throwable.getClass());
-                        request.setAttribute(Constants.ERROR_MESSAGE,
+                        request.setAttribute(SlingConstants.ERROR_MESSAGE,
                             throwable.getMessage());
 
-                        if (this.handleError(handler, request, response)) {
+                        if (handleError(handler, request, response)) {
                             return;
                         }
                     }
@@ -162,27 +175,24 @@
         }
     }
 
-    private boolean handleError(ErrorHandlerComponent errorHandler,
-            ComponentRequest request, ComponentResponse response) {
+    private boolean handleError(ErrorHandlerServlet errorHandler,
+            SlingHttpServletRequest request, SlingHttpServletResponse response) {
 
         // set the message properties
         try {
             RequestData requestData = RequestData.getRequestData(request);
             ContentData contentData = requestData.getContentData();
-            if (contentData != null && contentData.getContent() != null) {
-                request.setAttribute(Constants.ERROR_COMPONENT_ID,
-                    contentData.getContent().getComponentId());
+            if (contentData != null && contentData.getResource() != null) {
+                request.setAttribute(
+                    SlingConstants.ERROR_SERVLET_NAME,
+                    contentData.getServlet().getServletConfig().getServletName());
             }
         } catch (ComponentException ce) {
             log.warn("handleError: Called with wrong request type, ignore for now");
         }
 
-        request.setAttribute(Constants.ERROR_REQUEST_URI,
+        request.setAttribute(SlingConstants.ERROR_REQUEST_URI,
             request.getRequestURI());
-        request.setAttribute(Constants.ERROR_SERVLET_NAME,
-            errorHandler.getComponentContext().getServerInfo()); // not
-        // absolutely
-        // correct
 
         // return but keep the attribute to prevent repeated error handling !
         // TODO: Should actually do better for finding about whether we already
@@ -191,6 +201,11 @@
             return false;
         }
 
+        if (request.getAttribute(SlingConstants.ERROR_SERVLET_NAME) == null) {
+            request.setAttribute(SlingConstants.ERROR_SERVLET_NAME,
+                errorHandler.getServletConfig().getServletName());
+        }
+
         // find a component by
         try {
             errorHandler.service(request, response);
@@ -204,40 +219,38 @@
 
     // ---------- internal class -----------------------------------------------
 
-    private class ErrorHandlerResponse extends ComponentResponseWrapper {
+    private class ErrorHandlerResponse extends SlingHttpServletResponseWrapper {
 
-        private ComponentRequest handlerRequest;
+        private SlingHttpServletRequest handlerRequest;
 
-        public ErrorHandlerResponse(ComponentRequest handlerRequest,
-                ComponentResponse delegatee) {
+        public ErrorHandlerResponse(SlingHttpServletRequest handlerRequest,
+                SlingHttpServletResponse delegatee) {
             super(delegatee);
             this.handlerRequest = handlerRequest;
         }
 
         public void sendError(int status) throws IOException {
-            this.checkCommitted();
-
-            ErrorHandlerFilter.this.handleError(status, null, this.handlerRequest, this.getComponentResponse());
+            checkCommitted();
+            handleError(status, null, handlerRequest, getSlingResponse());
         }
 
         public void sendError(int status, String message) throws IOException {
-            this.checkCommitted();
-
-            ErrorHandlerFilter.this.handleError(status, message, this.handlerRequest, this.getComponentResponse());
+            checkCommitted();
+            handleError(status, message, handlerRequest, getSlingResponse());
         }
 
         public void sendRedirect(String location) {
-            this.checkCommitted();
+            checkCommitted();
 
             // TODO: location must be converted into an absolute URL and
             // link-checked
 
-            this.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
-            this.setHeader("Location", location);
+            setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
+            setHeader("Location", location);
         }
 
         private void checkCommitted() {
-            if (this.isCommitted()) {
+            if (isCommitted()) {
                 throw new IllegalStateException(
                     "Response has already been committed");
             }

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/LocaleResolverFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/LocaleResolverFilter.java?rev=593170&r1=593169&r2=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/LocaleResolverFilter.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/LocaleResolverFilter.java Thu Nov  8 06:38:21 2007
@@ -22,28 +22,28 @@
 import java.util.Dictionary;
 import java.util.Locale;
 
-import org.apache.sling.component.ComponentContext;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilter;
-import org.apache.sling.component.ComponentFilterChain;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
-import org.apache.sling.core.impl.RequestData;
-import org.apache.sling.core.locale.LocaleResolver;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 
+import org.apache.sling.core.impl.helper.RequestData;
+import org.apache.sling.core.locale.LocaleResolver;
 
 /**
  * The <code>LocaleResolverFilter</code> TODO
  *
  * @scr.component immediate="true" label="%locale.name"
- *      description="%locale.description"
+ *                description="%locale.description"
  * @scr.property name="service.description" value="Locale Resolver Filter"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="filter.scope" value="request" private="true"
  * @scr.property name="filter.order" value="-700" type="Integer" private="true"
  * @scr.service
  */
-public class LocaleResolverFilter implements ComponentFilter {
+public class LocaleResolverFilter implements Filter {
 
     /**
      * @scr.property value="en_US"
@@ -58,11 +58,12 @@
     private Locale defaultLocale;
 
     /**
-     * @see org.apache.sling.core.component.ComponentFilter#doFilter(org.apache.sling.core.component.ComponentRequest, org.apache.sling.core.component.ComponentResponse, org.apache.sling.core.component.ComponentFilterChain)
+     * @see org.apache.sling.core.component.ComponentFilter#doFilter(org.apache.sling.core.component.ComponentRequest,
+     *      org.apache.sling.core.component.ComponentResponse,
+     *      org.apache.sling.core.component.ComponentFilterChain)
      */
-    public void doFilter(ComponentRequest request, ComponentResponse response,
-            ComponentFilterChain filterChain) throws IOException,
-            ComponentException {
+    public void doFilter(ServletRequest request, ServletResponse response,
+            FilterChain filterChain) throws IOException, ServletException {
 
         // assert request data on request (may throw ComponentException if none)
         RequestData requestData = RequestData.getRequestData(request);
@@ -86,7 +87,7 @@
         filterChain.doFilter(request, response);
     }
 
-    public void init(ComponentContext context) {
+    public void init(FilterConfig config) {
     }
 
     public void destroy() {

Copied: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletBindingFilter.java (from r593045, incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentBindingFilter.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletBindingFilter.java?p2=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletBindingFilter.java&p1=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentBindingFilter.java&r1=593045&r2=593170&rev=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentBindingFilter.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletBindingFilter.java Thu Nov  8 06:38:21 2007
@@ -20,178 +20,178 @@
 
 import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 
-import org.apache.sling.component.Component;
-import org.apache.sling.component.ComponentContext;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilter;
-import org.apache.sling.core.components.AbstractRepositoryComponent;
+import javax.servlet.Filter;
+import javax.servlet.FilterConfig;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+
+import org.apache.sling.core.impl.helper.AbstractServiceReferenceConfig;
+import org.apache.sling.core.impl.helper.SlingServletConfig;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.ComponentException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
-abstract class ComponentBindingFilter implements ComponentFilter {
+abstract class ServletBindingFilter implements Filter {
 
     /** default log */
-    private static final Logger log = LoggerFactory.getLogger(ComponentBindingFilter.class);
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     private ComponentContext componentContext;
-    private Map components;
-    private LinkedHashMap pendingComponents;
 
-    public synchronized void init(ComponentContext context) {
-        this.componentContext = context;
-        this.components = new HashMap();
-
-        if (this.pendingComponents != null) {
-            LinkedHashMap pc = this.pendingComponents;
-            this.pendingComponents = null;
-
-            for (Iterator pi=pc.values().iterator(); pi.hasNext(); ) {
-                Component component = (Component) pi.next();
-
-                // initalize the component
-                try {
-                    component.init(this.componentContext);
-
-                    // only register it internally, if initialization succeeds
-                    log.debug("addComponent: Adding componnent {}", component.getId());
-                    this.insert(this.components, component.getId(), component);
-                } catch (ComponentException ce) {
-                    log.error("Component " + component.getId() + " failed to initialize", ce);
-                } catch (Throwable t) {
-                    log.error("Unexpected problem initializing component " + component.getId(), t);
-                }
-            }
-        }
+    private FilterConfig filterConfig;
+
+    private Map<ServiceReference, Servlet> servlets = new HashMap<ServiceReference, Servlet>();
+
+    private List<ServiceReference> pendingServlets;
+
+    public synchronized void init(FilterConfig config) {
+        this.filterConfig = config;
+        registerPendingServlets();
     }
 
     public synchronized void destroy() {
-        this.componentContext = null;
-        this.pendingComponents = null;
+        unregisterServlets();
+        this.filterConfig = null;
+    }
+
+    protected Iterator<Servlet> getServlets() {
+        return servlets.values().iterator();
+    }
+
+    protected abstract void servletBound(ServiceReference reference,
+            Servlet servlet);
+
+    protected abstract void servletUnbound(ServiceReference reference,
+            Servlet servlet);
+
+    protected synchronized void activate(ComponentContext componentContext) {
+        this.componentContext = componentContext;
+        registerPendingServlets();
     }
 
-    protected Component getComponent(String id) {
-        return (Component) this.components.get(id);
+    protected synchronized void deactivate(ComponentContext componentContext) {
+        unregisterServlets();
+        this.componentContext = null;
     }
 
-    protected Iterator getComponents() {
-        return this.components.values().iterator();
-    }
-
-    protected abstract boolean accept(Component component);
-
-    protected synchronized void bindComponent(Component component) {
-        if (this.accept(component)) {
-            if (this.componentContext != null) {
-                // initalize the component
-                try {
-                    component.init(this.componentContext);
-
-                    // only register it internally, if initialization succeeds
-                    log.debug("addComponent: Adding componnent {}", component.getId());
-                    this.update(component.getId(), component);
-                } catch (ComponentException ce) {
-                    log.error("Component " + component.getId() + " failed to initialize", ce);
-                } catch (Throwable t) {
-                    log.error("Unexpected problem initializing component " + component.getId(), t);
-                }
-            } else {
-                // no context yet
-                if (this.pendingComponents == null) {
-                    this.pendingComponents = new LinkedHashMap();
-                }
-                this.pendingComponents.put(component.getId(), component);
+    protected synchronized void bindComponent(ServiceReference reference) {
+
+        if (this.filterConfig == null) {
+
+            // not initialized yet, keep the registration pending
+            if (this.pendingServlets == null) {
+                this.pendingServlets = new LinkedList<ServiceReference>();
             }
+            this.pendingServlets.add(reference);
+
+        } else {
+
+            // initalize the servlet
+            registerServlet(reference);
         }
     }
 
-    protected synchronized void unbindComponent(Component component) {
-        if (this.accept(component)) {
-            // check whether the component is an unintialized one
-            if (this.pendingComponents != null) {
-                if (this.pendingComponents.remove(component.getId()) != null) {
-                    log.debug(
-                        "unbindComponent: Component {} pending initialization unbound",
-                        component.getId());
-                    return;
-                }
-            }
+    protected synchronized void unbindComponent(ServiceReference reference) {
 
-            // only try "removing" if we are active (initialized and not
-            // destroyed)
-            if (this.componentContext != null
-                && this.update(component.getId(), null) != null) {
-                log.debug("removeComponent: Component {} removed",
-                    component.getId());
-
-                // only call destroy, if init succeeded and hence the component
-                // was registered
-                try {
-                    component.destroy();
-                } catch (Throwable t) {
-                    log.error("Unexpected problem destroying component "
-                        + component.getId(), t);
-                }
+        // check whether the component is an unintialized one
+        if (this.pendingServlets != null) {
+            if (this.pendingServlets.remove(reference)) {
+                log.debug(
+                    "unbindComponent: Component {} pending initialization unbound",
+                    reference);
+                return;
             }
         }
+
+        // only try "removing" if we are active (initialized and not
+        // destroyed)
+        unregisterServlet(reference);
     }
 
-    /**
-     *
-     * <p>
-     * This is synchronized to prevent paralell update of the store thus enabling
-     * the loss of updates.
-     *
-     * @param componentId
-     * @param component
-     * @return
-     */
-    private Component update(String componentId, Component component) {
-        // create new working map as a copy of the old
-        Map newStore = new HashMap(this.components);
-
-        // replace the component actually
-        Component replaced = this.insert(newStore, componentId, component);
-
-        // put new store in action now
-        this.components = newStore;
-
-        // return the removed or replaced Component (may be null)
-        return replaced;
-    }
-
-    private Component insert(Map components, String componentId, Component component) {
-        // add or remove component
-        Component replaced;
-        if (component == null) {
-            replaced = (Component) components.remove(componentId);
-        } else {
-            replaced = (Component) components.put(componentId, component);
+    private void registerPendingServlets() {
+        if (pendingServlets != null && filterConfig != null
+            && componentContext != null) {
+
+            List<ServiceReference> pc = this.pendingServlets;
+            this.pendingServlets = null;
+
+            for (ServiceReference reference : pc) {
+                registerServlet(reference);
+            }
         }
 
-        // if a component has been removed from the map; if it is
-        // an AbstractRepository Component, also remove it by path
-        if (replaced instanceof AbstractRepositoryComponent) {
-            components.remove(((AbstractRepositoryComponent) replaced).getPath());
+    }
+
+    private void registerServlet(ServiceReference reference) {
+        Servlet servlet = (Servlet) componentContext.locateService("Servlets",
+            reference);
+        if (servlet == null) {
+            log.error(
+                "bindServlet: Servlet service not available from reference {}",
+                reference);
+            return;
+        }
+
+        String name = AbstractServiceReferenceConfig.getName(reference);
+        if (name == null) {
+            log.error(
+                "registerServlet: Cannot register servlet {} without a servlet name",
+                reference);
+            return;
+        }
+
+        ServletConfig config = createServletConfig(reference, name);
+        try {
+            servlet.init(config);
+
+            // only register it internally, if initialization succeeds
+            log.debug("addComponent: Adding componnent {}", name);
+            servlets.put(reference, servlet);
+            servletBound(reference, servlet);
+        } catch (ComponentException ce) {
+            log.error("Component " + name + " failed to initialize", ce);
+        } catch (Throwable t) {
+            log.error("Unexpected problem initializing component " + name, t);
         }
+    }
 
-        // if the new component is an AbstractRepositoryComponent, register it
-        // by path.
-        if (component instanceof AbstractRepositoryComponent) {
-            replaced = (Component) components.put(
-                ((AbstractRepositoryComponent) component).getPath(), component);
+    private void unregisterServlets() {
+        ServiceReference[] refs = servlets.keySet().toArray(
+            new ServiceReference[servlets.keySet().size()]);
+        for (ServiceReference serviceReference : refs) {
+            unregisterServlet(serviceReference);
+        }
+    }
 
-            // if the by-path registration removed yet another component,
-            // remove if by id (if not componentId)
-            if (replaced != null && !replaced.getId().equals(componentId)) {
-                components.remove(replaced.getId());
+    private void unregisterServlet(ServiceReference reference) {
+        Servlet servlet = servlets.remove(reference);
+        if (servlet != null) {
+
+            servletUnbound(reference, servlet);
+
+            String name = servlet.getServletConfig().getServletName();
+            log.debug("removeComponent: Component {} removed", name);
+
+            // only call destroy, if init succeeded and hence the component
+            // was registered
+            try {
+                servlet.destroy();
+            } catch (Throwable t) {
+                log.error("Unexpected problem destroying component " + name, t);
             }
         }
+    }
 
-        return replaced;
+    private ServletConfig createServletConfig(ServiceReference reference,
+            String servletName) {
+        return new SlingServletConfig(filterConfig.getServletContext(),
+            reference, servletName);
     }
 
 }

Copied: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletResolverFilter.java (from r593045, incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentResolverFilter.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletResolverFilter.java?p2=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletResolverFilter.java&p1=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentResolverFilter.java&r1=593045&r2=593170&rev=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentResolverFilter.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ServletResolverFilter.java Thu Nov  8 06:38:21 2007
@@ -20,41 +20,45 @@
 
 import java.io.IOException;
 import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Map;
 
+import javax.servlet.FilterChain;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.sling.component.Component;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilterChain;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
-import org.apache.sling.component.Content;
-import org.apache.sling.core.components.DefaultComponent;
-import org.apache.sling.core.components.ErrorHandlerComponent;
-import org.apache.sling.core.impl.ContentData;
-import org.apache.sling.core.impl.RequestData;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.core.CoreConstants;
+import org.apache.sling.core.impl.helper.ContentData;
+import org.apache.sling.core.impl.helper.RequestData;
+import org.apache.sling.core.servlets.DefaultServlet;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
- * The <code>ComponentResolverFilter</code> TODO
+ * The <code>ServletResolverFilter</code> TODO
  *
  * @scr.component immediate="true" label="%resolver.name"
- *      description="%resolver.description"
+ *                description="%resolver.description"
  * @scr.property name="service.description" value="Component Resolver Filter"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="filter.scope" value="component" private="true"
  * @scr.property name="filter.order" value="-900" type="Integer" private="true"
  * @scr.service
- * @scr.reference name="Components" interface="org.apache.sling.component.Component"
+ * @scr.reference name="Components" interface="javax.servlet.Servlet"
  *                cardinality="0..n" policy="dynamic"
  */
-public class ComponentResolverFilter extends ComponentBindingFilter {
+public class ServletResolverFilter extends ServletBindingFilter {
 
     /** default log */
-    private static final Logger log = LoggerFactory.getLogger(ComponentResolverFilter.class);
+    private static final Logger log = LoggerFactory.getLogger(ServletResolverFilter.class);
 
     /**
      * @scr.property values.1="/apps/components" values.2="/libs/components"
@@ -65,25 +69,31 @@
 
     private String[] path;
 
+    private Map<String, Servlet> servlets = new HashMap<String, Servlet>();
+
     /**
-     * @see org.apache.sling.core.component.ComponentFilter#doFilter(org.apache.sling.core.component.ComponentRequest, org.apache.sling.core.component.ComponentResponse, org.apache.sling.core.component.ComponentFilterChain)
+     * @see org.apache.sling.core.component.ComponentFilter#doFilter(org.apache.sling.core.component.ComponentRequest,
+     *      org.apache.sling.core.component.ComponentResponse,
+     *      org.apache.sling.core.component.ComponentFilterChain)
      */
-    public void doFilter(ComponentRequest request, ComponentResponse response,
-            ComponentFilterChain filterChain) throws IOException,
-            ComponentException {
+    public void doFilter(ServletRequest req, ServletResponse res,
+            FilterChain filterChain) throws IOException, ServletException {
+
+        SlingHttpServletRequest request = (SlingHttpServletRequest) req;
+        SlingHttpServletResponse response = (SlingHttpServletResponse) res;
 
         ContentData contentData = RequestData.getRequestData(request).getContentData();
 
         if (contentData != null) {
-            // 2.3 check Component
-            Content content = contentData.getContent();
-            String path = content.getPath();
-            Component component = this.resolveComponent(content);
-            if (component != null) {
+            // 2.3 check Servlet
+            Resource resource = contentData.getResource();
+            String path = resource.getURI();
+            Servlet servlet = resolveServlet(resource);
+            if (servlet != null) {
 
-                String compId = component.getId();
+                String compId = servlet.getServletConfig().getServletName();
                 log.debug("Using Component {} for {}", compId, path);
-                contentData.setComponent(component);
+                contentData.setServlet(servlet);
                 filterChain.doFilter(request, response);
                 return;
 
@@ -96,40 +106,78 @@
         response.sendError(HttpServletResponse.SC_NOT_FOUND, "Cannot handle");
     }
 
-    protected boolean accept(Component component) {
-        return !(component instanceof ErrorHandlerComponent);
+    @Override
+    protected void servletBound(ServiceReference reference, Servlet servlet) {
+        Object typeObject = reference.getProperty(CoreConstants.SLING_RESOURCE_TYPES);
+        String name = servlet.getServletConfig().getServletName();
+        if (typeObject instanceof String) {
+            log.debug("servletBound: Servlet {} handles type {}", name,
+                typeObject);
+            servlets.put((String) typeObject, servlet);
+        } else if (typeObject instanceof String[]) {
+            String[] types = (String[]) typeObject;
+            for (String type : types) {
+                log.debug("servletBound: Servlet {} handles type {}", name,
+                    type);
+                servlets.put(type, servlet);
+            }
+        }
+    }
+
+    @Override
+    protected void servletUnbound(ServiceReference reference, Servlet servlet) {
+        Object typeObject = reference.getProperty(CoreConstants.SLING_RESOURCE_TYPES);
+        String name = servlet.getServletConfig().getServletName();
+        if (typeObject instanceof String) {
+            log.debug("servletBound: Servlet {} unregistered for {}", name,
+                typeObject);
+            servlets.remove(typeObject);
+        } else if (typeObject instanceof String[]) {
+            String[] types = (String[]) typeObject;
+            for (String type : types) {
+                log.debug("servletBound: Servlet {} unregistered for  {}", name,
+                    type);
+                servlets.remove(type);
+            }
+        }
+    }
+
+    private Servlet getServlet(String resourceType) {
+        return servlets.get(resourceType);
     }
 
-    private Component resolveComponent(Content content) {
+    private Servlet resolveServlet(Resource resource) {
         // get the component id
-        String compId = content.getComponentId();
+        String type = resource.getResourceType();
 
         // if none, try the path of the content as its component id,
         // this allows direct addressing of components
-        if (compId == null) {
-            log.debug("resolveComponent: Content {} has no componentid, trying path", content.getPath());
-            compId = content.getPath();
+        if (type == null) {
+            log.debug(
+                "resolveComponent: Content {} has no componentid, trying path",
+                resource.getURI());
+            type = resource.getURI();
         }
 
-        Component component = this.getComponent(compId);
-        if (component != null) {
-            return component;
+        Servlet servlet = getServlet(type);
+        if (servlet != null) {
+            return servlet;
         }
 
         // if the component ID might be a realtive path name, check with path
-        if (!compId.startsWith("/")) {
+        if (!type.startsWith("/")) {
 
             // apply any path prefixes
             if (this.path != null) {
 
                 // might be a type name with namespace
-                String relId = compId.replace(':', '/');
+                String relId = type.replace(':', '/');
 
-                for (int i=0; i < this.path.length; i++) {
+                for (int i = 0; i < this.path.length; i++) {
                     String checkid = this.path[i] + relId;
-                    component = this.getComponent(checkid);
-                    if (component != null) {
-                        return component;
+                    servlet = getServlet(checkid);
+                    if (servlet != null) {
+                        return servlet;
                     }
                 }
 
@@ -137,61 +185,65 @@
 
         } else {
             // absolute path name: remove leading slash for further checks
-            compId = compId.substring(1);
+            type = type.substring(1);
         }
 
         // if the path is mapped from a class name, convert the slashes
         // to dots to get a potentially fully qualified class name
         // again, this allows direct addressing of components
-        compId = compId.replace('/', '.');
-        component = this.getComponent(compId);
-        if (component != null) {
-            return component;
+        type = type.replace('/', '.');
+        servlet = this.getServlet(type);
+        if (servlet != null) {
+            return servlet;
         }
 
         // next we try a class name mapping convention of the content class
-        compId = content.getClass().getName();
-        component = this.getComponent(compId);
-        if (component != null) {
-            return component;
+        type = resource.getObject().getClass().getName();
+        servlet = this.getServlet(type);
+        if (servlet != null) {
+            return servlet;
         }
 
         // check whether we have Content suffix to remove
-        if (compId.endsWith("Content")) {
-            compId = compId.substring(0, compId.length()-"Content".length());
-            component = this.getComponent(compId);
-            if (component != null) {
-                return component;
+        if (type.endsWith("Content")) {
+            type = type.substring(0, type.length() - "Content".length());
+            servlet = this.getServlet(type);
+            if (servlet != null) {
+                return servlet;
             }
         }
 
         // add "Component" suffix and check again
-        compId += "Component";
-        component = this.getComponent(compId);
-        if (component != null) {
-            return component;
+        type += "Component";
+        servlet = this.getServlet(type);
+        if (servlet != null) {
+            return servlet;
         }
 
         // use default component
-        component = this.getComponent(DefaultComponent.ID);
-        if (component != null) {
-            return component;
+        servlet = getServlet(DefaultServlet.class.getName());
+        if (servlet != null) {
+            return servlet;
         }
 
         // we exhausted all possibilities and finally fail
-        log.error("resolveComponent: Could not resolve a component for {}", content.getPath());
+        log.error("resolveComponent: Could not resolve a component for {}",
+            resource.getURI());
         return null;
     }
 
-    //---------- SCR Integration ----------------------------------------------
+    // ---------- SCR Integration ----------------------------------------------
 
+    @Override
     protected void activate(ComponentContext context) {
+        super.activate(context);
+
         Dictionary props = context.getProperties();
 
         Object pathObject = props.get(PROP_PATH);
         if (pathObject instanceof String[]) {
             this.path = (String[]) pathObject;
-            for (int i=0; i < this.path.length; i++) {
+            for (int i = 0; i < this.path.length; i++) {
                 // ensure leading slash
                 if (!this.path[i].startsWith("/")) {
                     this.path[i] = "/" + this.path[i];

Copied: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/SlingFilterChainHelper.java (from r593045, incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentFilterChainHelper.java)
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/SlingFilterChainHelper.java?p2=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/SlingFilterChainHelper.java&p1=incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentFilterChainHelper.java&r1=593045&r2=593170&rev=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ComponentFilterChainHelper.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/SlingFilterChainHelper.java Thu Nov  8 06:38:21 2007
@@ -22,37 +22,37 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.sling.component.ComponentFilter;
+import javax.servlet.Filter;
 
 /**
- * The <code>ComponentFilterChainHelper</code> class is used by Sling to
+ * The <code>SlingFilterChainHelper</code> class is used by Sling to
  * support building lists of <code>RenderFilter</code>s. To ensure filter
  * ordering, each filter is optionally registered with an ordering index. If
  * none is provided the default ordering index is Integer.MAX_VALUE to append
  * the filter to the end of the list.
  */
-public class ComponentFilterChainHelper {
+public class SlingFilterChainHelper {
 
     SortedSet<FilterListEntry> filterList;
 
-    ComponentFilter[] filters;
+    Filter[] filters;
 
-    public ComponentFilterChainHelper() {
+    public SlingFilterChainHelper() {
     }
 
-    public synchronized ComponentFilter addFilter(ComponentFilter filter,
+    public synchronized Filter addFilter(Filter filter,
             Long filterId, int order) {
-        this.filters = null;
-        if (this.filterList == null) {
-            this.filterList = new TreeSet<FilterListEntry>();
+        filters = null;
+        if (filterList == null) {
+            filterList = new TreeSet<FilterListEntry>();
         }
-        this.filterList.add(new FilterListEntry(filter, filterId, order));
+        filterList.add(new FilterListEntry(filter, filterId, order));
         return filter;
     }
 
-    public synchronized ComponentFilter[] removeAllFilters() {
+    public synchronized Filter[] removeAllFilters() {
         // will be returned after cleaning the lists
-        ComponentFilter[] removedFilters = getFilters();
+        Filter[] removedFilters = getFilters();
 
         filters = null;
         filterList = null;
@@ -60,9 +60,9 @@
         return removedFilters;
     }
 
-    public synchronized ComponentFilter removeFilter(ComponentFilter filter) {
-        if (this.filterList != null) {
-            this.filters = null;
+    public synchronized Filter removeFilter(Filter filter) {
+        if (filterList != null) {
+            filters = null;
             for (Iterator<FilterListEntry> fi = filterList.iterator(); fi.hasNext();) {
                 FilterListEntry test = fi.next();
                 if (test.getFilter().equals(filter)) {
@@ -76,9 +76,9 @@
         return null;
     }
 
-    public synchronized ComponentFilter removeFilterById(Object filterId) {
-        if (this.filterList != null) {
-            this.filters = null;
+    public synchronized Filter removeFilterById(Object filterId) {
+        if (filterList != null) {
+            filters = null;
             for (Iterator<FilterListEntry> fi = filterList.iterator(); fi.hasNext();) {
                 FilterListEntry test = fi.next();
                 if (test.getFitlerId() == filterId
@@ -98,41 +98,41 @@
      * Returns the list of <code>RenderFilter</code>s added to this instance
      * or <code>null</code> if no filters have been added.
      */
-    public synchronized ComponentFilter[] getFilters() {
-        if (this.filters == null) {
-            if (this.filterList != null && !this.filterList.isEmpty()) {
-                ComponentFilter[] tmp = new ComponentFilter[this.filterList.size()];
+    public synchronized Filter[] getFilters() {
+        if (filters == null) {
+            if (filterList != null && !filterList.isEmpty()) {
+                Filter[] tmp = new Filter[filterList.size()];
                 int i = 0;
                 for (FilterListEntry entry : filterList) {
                     tmp[i] = entry.getFilter();
                     i++;
                 }
-                this.filters = tmp;
+                filters = tmp;
             }
         }
-        return this.filters;
+        return filters;
     }
 
     private static class FilterListEntry implements Comparable<FilterListEntry> {
 
-        private ComponentFilter filter;
+        private Filter filter;
 
         private Long filterId;
 
         private int order;
 
-        FilterListEntry(ComponentFilter filter, Long filterId, int order) {
+        FilterListEntry(Filter filter, Long filterId, int order) {
             this.filter = filter;
             this.filterId = filterId;
             this.order = order;
         }
 
-        ComponentFilter getFilter() {
-            return this.filter;
+        Filter getFilter() {
+            return filter;
         }
 
         Long getFitlerId() {
-            return this.filterId;
+            return filterId;
         }
 
         /**
@@ -140,13 +140,13 @@
          * equals.
          */
         public int compareTo(FilterListEntry other) {
-            if (this == other || this.equals(other)) {
+            if (this == other || equals(other)) {
                 return 0;
             }
 
-            if (this.order < other.order) {
+            if (order < other.order) {
                 return -1;
-            } else if (this.order > other.order) {
+            } else if (order > other.order) {
                 return 1;
             }
 
@@ -169,7 +169,7 @@
 
             if (obj instanceof FilterListEntry) {
                 FilterListEntry other = (FilterListEntry) obj;
-                return this.getFilter().equals(other.getFilter());
+                return getFilter().equals(other.getFilter());
             }
 
             return false;

Modified: incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ThemeResolverFilter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ThemeResolverFilter.java?rev=593170&r1=593169&r2=593170&view=diff
==============================================================================
--- incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ThemeResolverFilter.java (original)
+++ incubator/sling/trunk/sling/core/src/main/java/org/apache/sling/core/impl/filter/ThemeResolverFilter.java Thu Nov  8 06:38:21 2007
@@ -20,17 +20,17 @@
 
 import java.io.IOException;
 
-import org.apache.sling.component.ComponentContext;
-import org.apache.sling.component.ComponentException;
-import org.apache.sling.component.ComponentFilter;
-import org.apache.sling.component.ComponentFilterChain;
-import org.apache.sling.component.ComponentRequest;
-import org.apache.sling.component.ComponentResponse;
-import org.apache.sling.core.impl.RequestData;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.sling.core.impl.helper.RequestData;
 import org.apache.sling.core.theme.Theme;
 import org.apache.sling.core.theme.ThemeResolver;
 
-
 /**
  * The <code>LocaleResolverFilter</code> is an internal global request filter
  * which is used by Sling to resolve the <code>Locale</code> to use during
@@ -40,15 +40,15 @@
  * receives the currently used {@link ThemeResolver} from Sling.
  *
  * @scr.component immediate="true" label="%theme.name"
- *      description="%theme.description"
- * @scr.property name="service.description"
- *      value="Default AuthenticationService implementation"
+ *                description="%theme.description"
+ * @scr.property name="service.description" value="Default AuthenticationService
+ *               implementation"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
  * @scr.property name="filter.scope" value="request" private="true"
  * @scr.property name="filter.order" value="-600" type="Integer" private="true"
  * @scr.service
  */
-public class ThemeResolverFilter implements ComponentFilter {
+public class ThemeResolverFilter implements Filter {
 
     /**
      * The current {@link ThemeResolver} to use or <code>null</code> if the
@@ -64,9 +64,8 @@
      * request. If no theme resolver is assigned, this method just forwards the
      * request to the next filter.
      */
-    public void doFilter(ComponentRequest request, ComponentResponse response,
-            ComponentFilterChain filterChain) throws IOException,
-            ComponentException {
+    public void doFilter(ServletRequest request, ServletResponse response,
+            FilterChain filterChain) throws IOException, ServletException {
 
         if (this.themeResolver != null) {
             Theme theme = this.themeResolver.resolveTheme(request);
@@ -77,23 +76,9 @@
         filterChain.doFilter(request, response);
     }
 
-    public void init(ComponentContext context) {
+    public void init(FilterConfig config) {
     }
 
     public void destroy() {
-    }
-
-    // ---------- Configuration
-
-    /**
-     * Sets the {@link ThemeResolver} to use. This may be <code>null</code> in
-     * which case, themes will not be resolved any more.
-     */
-    protected void bindThemeResolver(ThemeResolver themeResolver) {
-        this.themeResolver = themeResolver;
-    }
-
-    protected void unbindThemeResolver(ThemeResolver themeResolver) {
-        this.themeResolver = null;
     }
 }



Mime
View raw message