org.mmbase.module.core
Class MMBaseContext

java.lang.Object
  |
  +--org.mmbase.module.core.MMBaseContext

public class MMBaseContext
extends java.lang.Object

Using MMBaseContext class you can retrieve the servletContext from anywhere using the get method.

Version:
23 December 1999
Author:
Daniel Ockeloen, David van Zeventer, Jaco de Groot

Constructor Summary
MMBaseContext()
           
 
Method Summary
static java.lang.String getConfigPath()
          Returns a string representing the mmbase.config parameter without a final File.separator.
static java.lang.String getHtmlRoot()
          Returns a string representing the mmbase.htmlroot parameter without a final File.separator.
static java.lang.String getOutputFile()
          Returns a string representing the mmbase.outputfile parameter.
static javax.servlet.ServletContext getServletContext()
          Returns the ServeltContext used to initialize MMBase.
static void init()
          Initialize MMBase using system properties only.
static void init(javax.servlet.ServletContext servletContext)
          Initialize MMBase using a SevletContext.
static void initHtmlRoot()
          Initialize mmbase.htmlroot parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MMBaseContext

public MMBaseContext()
Method Detail

init

public static void init(javax.servlet.ServletContext servletContext)
                 throws javax.servlet.ServletException
Initialize MMBase using a SevletContext. This method will check the servlet configuration for context parameters mmbase.outputfile and mmbase.config. If not found it will look for system properties.
Throws:
javax.servlet.ServletException - if mmbase.configpath is not set or is not a directory or doesn't contain the expected config files.

init

public static void init()
                 throws java.lang.Exception
Initialize MMBase using system properties only. This may be useful in cases where MMBase is used without a servlet. For example when running JUnit tests.
Throws:
java.lang.Exception - if mmbase.configpath is not set or is not a directory or doesn't contain the expected config files.

initHtmlRoot

public static void initHtmlRoot()
                         throws javax.servlet.ServletException
Initialize mmbase.htmlroot parameter. This method is only needed for SCAN related servlets and should be called after the init(ServletContext) method. If the mmbase.htmlroot parameter is not found in the servlet context or system properties this method will try to set it to the root directory of the webapp.
Throws:
javax.servlet.ServletException - if mmbase.htmlroot is not set or is not a directory

getServletContext

public static javax.servlet.ServletContext getServletContext()
Returns the ServeltContext used to initialize MMBase. Before calling this method the init method should be called.
Returns:
the ServeltContext used to initialize MMBase or null if MMBase was initilized without ServletContext

getConfigPath

public static java.lang.String getConfigPath()
Returns a string representing the mmbase.config parameter without a final File.separator. Before calling this method the init method should be called to make sure this parameter is set.
Returns:
the mmbase.config parameter

getHtmlRoot

public static java.lang.String getHtmlRoot()
Returns a string representing the mmbase.htmlroot parameter without a final File.separator. Before calling this method the initHtmlRoot method should be called to make sure this parameter is set.
Returns:
the mmbase.htmlroot parameter or null if not initialized

getOutputFile

public static java.lang.String getOutputFile()
Returns a string representing the mmbase.outputfile parameter. If set, this is the file to wich all System.out and System.err output is redirected. Before calling this method the init method should be called.
Returns:
the mmbase.htmlroot parameter or null if not set


MMBase 2001