You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by kn...@apache.org on 2001/09/05 11:34:11 UTC
cvs commit: jakarta-turbine-3/proposals/kasper/newrundata/servlet HttpContext.java HttpCookie.java HttpRequest.java HttpResponse.java HttpSession.java
knielsen 01/09/05 02:34:11
Added: proposals/kasper/newrundata/servlet HttpContext.java
HttpCookie.java HttpRequest.java HttpResponse.java
HttpSession.java
Log:
Start of new Rundata proposal
Revision Changes Path
1.1 jakarta-turbine-3/proposals/kasper/newrundata/servlet/HttpContext.java
Index: HttpContext.java
===================================================================
package org.apache.turbine.newrundata.servlet;
import java.net.MalformedURLException;
import java.net.URL;
import javax.servlet.ServletContext;
/**
*
* Implements the {@link org.apache.cocoon.environment.Context} interface
*/
public class HttpContext {
/** The ServletContext */
private ServletContext servletContext = null;
/**
* Constructs a HttpContext object from a ServletContext object
*/
public HttpContext (ServletContext servletContext)
{
this.servletContext = servletContext;
}
public Object getAttribute(String name)
{
return servletContext.getAttribute(name);
}
public URL getResource(String path)
throws MalformedURLException
{
return servletContext.getResource(path);
}
public String getRealPath(String path)
throws MalformedURLException
{
if (path.equals("/") == true) {
String value = servletContext.getRealPath(path);
if (value == null) {
// Try to figure out the path of the root from that of WEB-INF
value = this.servletContext.getResource("/WEB-INF").toString();
value = value.substring(0,value.length()-"WEB-INF".length());
}
return value;
}
return servletContext.getRealPath(path);
}
public String getMimeType(String file)
{
return servletContext.getMimeType(file);
}
public String getInitParameter(String name)
{
return servletContext.getInitParameter(name);
}
}
1.1 jakarta-turbine-3/proposals/kasper/newrundata/servlet/HttpCookie.java
Index: HttpCookie.java
===================================================================
package org.apache.turbine.newrundata.servlet;
import org.apache.turbine.newrundata.Cookie;
/**
*
* Creates a cookie, a small amount of information sent by a servlet to
* a Web browser, saved by the browser, and later sent back to the server.
* A cookie's value can uniquely
* identify a client, so cookies are commonly used for session management.
*
* <p>A cookie has a name, a single value, and optional attributes
* such as a comment, path and domain qualifiers, a maximum age, and a
* version number. Some Web browsers have bugs in how they handle the
* optional attributes, so use them sparingly to improve the interoperability
* of your servlets.
*
* <p>The servlet sends cookies to the browser by using the
* {@link HttpResponse#addCookie} method, which adds
* fields to HTTP response headers to send cookies to the
* browser, one at a time. The browser is expected to
* support 20 cookies for each Web server, 300 cookies total, and
* may limit cookie size to 4 KB each.
*
* <p>The browser returns cookies to the servlet by adding
* fields to HTTP request headers. Cookies can be retrieved
* from a request by using the {@link HttpRequest#getCookies} method.
* Several cookies might have the same name but different path attributes.
*
* <p>Cookies affect the caching of the Web pages that use them.
* HTTP 1.0 does not cache pages that use cookies created with
* this class. This class does not support the cache control
* defined with HTTP 1.1.
*
* <p>This class supports both the Version 0 (by Netscape) and Version 1
* (by RFC 2109) cookie specifications. By default, cookies are
* created using Version 0 to ensure the best interoperability.
*
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @author <a href="mailto:knielsen@apache.org">Kasper Nielsen</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/09/05 09:34:11 $
*
*/
public final class HttpCookie
implements Cookie {
private javax.servlet.http.Cookie cookie;
public HttpCookie(String name, String value)
{
this.cookie = new javax.servlet.http.Cookie(name, value);
}
public HttpCookie(javax.servlet.http.Cookie cookie)
{
this.cookie = cookie;
}
public javax.servlet.http.Cookie getServletCookie()
{
this.checkState();
return this.cookie;
}
/**
* Constructs a cookie with a specified name and value.
*
* <p>The name must conform to RFC 2109. That means it can contain
* only ASCII alphanumeric characters and cannot contain commas,
* semicolons, or white space or begin with a $ character. The cookie's
* name cannot be changed after creation.
*
* <p>The value can be anything the server chooses to send. Its
* value is probably of interest only to the server. The cookie's
* value can be changed after creation with the
* <code>setValue</code> method.
*
* <p>By default, cookies are created according to the Netscape
* cookie specification. The version can be changed with the
* <code>setVersion</code> method.
*
*
* @param name a <code>String</code> specifying the name of the cookie
*
* @param value a <code>String</code> specifying the value of the cookie
*
* @throws IllegalArgumentException if the cookie name contains illegal characters
* (for example, a comma, space, or semicolon)
* or it is one of the tokens reserved for use
* by the cookie protocol
* @see #setValue
* @see #setVersion
*
*/
public void init(String name, String value)
{
if (this.cookie == null) {
this.cookie = new javax.servlet.http.Cookie(name, value);
} else {
throw new IllegalStateException("Cookie is already initialised");
}
}
private void checkState()
{
if (this.cookie == null) {
throw new IllegalStateException("Cookie is not initialised");
}
}
/**
*
* Specifies a comment that describes a cookie's purpose.
* The comment is useful if the browser presents the cookie
* to the user. Comments
* are not supported by Netscape Version 0 cookies.
*
* @param purpose a <code>String</code> specifying the comment
* to display to the user
*
* @see #getComment
*
*/
public void setComment(String purpose)
{
this.checkState();
this.cookie.setComment(purpose);
}
/**
* Returns the comment describing the purpose of this cookie, or
* <code>null</code> if the cookie has no comment.
*
* @return a <code>String</code> containing the comment,
* or <code>null</code> if none
*
* @see #setComment
*
*/
public String getComment()
{
this.checkState();
return this.cookie.getComment();
}
/**
*
* Specifies the domain within which this cookie should be presented.
*
* <p>The form of the domain name is specified by RFC 2109. A domain
* name begins with a dot (<code>.foo.com</code>) and means that
* the cookie is visible to servers in a specified Domain Name System
* (DNS) zone (for example, <code>www.foo.com</code>, but not
* <code>a.b.foo.com</code>). By default, cookies are only returned
* to the server that sent them.
*
*
* @param pattern a <code>String</code> containing the domain name
* within which this cookie is visible;
* form is according to RFC 2109
*
* @see #getDomain
*
*/
public void setDomain(String pattern)
{
this.checkState();
this.cookie.setDomain(pattern);
}
/**
* Returns the domain name set for this cookie. The form of
* the domain name is set by RFC 2109.
*
* @return a <code>String</code> containing the domain name
*
* @see #setDomain
*
*/
public String getDomain()
{
this.checkState();
return this.cookie.getDomain();
}
/**
* Sets the maximum age of the cookie in seconds.
*
* <p>A positive value indicates that the cookie will expire
* after that many seconds have passed. Note that the value is
* the <i>maximum</i> age when the cookie will expire, not the cookie's
* current age.
*
* <p>A negative value means
* that the cookie is not stored persistently and will be deleted
* when the Web browser exits. A zero value causes the cookie
* to be deleted.
*
* @param expiry an integer specifying the maximum age of the
* cookie in seconds; if negative, means
* the cookie is not stored; if zero, deletes
* the cookie
*
*
* @see #getMaxAge
*
*/
public void setMaxAge(int expiry)
{
this.checkState();
this.cookie.setMaxAge(expiry);
}
/**
* Returns the maximum age of the cookie, specified in seconds,
* By default, <code>-1</code> indicating the cookie will persist
* until browser shutdown.
*
*
* @return an integer specifying the maximum age of the
* cookie in seconds; if negative, means
* the cookie persists until browser shutdown
*
*
* @see #setMaxAge
*
*/
public int getMaxAge()
{
this.checkState();
return this.cookie.getMaxAge();
}
/**
* Specifies a path for the cookie
* to which the client should return the cookie.
*
* <p>The cookie is visible to all the pages in the directory
* you specify, and all the pages in that directory's subdirectories.
* A cookie's path must include the servlet that set the cookie,
* for example, <i>/catalog</i>, which makes the cookie
* visible to all directories on the server under <i>/catalog</i>.
*
* <p>Consult RFC 2109 (available on the Internet) for more
* information on setting path names for cookies.
*
*
* @param uri a <code>String</code> specifying a path
*
*
* @see #getPath
*
*/
public void setPath(String uri)
{
this.checkState();
this.cookie.setPath(uri);
}
/**
* Returns the path on the server
* to which the browser returns this cookie. The
* cookie is visible to all subpaths on the server.
*
*
* @return a <code>String</code> specifying a path that contains
* a servlet name, for example, <i>/catalog</i>
*
* @see #setPath
*
*/
public String getPath()
{
this.checkState();
return this.cookie.getPath();
}
/**
* Indicates to the browser whether the cookie should only be sent
* using a secure protocol, such as HTTPS or SSL.
*
* <p>The default value is <code>false</code>.
*
* @param flag if <code>true</code>, sends the cookie from the browser
* to the server using only when using a secure protocol;
* if <code>false</code>, sent on any protocol
*
* @see #getSecure
*
*/
public void setSecure(boolean flag)
{
this.checkState();
this.cookie.setSecure(flag);
}
/**
* Returns <code>true</code> if the browser is sending cookies
* only over a secure protocol, or <code>false</code> if the
* browser can send cookies using any protocol.
*
* @return <code>true</code> if the browser can use
* any standard protocol; otherwise, <code>false</code>
*
* @see #setSecure
*
*/
public boolean getSecure()
{
this.checkState();
return this.cookie.getSecure();
}
/**
* Returns the name of the cookie. The name cannot be changed after
* creation.
*
* @return a <code>String</code> specifying the cookie's name
*
*/
public String getName()
{
this.checkState();
return this.cookie.getName();
}
/**
*
* Assigns a new value to a cookie after the cookie is created.
* If you use a binary value, you may want to use BASE64 encoding.
*
* <p>With Version 0 cookies, values should not contain white
* space, brackets, parentheses, equals signs, commas,
* double quotes, slashes, question marks, at signs, colons,
* and semicolons. Empty values may not behave the same way
* on all browsers.
*
* @param newValue a <code>String</code> specifying the new value
*
*
* @see #getValue
* @see Cookie
*
*/
public void setValue(String newValue)
{
this.checkState();
this.cookie.setValue(newValue);
}
/**
* Returns the value of the cookie.
*
* @return a <code>String</code> containing the cookie's
* present value
*
* @see #setValue
* @see Cookie
*
*/
public String getValue()
{
this.checkState();
return this.cookie.getValue();
}
/**
* Returns the version of the protocol this cookie complies
* with. Version 1 complies with RFC 2109,
* and version 0 complies with the original
* cookie specification drafted by Netscape. Cookies provided
* by a browser use and identify the browser's cookie version.
*
*
* @return 0 if the cookie complies with the
* original Netscape specification; 1
* if the cookie complies with RFC 2109
*
* @see #setVersion
*
*/
public int getVersion()
{
this.checkState();
return this.cookie.getVersion();
}
/**
* Sets the version of the cookie protocol this cookie complies
* with. Version 0 complies with the original Netscape cookie
* specification. Version 1 complies with RFC 2109.
*
* <p>Since RFC 2109 is still somewhat new, consider
* version 1 as experimental; do not use it yet on production sites.
*
*
* @param v 0 if the cookie should comply with
* the original Netscape specification;
* 1 if the cookie should comply with RFC 2109
*
* @see #getVersion
*
*/
public void setVersion(int v)
{
this.checkState();
this.cookie.setVersion(v);
}
}
1.1 jakarta-turbine-3/proposals/kasper/newrundata/servlet/HttpRequest.java
Index: HttpRequest.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.turbine.newrundata.servlet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Vector;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import org.apache.turbine.newrundata.Cookie;
import org.apache.turbine.newrundata.Request;
//import org.apache.cocoon.environment.Session;
/**
* Implements the {@link javax.servlet.http.HttpServletRequest} interface
* to provide request information for HTTP servlets.
*
* @author <a href="mailto:giacomo@apache,org">Giacomo Pati</a>
* @version CVS $Id: HttpRequest.java,v 1.1 2001/09/05 09:34:11 knielsen Exp $
*/
public class HttpRequest implements Request {
/** The real HttpServletRequest object */
private HttpServletRequest req = null;
/**
* Creates a HttpServletRequest based on a real HttpServletRequest object
*/
protected HttpRequest (HttpServletRequest req) {
super ();
this.req = req;
}
/* The HttpServletRequest interface methods */
public Object get(String name)
{
String[] values = req.getParameterValues(name);
if (values == null) return null;
if (values.length == 1)
{
return values[0];
}
if (values.length > 1)
{
Vector vect = new Vector(values.length);
for (int i = 0; i < values.length; i++)
{
vect.add(values[i]);
}
return vect;
}
return null;
}
public String getAuthType() {
return this.req.getAuthType();
}
private Cookie[] wrappedCookies = null;
private Map wrappedCookieMap = null;
public Cookie[] getCookies() {
if (this.wrappedCookies == null) {
this.wrappedCookieMap = new HashMap();
javax.servlet.http.Cookie[] cookies = this.req.getCookies();
if (cookies != null) {
this.wrappedCookies = new Cookie[cookies.length];
for(int i=0; i<cookies.length;i++) {
HttpCookie cookie = new HttpCookie(cookies[i]);
this.wrappedCookies[i] = cookie;
this.wrappedCookieMap.put(cookie.getName(),cookie);
}
}
}
return this.wrappedCookies;
}
public Map getCookieMap() {
if (this.wrappedCookieMap != null)
{
getCookies();
}
return Collections.unmodifiableMap(this.wrappedCookieMap);
}
public long getDateHeader(String name) {
return this.req.getDateHeader(name);
}
public String getHeader(String name) {
return this.req.getHeader(name);
}
public Enumeration getHeaders(String name) {
return this.req.getHeaders(name);
}
public Enumeration getHeaderNames() {
return this.req.getHeaderNames();
}
public int getIntHeader(String name) {
return this.req.getIntHeader(name);
}
public String getMethod() {
return this.req.getMethod();
}
public String getPathInfo() {
return this.req.getPathInfo();
}
public String getPathTranslated() {
return this.req.getPathTranslated();
}
public String getContextPath() {
return this.req.getContextPath();
}
public String getQueryString() {
return this.req.getQueryString();
}
public String getRemoteUser() {
return this.req.getRemoteUser();
}
public boolean isUserInRole(String role) {
return this.req.isUserInRole(role);
}
//okay this what was getUser once
public java.security.Principal getUserPrincipal() {
return this.req.getUserPrincipal();
}
public String getRequestedSessionId() {
return this.req.getRequestedSessionId();
}
public String getRequestURI() {
return this.req.getRequestURI();
}
public String getServletPath() {
return this.req.getServletPath();
}
/*
public Session getSession(boolean create) {
javax.servlet.http.HttpSession session = this.req.getSession(create);
if(session != null)
return new HttpSession(session);
return null;
}
public Session getSession() {
return this.getSession(true);
}
*/
public boolean isRequestedSessionIdValid() {
return this.req.isRequestedSessionIdValid();
}
public boolean isRequestedSessionIdFromCookie() {
return this.req.isRequestedSessionIdFromCookie();
}
public boolean isRequestedSessionIdFromURL() {
return this.req.isRequestedSessionIdFromURL();
}
/*
* @deprecated As of Version 2.1 of the Java Servlet
* API, use {@link #isRequestedSessionIdFromURL}
*instead.
public boolean isRequestedSessionIdFromUrl() {
return this.req.isRequestedSessionIdFromUrl();
}
*/
/* The ServletRequest interface methods */
public Object getAttribute(String name) {
return this.req.getAttribute(name);
}
public Enumeration getAttributeNames() {
return this.req.getAttributeNames();
}
public String getCharacterEncoding() {
return this.req.getCharacterEncoding();
}
public int getContentLength() {
return this.req.getContentLength();
}
public String getContentType() {
return this.req.getContentType();
}
public ServletInputStream getInputStream() throws IOException {
return this.req.getInputStream();
}
public String getParameter(String name) {
return this.req.getParameter(name);
}
public Enumeration getParameterNames() {
return this.req.getParameterNames();
}
public String[] getParameterValues(String name) {
return this.req.getParameterValues(name);
}
public String getProtocol() {
return this.req.getProtocol();
}
public String getScheme() {
return this.req.getScheme();
}
public String getServerName() {
return this.req.getServerName();
}
public int getServerPort() {
return this.req.getServerPort();
}
public BufferedReader getReader() throws IOException {
return this.req.getReader();
}
public String getRemoteAddr() {
return this.req.getRemoteAddr();
}
public String getRemoteHost() {
return this.req.getRemoteHost();
}
public void setAttribute(String name, Object o) {
this.req.setAttribute(name, o);
}
public void removeAttribute(String name) {
this.req.removeAttribute(name);
}
public Locale getLocale() {
return this.req.getLocale();
}
public Enumeration getLocales() {
return this.req.getLocales();
}
public boolean isSecure() {
return this.req.isSecure();
}
public RequestDispatcher getRequestDispatcher(String path) {
return this.req.getRequestDispatcher(path);
}
/**
* @deprecated As of Version 2.1 of the Java Servlet API,
* use {@link javax.servlet.ServletContext#getRealPath} instead.
public String getRealPath(String path) {
return this.req.getRealPath(path);
}
*/
}
1.1 jakarta-turbine-3/proposals/kasper/newrundata/servlet/HttpResponse.java
Index: HttpResponse.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
package org.apache.turbine.newrundata.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.turbine.newrundata.Cookie;
import org.apache.turbine.newrundata.Response;
/**
*
* Implements the {@link HttpServletResponse} interface to provide HTTP-specific
* functionality in sending a response. For example, it has methods
* to access HTTP headers and cookies.
*
* @author <a href="mailto:knielsen@apache,org">Kasper Nielsen</a>
* @version CVS $Id: HttpResponse.java,v 1.1 2001/09/05 09:34:11 knielsen Exp $
*/
public class HttpResponse implements Response {
/** The real HttpServletResponse object */
private HttpServletResponse res = null;
/**
* Creates a HttpServletResponse based on a real HttpServletResponse object
*/
protected HttpResponse (HttpServletResponse res) {
super ();
this.res = res;
}
/**
* Create a new cookie which is not added to the response
*/
public Cookie createCookie(String name, String value) {
return new HttpCookie(name, value);
}
public void addCookie(Cookie cookie) {
if (cookie instanceof HttpCookie) {
this.res.addCookie(((HttpCookie)cookie).getServletCookie());
} else {
javax.servlet.http.Cookie newCookie;
newCookie = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue());
newCookie.setComment(cookie.getComment());
newCookie.setDomain(cookie.getDomain());
newCookie.setMaxAge(cookie.getMaxAge());
newCookie.setPath(cookie.getPath());
newCookie.setSecure(cookie.getSecure());
newCookie.setVersion(cookie.getVersion());
this.res.addCookie(newCookie);
}
}
public boolean containsHeader(String name) {
return this.res.containsHeader(name);
}
public String encodeURL(String url) {
if (url != null && url.indexOf(";jsessionid=") != -1)
return url;
return this.res.encodeURL(url);
}
public String encodeRedirectURL(String url) {
if (url != null && url.indexOf(";jsessionid=") != -1)
return url;
return this.res.encodeRedirectURL(url);
}
public void sendError(int sc, String msg) throws IOException {
this.res.sendError(sc, msg);
}
public void sendError(int sc) throws IOException {
this.res.sendError(sc);
}
public void sendRedirect(String location) throws IOException {
this.res.sendRedirect(location);
}
public void setDateHeader(String name, long date) {
this.res.setDateHeader(name, date);
}
public void addDateHeader(String name, long date) {
this.res.addDateHeader(name, date);
}
public void setHeader(String name, String value) {
this.res.setHeader(name, value);
}
public void addHeader(String name, String value) {
this.res.addHeader(name, value);
}
public void setIntHeader(String name, int value) {
this.res.setIntHeader(name, value);
}
public void addIntHeader(String name, int value) {
this.res.addIntHeader(name, value);
}
public void setStatus(int sc) {
this.res.setStatus(sc);
}
/**
* @deprecated As of version 2.1, use encodeURL(String url) instead
public String encodeUrl(String url) {
return this.res.encodeUrl(url);
}
*/
/**
* @deprecated As of version 2.1, use
* encodeRedirectURL(String url) instead
public String encodeRedirectUrl(String url) {
return this.res.encodeRedirectUrl(url);
}
*/
/**
* @deprecated As of version 2.1, due to ambiguous meaning of the
* message parameter. To set a status code
* use <code>setStatus(int)</code>, to send an error with a description
* use <code>sendError(int, String)</code>.
public void setStatus(int sc, String sm) {
this.res.setStatus(sc, sm);
}
*/
/* The ServletResponse interface methods */
public String getCharacterEncoding() {
return this.res.getCharacterEncoding();
}
public ServletOutputStream getOutputStream() throws IOException {
return this.res.getOutputStream();
}
public PrintWriter getWriter() throws IOException {
return this.res.getWriter();
}
public void setContentLength(int len) {
this.res.setContentLength(len);
}
public void setContentType(String type) {
this.res.setContentType(type);
}
public void setBufferSize(int size) {
this.res.setBufferSize(size);
}
public int getBufferSize() {
return this.res.getBufferSize();
}
public void flushBuffer() throws IOException {
this.res.flushBuffer();
}
public boolean isCommitted() {
return this.res.isCommitted();
}
public void reset() {
this.res.reset();
}
public void setLocale(Locale loc) {
this.res.setLocale(loc);
}
public Locale getLocale() {
return this.res.getLocale();
}
}
1.1 jakarta-turbine-3/proposals/kasper/newrundata/servlet/HttpSession.java
Index: HttpSession.java
===================================================================
package org.apache.turbine.newrundata.servlet;
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
import java.util.Enumeration;
import java.util.Map;
import org.apache.turbine.newrundata.Session;
/**
*
* Provides a way to identify a user across more than one page
* request or visit to a Web site and to store information about that user.
*
* <p>Cocoon uses this interface to create a session
* between a client and the "cocoon server". The session persists
* for a specified time period, across more than one connection or
* page request from the user. A session usually corresponds to one
* user, who may visit a site many times. The server can maintain a
* session in many ways such as using cookies or rewriting URLs.
*
* <p>This interface allows Cocoon to
* <ul>
* <li>View and manipulate information about a session, such as
* the session identifier, creation time, and last accessed time
* <li>Bind objects to sessions, allowing user information to persist
* across multiple user connections
* </ul>
*
* <p>Session information is scoped only to the current context
* (<code>Context</code>), so information stored in one context
* will not be directly visible in another.
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @author <a href="mailto:knielsen@apache.org">Kasper Nielsen</a>
* @version CVS $Revision: 1.1 $ $Date: 2001/09/05 09:34:11 $
*
*/
public final class HttpSession
implements Session {
private javax.servlet.http.HttpSession session;
private Map tempStorage;
/**
* Construct a new session from an HttpSession
*/
public HttpSession(javax.servlet.http.HttpSession session, Map tempStorage)
{
this.session = session;
this.tempStorage=tempStorage;
}
/**
*
* Returns the time when this session was created, measured
* in milliseconds since midnight January 1, 1970 GMT.
*
* @return a <code>long</code> specifying
* when this session was created,
* expressed in
* milliseconds since 1/1/1970 GMT
*
* @exception IllegalStateException if this method is called on an
* invalidated session
*
*/
public long getCreationTime() {
return this.session.getCreationTime();
}
/**
*
* Returns a string containing the unique identifier assigned
* to this session. The identifier is assigned
* by the context container and is implementation dependent.
*
* @return a string specifying the identifier
* assigned to this session
*
* @exeption IllegalStateException if this method is called on an
* invalidated session
*
*/
public String getId() {
return this.session.getId();
}
/**
*
* Returns the last time the client sent a request associated with
* this session, as the number of milliseconds since midnight
* January 1, 1970 GMT.
*
* <p>Actions that your application takes, such as getting or setting
* a value associated with the session, do not affect the access
* time.
*
* @return a <code>long</code>
* representing the last time
* the client sent a request associated
* with this session, expressed in
* milliseconds since 1/1/1970 GMT
*
* @exeption IllegalStateException if this method is called on an
* invalidated session
*
*/
public long getLastAccessedTime() {
return this.session.getLastAccessedTime();
}
/**
*
* Specifies the time, in seconds, between client requests before the
* contextcontainer will invalidate this session. A negative time
* indicates the session should never timeout.
*
* @param interval An integer specifying the number
* of seconds
*
*/
public void setMaxInactiveInterval(int interval) {
this.session.setMaxInactiveInterval(interval);
}
/**
* Returns the maximum time interval, in seconds, that
* the context container will keep this session open between
* client accesses. After this interval, the context container
* will invalidate the session. The maximum time interval can be set
* with the <code>setMaxInactiveInterval</code> method.
* A negative time indicates the session should never timeout.
*
*
* @return an integer specifying the number of
* seconds this session remains open
* between client requests
*
* @see #setMaxInactiveInterval
*
*
*/
public int getMaxInactiveInterval() {
return this.session.getMaxInactiveInterval();
}
/**
*
* Returns the object bound with the specified name in this session, or
* <code>null</code> if no object is bound under the name.
*
* @param name a string specifying the name of the object
*
* @return the object with the specified name
*
* @exception IllegalStateException if this method is called on an
* invalidated session
*
*/
public Object getAttribute(String name) {
return this.session.getAttribute(name);
}
/**
*
* Returns an <code>Enumeration</code> of <code>String</code> objects
* containing the names of all the objects bound to this session.
*
* @return an <code>Enumeration</code> of
* <code>String</code> objects specifying the
* names of all the objects bound to
* this session
*
* @exception IllegalStateException if this method is called on an
* invalidated session
*
*/
public Enumeration getAttributeNames() {
return this.session.getAttributeNames();
}
/**
* Binds an object to this session, using the name specified.
* If an object of the same name is already bound to the session,
* the object is replaced.
*
*
* @param name the name to which the object is bound;
* cannot be null
*
* @param value the object to be bound; cannot be null
*
* @exception IllegalStateException if this method is called on an
* invalidated session
*
*/
public void setAttribute(String name, Object value) {
this.session.setAttribute(name, value);
}
/**
*
* Removes the object bound with the specified name from
* this session. If the session does not have an object
* bound with the specified name, this method does nothing.
*
*
* @param name the name of the object to
* remove from this session
*
* @exception IllegalStateException if this method is called on an
* invalidated session
*/
public void removeAttribute(String name) {
this.session.removeAttribute(name);
}
/**
*
* Invalidates this session
* to it.
*
* @exception IllegalStateException if this method is called on an
* already invalidated session
*
*/
public void invalidate() {
this.session.invalidate();
}
/**
*
* Returns <code>true</code> if the client does not yet know about the
* session or if the client chooses not to join the session. For
* example, if the server used only cookie-based sessions, and
* the client had disabled the use of cookies, then a session would
* be new on each request.
*
* @return <code>true</code> if the
* server has created a session,
* but the client has not yet joined
*
* @exception IllegalStateException if this method is called on an
* already invalidated session
*
*/
public boolean isNew() {
return this.session.isNew();
}
/**
*
* Returns a <code>Map</code> where arbitary session data can be stored
* The implementation _must_ provide a Threadsafe Map
* Everything that is put into the Map should also be ThreadSafe
*
*
* @exception IllegalStateException if this method is called on an
* already invalidated session
*
*/
public Map getSessionTempStorage()
{
return this.tempStorage;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: cvs commit:jakarta-turbine-3/proposals/kasper/newrundata/servlet HttpContext.javaHttpCookie.java HttpRequest.java HttpResponse.java HttpSession.java
Posted by Kasper Nielsen <ne...@kav.dk>.
sure, its nowhere from finished.
- Kasper
----- Original Message -----
From: "Jon Stevens" <jo...@latchkey.com>
To: "turbine-dev" <tu...@jakarta.apache.org>
Sent: Wednesday, September 05, 2001 11:47 AM
Subject: Re: cvs
commit:jakarta-turbine-3/proposals/kasper/newrundata/servlet
HttpContext.javaHttpCookie.java HttpRequest.java HttpResponse.java
HttpSession.java
> on 9/5/01 2:34 AM, "knielsen@apache.org" <kn...@apache.org> wrote:
>
> > knielsen 01/09/05 02:34:11
> >
> > Added: proposals/kasper/newrundata/servlet HttpContext.java
> > HttpCookie.java HttpRequest.java HttpResponse.java
> > HttpSession.java
> > Log:
> > Start of new Rundata proposal
>
> You are really going to have to explain the need for this.
>
> The code is also going to have to be cleaned up quite a bit.
>
> -jon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: cvs commit:
jakarta-turbine-3/proposals/kasper/newrundata/servlet HttpContext.java
HttpCookie.java HttpRequest.java HttpResponse.java HttpSession.java
Posted by Jon Stevens <jo...@latchkey.com>.
on 9/5/01 2:34 AM, "knielsen@apache.org" <kn...@apache.org> wrote:
> knielsen 01/09/05 02:34:11
>
> Added: proposals/kasper/newrundata/servlet HttpContext.java
> HttpCookie.java HttpRequest.java HttpResponse.java
> HttpSession.java
> Log:
> Start of new Rundata proposal
You are really going to have to explain the need for this.
The code is also going to have to be cleaned up quite a bit.
-jon
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org