org.apache.turbine.util
Class TurbineConfig

java.lang.Object
  |
  +--org.apache.turbine.util.TurbineConfig
All Implemented Interfaces:
javax.servlet.ServletConfig, javax.servlet.ServletContext

public class TurbineConfig
extends java.lang.Object
implements javax.servlet.ServletConfig, javax.servlet.ServletContext

A class used for initalization of Turbine without a servlet container. If you need to use Turbine outside of a servlet container, you can use this class for initalization of the Turbine servlet.

   TurbineConfig config = new TurbineConfig(".","/conf/TurbineResources.properties");
 
All paths referenced in TurbineResources.properties and the path to the properties file itself (the second argument) will be resolved relative to the directory given as the first argument of the constructor, here - the directory where application was started. Don't worry about discarding the references to objects created above. They are not needed, once everything is initialized. In order to initialize the Services Framework outside of the Turbine Servlet, you need to call the init() method. By default, this will initialize the Resource and Logging Services and any other services you have defined in your TurbineResources.properties file.

Version:
$Id$
Author:
Rafal Krzewski, Jon S. Stevens, Daniel Rall

Field Summary
private static boolean DEBUG
          Enables output of debug messages (compile time option).
private  java.util.Map initParams
          Initialization parameters
private  java.io.File root
          Filenames are looked up in this directory.
private  Turbine turbine
          The Turbine servlet instance used for initialization.
 
Constructor Summary
TurbineConfig(java.lang.String path, java.util.Map initParams)
          Constructs a new TurbineConfig.
TurbineConfig(java.lang.String path, java.lang.String properties)
          Constructs a TurbineConfig.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String s)
          Not implemented.
 java.util.Enumeration getAttributeNames()
          Not implemented.
 javax.servlet.ServletContext getContext(java.lang.String s)
          Not implemented.
 java.lang.String getInitParameter(java.lang.String name)
          Retrieves an initialization parameter.
 java.util.Enumeration getInitParameterNames()
          Retrieves an Enumeration of initialization parameter names.
 int getMajorVersion()
          Not implemented.
 java.lang.String getMimeType(java.lang.String s)
          Not implemented.
 int getMinorVersion()
          Not implemented.
 javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String s)
          Not implemented.
 java.lang.String getRealPath(java.lang.String path)
          Translates a path relative to the web application root into an absolute path.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String s)
          Not implemented.
 java.net.URL getResource(java.lang.String s)
          Returns a URL to the resource that is mapped to a specified path.
 java.io.InputStream getResourceAsStream(java.lang.String s)
          Returns the resource located at the named path as an InputStream object.
 java.util.Set getResourcePaths()
          Deprecated.  
 java.lang.String getServerInfo()
          Not implemented.
 javax.servlet.Servlet getServlet(java.lang.String s)
          Deprecated.  
 javax.servlet.ServletContext getServletContext()
          Returns a reference to the object cast onto ServletContext type.
 java.lang.String getServletContextName()
          Returns the context name.
 java.lang.String getServletName()
          Returns the servlet name.
 java.util.Enumeration getServletNames()
          Deprecated.  
 java.util.Enumeration getServlets()
          Deprecated.  
 void init()
          Causes this class to initialize itself which in turn initializes all of the Turbine Services that need to be initialized.
 void init(RunData data)
          Initialization requiring a HTTP GET request.
 void log(java.lang.Exception e, java.lang.String m)
          Deprecated.  
 void log(java.lang.String m)
          Logs a message.
 void log(java.lang.String m, java.lang.Throwable t)
          Logs an error message.
 void removeAttribute(java.lang.String s)
          Not implemented.
 void setAttribute(java.lang.String s, java.lang.Object o)
          Not implemented.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG
Enables output of debug messages (compile time option).

root

private java.io.File root
Filenames are looked up in this directory.

initParams

private java.util.Map initParams
Initialization parameters

turbine

private Turbine turbine
The Turbine servlet instance used for initialization.
Constructor Detail

TurbineConfig

public TurbineConfig(java.lang.String path,
                     java.util.Map initParams)
Constructs a new TurbineConfig. This is the general form of the constructor. You can provide a path to search for files, and a name-value map of init parameters.

For the list of recognized init parameters, see Turbine class.

Parameters:
path - The web application root (i.e. the path for file lookup).
initParams - initialization parameters.

TurbineConfig

public TurbineConfig(java.lang.String path,
                     java.lang.String properties)
Constructs a TurbineConfig. This is a specialized constructor that allows to configure Turbine easiliy in the common setups.
Parameters:
path - The web application root (i.e. the path for file lookup).
properties - the relative path to TurbineResources.properties file
Method Detail

init

public void init()
Causes this class to initialize itself which in turn initializes all of the Turbine Services that need to be initialized.

init

public void init(RunData data)
Initialization requiring a HTTP GET request.

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns a reference to the object cast onto ServletContext type.
Specified by:
getServletContext in interface javax.servlet.ServletConfig
Returns:
a ServletContext reference

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Translates a path relative to the web application root into an absolute path.
Specified by:
getRealPath in interface javax.servlet.ServletContext
Parameters:
path - A path relative to the web application root.
Returns:
An absolute version of the supplied path, or null if the translated path doesn't map to a file or directory.

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Retrieves an initialization parameter.
Specified by:
getInitParameter in interface javax.servlet.ServletConfig
Parameters:
name - the name of the parameter.
Returns:
the value of the parameter.

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Retrieves an Enumeration of initialization parameter names.
Specified by:
getInitParameterNames in interface javax.servlet.ServletConfig
Returns:
an Enumeration of initialization parameter names.

getServletName

public java.lang.String getServletName()
Returns the servlet name. Fixed value "Turbine" is returned.
Specified by:
getServletName in interface javax.servlet.ServletConfig
Returns:
the servlet name.

getServletContextName

public java.lang.String getServletContextName()
Returns the context name. Fixed value "Turbine" is returned
Returns:
the context name

getResource

public java.net.URL getResource(java.lang.String s)
                         throws java.net.MalformedURLException
Returns a URL to the resource that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root.
Specified by:
getResource in interface javax.servlet.ServletContext
Parameters:
s - the path to the resource
Returns:
a URL pointing to the resource
Throws:
java.net.MalformedURLException -  

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String s)
Returns the resource located at the named path as an InputStream object.
Specified by:
getResourceAsStream in interface javax.servlet.ServletContext
Parameters:
s - the path to the resource
Returns:
an InputStream object from which the resource can be read

log

public void log(java.lang.Exception e,
                java.lang.String m)
Deprecated.  

Logs an error message.
Specified by:
log in interface javax.servlet.ServletContext
Parameters:
e - an Exception.
m - a message.

log

public void log(java.lang.String m)
Logs a message.
Specified by:
log in interface javax.servlet.ServletContext
Parameters:
m - a message.

log

public void log(java.lang.String m,
                java.lang.Throwable t)
Logs an error message.
Specified by:
log in interface javax.servlet.ServletContext
Parameters:
t - a Throwable object.
m - a message.

getAttribute

public java.lang.Object getAttribute(java.lang.String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getAttribute in interface javax.servlet.ServletContext

getAttributeNames

public java.util.Enumeration getAttributeNames()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getAttributeNames in interface javax.servlet.ServletContext

getContext

public javax.servlet.ServletContext getContext(java.lang.String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getContext in interface javax.servlet.ServletContext

getMajorVersion

public int getMajorVersion()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getMajorVersion in interface javax.servlet.ServletContext

getMimeType

public java.lang.String getMimeType(java.lang.String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getMimeType in interface javax.servlet.ServletContext

getMinorVersion

public int getMinorVersion()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getMinorVersion in interface javax.servlet.ServletContext

getNamedDispatcher

public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getNamedDispatcher in interface javax.servlet.ServletContext

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getRequestDispatcher in interface javax.servlet.ServletContext

getResourcePaths

public java.util.Set getResourcePaths()
Deprecated.  

Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation

getServerInfo

public java.lang.String getServerInfo()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getServerInfo in interface javax.servlet.ServletContext

getServlet

public javax.servlet.Servlet getServlet(java.lang.String s)
Deprecated.  

Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getServlet in interface javax.servlet.ServletContext

getServletNames

public java.util.Enumeration getServletNames()
Deprecated.  

Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getServletNames in interface javax.servlet.ServletContext

getServlets

public java.util.Enumeration getServlets()
Deprecated.  

Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
getServlets in interface javax.servlet.ServletContext

removeAttribute

public void removeAttribute(java.lang.String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
removeAttribute in interface javax.servlet.ServletContext

setAttribute

public void setAttribute(java.lang.String s,
                         java.lang.Object o)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
Specified by:
setAttribute in interface javax.servlet.ServletContext


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.