org.mmbase.module.core
Class MMBaseContext

java.lang.Object
  extended byorg.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:
$Id: MMBaseContext.java,v 1.40 2004/02/24 13:48:41 michiel Exp $
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 getHtmlRootUrlPath()
          Deprecated. should not be needed, and this information should be requested from the ServletRequest
static java.lang.String getOutputFile()
          Deprecated. use logging system
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 ServletContext.
static void init(java.lang.String configPath, boolean initLogging)
          Initialize MMBase using a config path.
static void initHtmlRoot()
          Initialize mmbase.htmlroot parameter.
static boolean isInitialized()
          Returns whether this class has been initialized.
 
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 ServletContext. 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.config is not set or is not a directory or doesn't contain the expected config files.

init

public static void init(java.lang.String configPath,
                        boolean initLogging)
                 throws java.lang.Exception
Initialize MMBase using a config path. Useful when testing MMBase classes with a main. You can also configure to init logging or not.

Throws:
java.lang.Exception - if mmbase.config 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.config 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 or WEB-INF/config

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()
Deprecated. use logging system

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.outputFile parameter or null if not set

getHtmlRootUrlPath

public static java.lang.String getHtmlRootUrlPath()
Deprecated. should not be needed, and this information should be requested from the ServletRequest

Returns a string representing the HtmlRootUrlPath, this is the path under the webserver, what is the root for this instance. this will return '/' or something like '/mmbase/' or so...

Returns:
the HtmlRootUrlPath

isInitialized

public static boolean isInitialized()
Returns whether this class has been initialized. This can be used to determine whether MMBase specific configuration data is accessible.



MMBase build 1.7.1.20041002