/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at .
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.ui.config.RootConfig;
public class NullSession implements VeniceUISession, VeniceUISessionFactory
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static NullSession self = null;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
private NullSession()
{ // do nothing
} // end constructor
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private final void bogus()
{
throw new IllegalStateException("null session is not valid");
} // end bogus
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceUISession
*--------------------------------------------------------------------------------
*/
public long getCreationTime()
{
bogus();
return 0;
} // end getCreationTime
public String getID()
{
return null;
} // end getID
public long getLastAccessedTime()
{
return 0;
} // end getLastAccessedTime
public void setMaxInactiveInterval(int interval)
{ // do nothing
} // end setMaxInactiveInterval
public int getMaxInactiveInterval()
{
return -1;
} // end getMaxInactiveInterval
public Object getAttribute(String name)
{
bogus();
return null;
} // end getAttribute
public Enumeration getAttributeNames()
{
bogus();
return null;
} // end getAttributeNames
public void setAttribute(String name, Object o)
{
bogus();
} // end setAttribute
public void removeAttribute(String name)
{
bogus();
} // end removeAttribute
public void invalidate()
{
bogus();
} // end invalidate
public UserContext getUser()
{
bogus();
return null;
} // end getUser
public void setUser(UserContext user)
{
bogus();
} // end setUser
public void preprocess(RequestInput ri)
{ // do nothing
} // end preprocess
/*--------------------------------------------------------------------------------
* Implementations from interface VeniceUISessionFactory
*--------------------------------------------------------------------------------
*/
public VeniceUISession createSession(ServletContext ctxt, HttpServletRequest request,
HttpServletResponse response, VeniceEngine engine,
RootConfig config)
{
return this;
} // end createSession
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------
*/
public static final synchronized NullSession get()
{
if (self==null)
self = new NullSession();
return self;
} // end get
} // end class NullSession