FileDocCategorySizeDatePackage
ServletContextSingleton.javaAPI DocExample2782Mon Jul 23 13:26:54 BST 2007org.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 {@link org.apache.struts2.dispatcher.FilterDispatcherCompatWeblogic61} before the servlet context is needed by {@link org.apache.struts2.lifecycle.SessionLifecycleListener} which will use this object to get it.

Fields Summary
private ServletContext
servletContext
The web servlet context. Holding this is the purpose of this singleton.
private static ServletContextSingleton
singleton
The sole instance of this class.
Constructors Summary
private ServletContextSingleton()
Constructor which cannot be called publicly.

    
Methods Summary
public static org.apache.struts2.config.ServletContextSingletongetInstance()
Answers the singleton.

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

return
Answers the singleton instance of this class

        if (singleton == null) {
            singleton = new ServletContextSingleton();
        }
        return singleton;
    
public javax.servlet.ServletContextgetServletContext()
Gets the servlet context

return
The web servlet context

        return servletContext;
    
public voidsetServletContext(javax.servlet.ServletContext context)
Sets the servlet context

param
context The web servlet context

        servletContext = context;