FELIX-4939 : Add support for http session id listener
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1687565 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/bridge/pom.xml b/http/bridge/pom.xml
index c25afde..18f4bd9 100644
--- a/http/bridge/pom.xml
+++ b/http/bridge/pom.xml
@@ -28,7 +28,7 @@
<name>Apache Felix Http Bridge</name>
<artifactId>org.apache.felix.http.bridge</artifactId>
- <version>2.4.0-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<scm>
diff --git a/http/proxy/pom.xml b/http/proxy/pom.xml
index ea74712..7479681 100644
--- a/http/proxy/pom.xml
+++ b/http/proxy/pom.xml
@@ -28,7 +28,7 @@
<name>Apache Felix Http Proxy</name>
<artifactId>org.apache.felix.http.proxy</artifactId>
- <version>2.3.3-SNAPSHOT</version>
+ <version>3.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<scm>
@@ -45,7 +45,7 @@
<configuration>
<instructions>
<Export-Package>
- org.apache.felix.http.proxy;version=2.1.0
+ org.apache.felix.http.proxy
</Export-Package>
</instructions>
</configuration>
diff --git a/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyListener.java b/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyListener.java
index f615552..175b5f2 100644
--- a/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyListener.java
+++ b/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyListener.java
@@ -26,6 +26,7 @@
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionIdListener;
import javax.servlet.http.HttpSessionListener;
import org.osgi.framework.BundleContext;
@@ -42,7 +43,11 @@
*
* @since 2.1.0
*/
-public class ProxyListener implements HttpSessionAttributeListener, HttpSessionListener, ServletContextListener
+public class ProxyListener
+ implements HttpSessionAttributeListener,
+ HttpSessionListener,
+ HttpSessionIdListener,
+ ServletContextListener
{
private ServletContext servletContext;
@@ -51,15 +56,19 @@
private HttpSessionListener sessionDispatcher;
+ private HttpSessionIdListener sessionIdDispatcher;
+
private HttpSessionAttributeListener attributeDispatcher;
// ---------- ServletContextListener
+ @Override
public void contextInitialized(final ServletContextEvent sce)
{
this.servletContext = sce.getServletContext();
}
+ @Override
public void contextDestroyed(final ServletContextEvent sce)
{
if (this.eventDispatcherTracker != null)
@@ -72,6 +81,7 @@
// ---------- HttpSessionListener
+ @Override
public void sessionCreated(final HttpSessionEvent se)
{
final HttpSessionListener sessionDispatcher = getSessionDispatcher();
@@ -81,6 +91,7 @@
}
}
+ @Override
public void sessionDestroyed(final HttpSessionEvent se)
{
final HttpSessionListener sessionDispatcher = getSessionDispatcher();
@@ -90,8 +101,21 @@
}
}
+ // ---------- HttpSessionIdListener
+
+ @Override
+ public void sessionIdChanged(final HttpSessionEvent event, final String oldSessionId)
+ {
+ final HttpSessionIdListener sessionIdDispatcher = getSessionIdDispatcher();
+ if (sessionIdDispatcher != null)
+ {
+ sessionIdDispatcher.sessionIdChanged(event, oldSessionId);
+ }
+ }
+
// ---------- HttpSessionAttributeListener
+ @Override
public void attributeAdded(final HttpSessionBindingEvent se)
{
final HttpSessionAttributeListener attributeDispatcher = getAttributeDispatcher();
@@ -101,6 +125,7 @@
}
}
+ @Override
public void attributeRemoved(final HttpSessionBindingEvent se)
{
final HttpSessionAttributeListener attributeDispatcher = getAttributeDispatcher();
@@ -110,6 +135,7 @@
}
}
+ @Override
public void attributeReplaced(final HttpSessionBindingEvent se)
{
final HttpSessionAttributeListener attributeDispatcher = getAttributeDispatcher();
@@ -139,10 +165,12 @@
Filter filter = createFilter(bundleContext, null);
this.eventDispatcherTracker = new ServiceTracker(bundleContext, filter, null)
{
+ @Override
public void removedService(ServiceReference reference, Object service)
{
ProxyListener.this.sessionDispatcher = null;
ProxyListener.this.attributeDispatcher = null;
+ ProxyListener.this.sessionIdDispatcher = null;
super.removedService(reference, service);
}
};
@@ -170,6 +198,19 @@
return this.sessionDispatcher;
}
+ private HttpSessionIdListener getSessionIdDispatcher()
+ {
+ if (this.sessionIdDispatcher == null)
+ {
+ final Object dispatcher = getDispatcher();
+ if (dispatcher instanceof HttpSessionIdListener)
+ {
+ this.sessionIdDispatcher = (HttpSessionIdListener) dispatcher;
+ }
+ }
+ return this.sessionIdDispatcher;
+ }
+
private HttpSessionAttributeListener getAttributeDispatcher()
{
if (this.attributeDispatcher == null)