Class TurbineConfig

java.lang.Object
org.apache.turbine.util.TurbineConfig
All Implemented Interfaces:
jakarta.servlet.ServletConfig, jakarta.servlet.ServletContext, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable
Direct Known Subclasses:
TurbineXmlConfig

public class TurbineConfig extends Object implements jakarta.servlet.ServletConfig, jakarta.servlet.ServletContext, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable
A class used for initialization of Turbine without a servlet container.

If you need to use Turbine outside of a servlet container, you can use this class for initialization 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.

TODO Make this class enforce the lifecycle contracts
Version:
$Id$
Author:
Quinton McCombs, Rafal Krzewski, Jon S. Stevens, Daniel Rall, Henning P. Schmiedehausen, Eric Pugh
See Also:
  • Field Details

  • Constructor Details

    • TurbineConfig

      public TurbineConfig(String path, Map<String,Object> attributes, Map<String,String> 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).
      attributes - Servlet container (or emulator) attributes.
      initParams - initialization parameters.
    • TurbineConfig

      public TurbineConfig(String path, Map<String,String> 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(String path, String properties)
      Constructs a TurbineConfig. This is a specialized constructor that allows to configure Turbine easily in the common setups. Check also TurbineXmlConfig to load a CONFIGURATION_PATH_KEY.
      Parameters:
      path - The web application root (i.e. the path for file lookup).
      properties - the relative path to TurbineResources.properties file
  • Method Details

    • initialize

      public void initialize()
      Causes this class to initialize itself which in turn initializes all of the Turbine Services that need to be initialized.
      Specified by:
      initialize in interface org.apache.avalon.framework.activity.Initializable
    • init

      public void init(RunData data)
      Initialization requiring a HTTP GET request.
      Parameters:
      data - the Turbine request
    • dispose

      public void dispose()
      Shutdown the Turbine System, lifecycle style
      Specified by:
      dispose in interface org.apache.avalon.framework.activity.Disposable
    • getTurbine

      public Turbine getTurbine()
      Returns a reference to the Turbine servlet that was initialized.
      Returns:
      a ServletContext reference
    • getServletContext

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

      public String getRealPath(String path)
      Translates a path relative to the web application root into an absolute path.
      Specified by:
      getRealPath in interface jakarta.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

      Retrieves an initialization parameter.
      Specified by:
      getInitParameter in interface jakarta.servlet.ServletConfig
      Specified by:
      getInitParameter in interface jakarta.servlet.ServletContext
      Parameters:
      name - the name of the parameter.
      Returns:
      the value of the parameter.
    • getInitParameterNames

      Retrieves an Enumeration of initialization parameter names.
      Specified by:
      getInitParameterNames in interface jakarta.servlet.ServletConfig
      Specified by:
      getInitParameterNames in interface jakarta.servlet.ServletContext
      Returns:
      an Enumeration of initialization parameter names.
    • getServletName

      Returns the servlet name. Fixed value "Turbine" is returned.
      Specified by:
      getServletName in interface jakarta.servlet.ServletConfig
      Returns:
      the servlet name.
    • getServletContextName

      Returns the context name. Fixed value "Turbine" is returned
      Specified by:
      getServletContextName in interface jakarta.servlet.ServletContext
      Returns:
      the context name
    • getContextPath

      Returns the context path. Fixed value "/turbine" is returned
      Specified by:
      getContextPath in interface jakarta.servlet.ServletContext
      Returns:
      the context path
    • getResource

      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 jakarta.servlet.ServletContext
      Parameters:
      s - the path to the resource
      Returns:
      a URL pointing to the resource
      Throws:
      MalformedURLException - if unable to parse path
    • getResourceAsStream

      Returns the resource located at the named path as an InputStream object.
      Specified by:
      getResourceAsStream in interface jakarta.servlet.ServletContext
      Parameters:
      s - the path to the resource
      Returns:
      an InputStream object from which the resource can be read
    • log

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

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

      Returns the servlet container attribute with the given name, or null if there is no attribute by that name.
      Specified by:
      getAttribute in interface jakarta.servlet.ServletContext
    • getAttributeNames

      Returns an Enumeration containing the attribute names available within this servlet context.
      Specified by:
      getAttributeNames in interface jakarta.servlet.ServletContext
    • getContext

      public jakarta.servlet.ServletContext getContext(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 jakarta.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 jakarta.servlet.ServletContext
    • getMimeType

      Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getMimeType in interface jakarta.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 jakarta.servlet.ServletContext
    • getNamedDispatcher

      public jakarta.servlet.RequestDispatcher getNamedDispatcher(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 jakarta.servlet.ServletContext
    • getRequestDispatcher

      public jakarta.servlet.RequestDispatcher getRequestDispatcher(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 jakarta.servlet.ServletContext
    • getResourcePaths

      Not implemented. A method in ServletContext (2.3) interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getResourcePaths in interface jakarta.servlet.ServletContext
    • getServerInfo

      Not implemented. A method in ServletContext (2.3) interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getServerInfo in interface jakarta.servlet.ServletContext
    • removeAttribute

      public void removeAttribute(String s)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      removeAttribute in interface jakarta.servlet.ServletContext
    • setAttribute

      public void setAttribute(String s, Object o)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      setAttribute in interface jakarta.servlet.ServletContext
    • getEffectiveMajorVersion

      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getEffectiveMajorVersion in interface jakarta.servlet.ServletContext
    • getEffectiveMinorVersion

      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getEffectiveMinorVersion in interface jakarta.servlet.ServletContext
    • setInitParameter

      public boolean setInitParameter(String name, String value)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      setInitParameter in interface jakarta.servlet.ServletContext
    • addServlet

      public jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addServlet in interface jakarta.servlet.ServletContext
    • addServlet

      public jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, jakarta.servlet.Servlet servlet)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addServlet in interface jakarta.servlet.ServletContext
    • addServlet

      public jakarta.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends jakarta.servlet.Servlet> servletClass)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addServlet in interface jakarta.servlet.ServletContext
    • createServlet

      public <T extends jakarta.servlet.Servlet> T createServlet(Class<T> clazz) throws jakarta.servlet.ServletException
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      createServlet in interface jakarta.servlet.ServletContext
      Throws:
      jakarta.servlet.ServletException
    • getServletRegistration

      public jakarta.servlet.ServletRegistration getServletRegistration(String servletName)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getServletRegistration in interface jakarta.servlet.ServletContext
    • getServletRegistrations

      public Map<String,? extends jakarta.servlet.ServletRegistration> getServletRegistrations()
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getServletRegistrations in interface jakarta.servlet.ServletContext
    • addFilter

      public jakarta.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addFilter in interface jakarta.servlet.ServletContext
    • addFilter

      public jakarta.servlet.FilterRegistration.Dynamic addFilter(String filterName, jakarta.servlet.Filter filter)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addFilter in interface jakarta.servlet.ServletContext
    • addFilter

      public jakarta.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends jakarta.servlet.Filter> filterClass)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addFilter in interface jakarta.servlet.ServletContext
    • createFilter

      public <T extends jakarta.servlet.Filter> T createFilter(Class<T> clazz) throws jakarta.servlet.ServletException
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      createFilter in interface jakarta.servlet.ServletContext
      Throws:
      jakarta.servlet.ServletException
    • getFilterRegistration

      public jakarta.servlet.FilterRegistration getFilterRegistration(String filterName)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getFilterRegistration in interface jakarta.servlet.ServletContext
    • getFilterRegistrations

      public Map<String,? extends jakarta.servlet.FilterRegistration> getFilterRegistrations()
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getFilterRegistrations in interface jakarta.servlet.ServletContext
    • getSessionCookieConfig

      public jakarta.servlet.SessionCookieConfig getSessionCookieConfig()
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getSessionCookieConfig in interface jakarta.servlet.ServletContext
    • setSessionTrackingModes

      public void setSessionTrackingModes(Set<jakarta.servlet.SessionTrackingMode> sessionTrackingModes)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      setSessionTrackingModes in interface jakarta.servlet.ServletContext
    • getDefaultSessionTrackingModes

      public Set<jakarta.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getDefaultSessionTrackingModes in interface jakarta.servlet.ServletContext
    • getEffectiveSessionTrackingModes

      public Set<jakarta.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getEffectiveSessionTrackingModes in interface jakarta.servlet.ServletContext
    • addListener

      public void addListener(String className)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addListener in interface jakarta.servlet.ServletContext
    • addListener

      public <T extends EventListener> void addListener(T t)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addListener in interface jakarta.servlet.ServletContext
    • addListener

      public void addListener(Class<? extends EventListener> listenerClass)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      addListener in interface jakarta.servlet.ServletContext
    • createListener

      public <T extends EventListener> T createListener(Class<T> clazz) throws jakarta.servlet.ServletException
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      createListener in interface jakarta.servlet.ServletContext
      Throws:
      jakarta.servlet.ServletException
    • getJspConfigDescriptor

      public jakarta.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getJspConfigDescriptor in interface jakarta.servlet.ServletContext
    • getClassLoader

      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getClassLoader in interface jakarta.servlet.ServletContext
    • declareRoles

      public void declareRoles(String... roleNames)
      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      declareRoles in interface jakarta.servlet.ServletContext
    • getVirtualServerName

      Not implemented. A method in ServletContext interface that is not implemented and will throw UnsuportedOperationException upon invocation
      Specified by:
      getVirtualServerName in interface jakarta.servlet.ServletContext
    • addJspFile

      public jakarta.servlet.ServletRegistration.Dynamic addJspFile(String servletName, String jspFile)
      Specified by:
      addJspFile in interface jakarta.servlet.ServletContext
    • getSessionTimeout

      public int getSessionTimeout()
      Specified by:
      getSessionTimeout in interface jakarta.servlet.ServletContext
    • setSessionTimeout

      public void setSessionTimeout(int sessionTimeout)
      in minutes
      Specified by:
      setSessionTimeout in interface jakarta.servlet.ServletContext
    • getRequestCharacterEncoding

      Specified by:
      getRequestCharacterEncoding in interface jakarta.servlet.ServletContext
    • setRequestCharacterEncoding

      public void setRequestCharacterEncoding(String encoding)
      Specified by:
      setRequestCharacterEncoding in interface jakarta.servlet.ServletContext
    • getResponseCharacterEncoding

      Specified by:
      getResponseCharacterEncoding in interface jakarta.servlet.ServletContext
    • setResponseCharacterEncoding

      public void setResponseCharacterEncoding(String encoding)
      Specified by:
      setResponseCharacterEncoding in interface jakarta.servlet.ServletContext