Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 35952 invoked from network); 10 Jan 2011 07:37:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Jan 2011 07:37:37 -0000 Received: (qmail 64287 invoked by uid 500); 10 Jan 2011 07:37:37 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 64207 invoked by uid 500); 10 Jan 2011 07:37:35 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 64188 invoked by uid 99); 10 Jan 2011 07:37:34 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jan 2011 07:37:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jan 2011 07:37:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 43D502388903; Mon, 10 Jan 2011 07:37:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1057098 - in /sling/trunk/launchpad/base: ./ src/main/java/org/apache/sling/launchpad/base/shared/ src/main/java/org/apache/sling/launchpad/base/webapp/ src/main/java/org/apache/sling/launchpad/webapp/ src/main/webapp/WEB-INF/ Date: Mon, 10 Jan 2011 07:37:13 -0000 To: commits@sling.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110110073713.43D502388903@eris.apache.org> Author: fmeschbe Date: Mon Jan 10 07:37:12 2011 New Revision: 1057098 URL: http://svn.apache.org/viewvc?rev=1057098&view=rev Log: SLING-1924 Upgrade to Apache Felix HTTP Bundles 2.0.5-SNAPSHOT and add support for Http Session event forwarding to the ProxyListener. Added: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java (with props) sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java (with props) Modified: sling/trunk/launchpad/base/pom.xml sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/SharedConstants.java sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java sling/trunk/launchpad/base/src/main/webapp/WEB-INF/web.xml Modified: sling/trunk/launchpad/base/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/pom.xml?rev=1057098&r1=1057097&r2=1057098&view=diff ============================================================================== --- sling/trunk/launchpad/base/pom.xml (original) +++ sling/trunk/launchpad/base/pom.xml Mon Jan 10 07:37:12 2011 @@ -38,7 +38,7 @@ - 2.0.4 + 2.0.5-SNAPSHOT Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/SharedConstants.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/SharedConstants.java?rev=1057098&r1=1057097&r2=1057098&view=diff ============================================================================== --- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/SharedConstants.java (original) +++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/shared/SharedConstants.java Mon Jan 10 07:37:12 2011 @@ -54,6 +54,14 @@ public interface SharedConstants { public static final String DEFAULT_SLING_SERVLET = "org.apache.sling.launchpad.base.webapp.SlingServletDelegate"; /** + * The fully qualified name of the implementation of the Servlet API + * ServletContextListener, HttpSessionListener, and + * HttpSessionAttributeListener interfaces to which the respective events + * are forwarded. + */ + public static final String DEFAULT_SLING_LISTENER = "org.apache.sling.launchpad.base.webapp.SlingHttpSessionListenerDelegate"; + + /** * The name of the file providing the Launcher JAR. On the one hand this is * the name used to place the JAR file sling.home to use for startup. On the * other hand, this is the name of the file in the archive (see Added: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java?rev=1057098&view=auto ============================================================================== --- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java (added) +++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java Mon Jan 10 07:37:12 2011 @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.launchpad.base.webapp; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.http.HttpSessionAttributeListener; +import javax.servlet.http.HttpSessionBindingEvent; +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.apache.felix.http.proxy.ProxyListener; + +public class SlingHttpSessionListenerDelegate implements + HttpSessionAttributeListener, HttpSessionListener, + ServletContextListener { + + private final ProxyListener proxyListener = new ProxyListener(); + + // ---------- ServletContextListener + + public void contextInitialized(final ServletContextEvent sce) { + this.proxyListener.contextInitialized(sce); + } + + public void contextDestroyed(final ServletContextEvent sce) { + this.proxyListener.contextDestroyed(sce); + } + + // ---------- HttpSessionListener + + public void sessionCreated(HttpSessionEvent se) { + proxyListener.sessionCreated(se); + } + + public void sessionDestroyed(HttpSessionEvent se) { + proxyListener.sessionDestroyed(se); + } + + // ---------- HttpSessionAttributeListener + + public void attributeAdded(HttpSessionBindingEvent se) { + proxyListener.attributeAdded(se); + } + + public void attributeRemoved(HttpSessionBindingEvent se) { + proxyListener.attributeRemoved(se); + } + + public void attributeReplaced(HttpSessionBindingEvent se) { + proxyListener.attributeReplaced(se); + } + +} Propchange: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingHttpSessionListenerDelegate.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev Url Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java?rev=1057098&r1=1057097&r2=1057098&view=diff ============================================================================== --- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java (original) +++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingServlet.java Mon Jan 10 07:37:12 2011 @@ -167,6 +167,8 @@ public class SlingServlet extends Generi */ @Override public void destroy() { + SlingSessionListener.stopDelegatee(); + if (sling != null) { sling.destroy(); } @@ -200,6 +202,7 @@ public class SlingServlet extends Generi // clear the reference to the framework sling = null; + SlingSessionListener.stopDelegatee(); } /** @@ -220,6 +223,7 @@ public class SlingServlet extends Generi synchronized (this) { if (startingSling == null) { sling = null; + SlingSessionListener.stopDelegatee(); } } @@ -347,6 +351,8 @@ public class SlingServlet extends Generi slingLauncher.setSlingHome(slingHome); } + SlingSessionListener.startDelegate(sling.getClass().getClassLoader()); + try { log("Starting launcher ..."); sling.init(getServletConfig()); Added: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java?rev=1057098&view=auto ============================================================================== --- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java (added) +++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java Mon Jan 10 07:37:12 2011 @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.launchpad.webapp; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.http.HttpSessionAttributeListener; +import javax.servlet.http.HttpSessionBindingEvent; +import javax.servlet.http.HttpSessionEvent; +import javax.servlet.http.HttpSessionListener; + +import org.apache.sling.launchpad.base.shared.SharedConstants; + +public class SlingSessionListener implements HttpSessionAttributeListener, + HttpSessionListener, ServletContextListener { + + private static ServletContext servletContext; + + private static ServletContextListener delegateeContextListener; + + private static HttpSessionListener delegateeSessionListener; + + private static HttpSessionAttributeListener delegateeSessionAttributeListener; + + static void startDelegate(final ClassLoader classLoader) { + Object delegatee = null; + try { + Class delegateeClass = classLoader.loadClass(SharedConstants.DEFAULT_SLING_LISTENER); + delegatee = delegateeClass.newInstance(); + } catch (Exception e) { + servletContext.log( + "Delegatee Event Listener class " + + SharedConstants.DEFAULT_SLING_LISTENER + + " cannot be loaded or instantiated; Http Session Event forwarding is disabled", + e); + } + + if (delegatee instanceof ServletContextListener) { + delegateeContextListener = (ServletContextListener) delegatee; + delegateeContextListener.contextInitialized(new ServletContextEvent( + servletContext)); + + delegateeSessionListener = (HttpSessionListener) delegatee; + delegateeSessionAttributeListener = (HttpSessionAttributeListener) delegatee; + } + } + + static void stopDelegatee() { + if (delegateeContextListener != null) { + delegateeContextListener.contextDestroyed(new ServletContextEvent( + servletContext)); + } + + delegateeContextListener = null; + delegateeSessionListener = null; + delegateeSessionAttributeListener = null; + } + + public void contextInitialized(ServletContextEvent sce) { + SlingSessionListener.servletContext = sce.getServletContext(); + } + + public void contextDestroyed(ServletContextEvent sce) { + stopDelegatee(); + SlingSessionListener.servletContext = null; + } + + public void sessionCreated(HttpSessionEvent se) { + final HttpSessionListener delegateeSessionListener = SlingSessionListener.delegateeSessionListener; + if (delegateeSessionListener != null) { + delegateeSessionListener.sessionCreated(se); + } + } + + public void sessionDestroyed(HttpSessionEvent se) { + final HttpSessionListener delegateeSessionListener = SlingSessionListener.delegateeSessionListener; + if (delegateeSessionListener != null) { + delegateeSessionListener.sessionDestroyed(se); + } + } + + public void attributeAdded(HttpSessionBindingEvent se) { + final HttpSessionAttributeListener delegateeSessionAttributeListener = SlingSessionListener.delegateeSessionAttributeListener; + if (delegateeSessionAttributeListener != null) { + delegateeSessionAttributeListener.attributeAdded(se); + } + } + + public void attributeRemoved(HttpSessionBindingEvent se) { + final HttpSessionAttributeListener delegateeSessionAttributeListener = SlingSessionListener.delegateeSessionAttributeListener; + if (delegateeSessionAttributeListener != null) { + delegateeSessionAttributeListener.attributeRemoved(se); + } + } + + public void attributeReplaced(HttpSessionBindingEvent se) { + final HttpSessionAttributeListener delegateeSessionAttributeListener = SlingSessionListener.delegateeSessionAttributeListener; + if (delegateeSessionAttributeListener != null) { + delegateeSessionAttributeListener.attributeReplaced(se); + } + } + +} Propchange: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/webapp/SlingSessionListener.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Rev Url Modified: sling/trunk/launchpad/base/src/main/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/webapp/WEB-INF/web.xml?rev=1057098&r1=1057097&r2=1057098&view=diff ============================================================================== --- sling/trunk/launchpad/base/src/main/webapp/WEB-INF/web.xml (original) +++ sling/trunk/launchpad/base/src/main/webapp/WEB-INF/web.xml Mon Jan 10 07:37:12 2011 @@ -23,6 +23,13 @@ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> Sling Launchpad Web Application + + + + org.apache.sling.launchpad.webapp.SlingSessionListener + + + Sling Servlet sling