You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2003/10/27 05:36:19 UTC
cvs commit: ws-axis/java/webapps/axis/WEB-INF web.xml
gdaniels 2003/10/26 20:36:19
Modified: java/src/org/apache/axis/transport/http AxisHttpSession.java
java/webapps/axis/WEB-INF web.xml
Added: java/src/org/apache/axis/transport/http
AxisHTTPSessionListener.java
Log:
Fix bug:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11815
Upgrade web.xml to servlet 2.3, and introduce a listener class to
handle session lifecycle events. When we get a destroySession()
event, check the session to ensure it's an Axis session, and if so
call destroy() on any ServiceLifecycle-implementing objects
it contains.
Revision Changes Path
1.16 +7 -3 ws-axis/java/src/org/apache/axis/transport/http/AxisHttpSession.java
Index: AxisHttpSession.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/AxisHttpSession.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- AxisHttpSession.java 5 Sep 2003 17:58:52 -0000 1.15
+++ AxisHttpSession.java 27 Oct 2003 04:36:19 -0000 1.16
@@ -68,6 +68,8 @@
*/
public class AxisHttpSession implements Session
{
+ public static final String AXIS_SESSION_MARKER = "axis.isAxisSession";
+
private HttpSession rep;
private HttpServletRequest req;
@@ -78,7 +80,8 @@
public AxisHttpSession(HttpSession realSession)
{
- rep = realSession;
+ if (realSession != null)
+ setRep(realSession);
}
/** Get the internal HttpSession.
@@ -93,9 +96,10 @@
* servlet HttpSession. Not sure if we'll really
* need this method...
*/
- public void setRep(HttpSession realSession)
+ private void setRep(HttpSession realSession)
{
rep = realSession;
+ rep.setAttribute(AXIS_SESSION_MARKER, Boolean.TRUE);
}
/** Get a property from the session
@@ -175,7 +179,7 @@
protected void ensureSession() {
if (rep == null) {
- rep = req.getSession();
+ setRep(req.getSession());
}
}
1.1 ws-axis/java/src/org/apache/axis/transport/http/AxisHTTPSessionListener.java
Index: AxisHTTPSessionListener.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.axis.transport.http;
import org.apache.commons.logging.Log;
import org.apache.axis.components.logger.LogFactory;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSession;
import javax.xml.rpc.server.ServiceLifecycle;
import java.util.Enumeration;
/**
* A simple listener for Servlet 2.3 session lifecycle events.
*
* @author Glen Daniels (gdaniels@apache.org)
*/
public class AxisHTTPSessionListener implements HttpSessionListener {
protected static Log log =
LogFactory.getLog(AxisHTTPSessionListener.class.getName());
/**
* Static method to destroy all ServiceLifecycle objects within an
* Axis session.
*/
static void destroySession(HttpSession session)
{
// Check for our marker so as not to do unneeded work
if (session.getAttribute(AxisHttpSession.AXIS_SESSION_MARKER) == null)
return;
if (log.isDebugEnabled()) {
log.debug("Got destroySession event : " + session);
}
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
Object next = e.nextElement();
if (next instanceof ServiceLifecycle) {
((ServiceLifecycle)next).destroy();
}
}
}
/** No-op for now */
public void sessionCreated(HttpSessionEvent event) {
}
/**
* Called when a session is destroyed by the servlet engine. We use
* the relevant HttpSession to look up an AxisHttpSession, and destroy
* all the appropriate objects stored therein.
*
* @param event the event descriptor passed in by the servlet engine
*/
public void sessionDestroyed(HttpSessionEvent event) {
HttpSession session = event.getSession();
destroySession(session);
}
}
1.16 +12 -3 ws-axis/java/webapps/axis/WEB-INF/web.xml
Index: web.xml
===================================================================
RCS file: /home/cvs/ws-axis/java/webapps/axis/WEB-INF/web.xml,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- web.xml 15 Apr 2003 18:50:39 -0000 1.15
+++ web.xml 27 Oct 2003 04:36:19 -0000 1.16
@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
- "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
+Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
+
+ <listener>
+ <listener-class>org.apache.axis.transport.http.AxisHTTPSessionListener</listener-class>
+ </listener>
+
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
@@ -63,6 +67,11 @@
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
-->
+
+ <session-config>
+ <!-- Default to 5 minute session timeouts -->
+ <session-timeout>5</session-timeout>
+ </session-config>
<!-- currently the W3C havent settled on a media type for WSDL;
http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft