org.apache.struts2.config
Class ServletContextSingleton

java.lang.Object
  extended by org.apache.struts2.config.ServletContextSingleton

public class ServletContextSingleton
extends Object

This singleton holds an instance of the web servlet context.

This is needed for running Struts on Weblogic Server 6.1 because there is no provision to retrieve the servlet context from the web session object.

This class is created to bet that this singleton can be set by FilterDispatcherCompatWeblogic61 before the servlet context is needed by org.apache.struts2.lifecycle.SessionLifecycleListener which will use this object to get it.


Field Summary
private  ServletContext servletContext
          The web servlet context.
private static ServletContextSingleton singleton
          The sole instance of this class.
 
Constructor Summary
private ServletContextSingleton()
          Constructor which cannot be called publicly.
 
Method Summary
static ServletContextSingleton getInstance()
          Answers the singleton.
 ServletContext getServletContext()
          Gets the servlet context
 void setServletContext(ServletContext context)
          Sets the servlet context
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servletContext

private ServletContext servletContext
The web servlet context. Holding this is the purpose of this singleton.


singleton

private static ServletContextSingleton singleton
The sole instance of this class.

Constructor Detail

ServletContextSingleton

private ServletContextSingleton()
Constructor which cannot be called publicly.

Method Detail

getInstance

public static ServletContextSingleton getInstance()
Answers the singleton.

At some point, the caller must populate the web servlet context.

Returns:
Answers the singleton instance of this class

getServletContext

public ServletContext getServletContext()
Gets the servlet context

Returns:
The web servlet context

setServletContext

public void setServletContext(ServletContext context)
Sets the servlet context

Parameters:
context - The web servlet context


Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.