Class TurbineConfig
- java.lang.Object
-
- org.apache.turbine.util.TurbineConfig
-
- All Implemented Interfaces:
ServletConfig,ServletContext,org.apache.avalon.framework.activity.Disposable,org.apache.avalon.framework.activity.Initializable
- Direct Known Subclasses:
TurbineXmlConfig
public class TurbineConfig extends Object implements ServletConfig, 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
TODO Make this class enforce the lifecycle contractsinit()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:
- Quinton McCombs, Rafal Krzewski, Jon S. Stevens, Daniel Rall, Henning P. Schmiedehausen, Eric Pugh
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>attributesServlet container (or emulator) attributes.static StringCONFIGURATION_PATH_KEYServlet initialization parameter name for the path to TurbineConfiguration.xml file used by Turbineprotected Map<String,String>initParamsTurbine servlet initialization parameters.static StringPROPERTIES_PATH_DEFAULTDefault value of TurbineResources.properties file path (/WEB-INF/conf/TurbineResources.properties).static StringPROPERTIES_PATH_KEYServlet initialization parameter name for the path to Turbine.properties file used by Turbineprotected FilerootFilenames are looked up in this directory.protected inttimeout-
Fields inherited from interface javax.servlet.ServletContext
ORDERED_LIBS, TEMPDIR
-
-
Constructor Summary
Constructors Constructor Description TurbineConfig(String path, String properties)Constructs a TurbineConfig.TurbineConfig(String path, Map<String,Object> attributes, Map<String,String> initParams)Constructs a new TurbineConfig.TurbineConfig(String path, Map<String,String> initParams)Constructs a new TurbineConfig.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FilterRegistration.DynamicaddFilter(String filterName, Class<? extends Filter> filterClass)Not implemented.FilterRegistration.DynamicaddFilter(String filterName, String className)Not implemented.FilterRegistration.DynamicaddFilter(String filterName, Filter filter)Not implemented.voidaddListener(Class<? extends EventListener> listenerClass)Not implemented.voidaddListener(String className)Not implemented.<T extends EventListener>
voidaddListener(T t)Not implemented.ServletRegistration.DynamicaddServlet(String servletName, Class<? extends Servlet> servletClass)Not implemented.ServletRegistration.DynamicaddServlet(String servletName, String className)Not implemented.ServletRegistration.DynamicaddServlet(String servletName, Servlet servlet)Not implemented.<T extends Filter>
TcreateFilter(Class<T> clazz)Not implemented.<T extends EventListener>
TcreateListener(Class<T> clazz)Not implemented.<T extends Servlet>
TcreateServlet(Class<T> clazz)Not implemented.voiddeclareRoles(String... roleNames)Not implemented.voiddispose()Shutdown the Turbine System, lifecycle styleObjectgetAttribute(String s)Returns the servlet container attribute with the given name, or null if there is no attribute by that name.Enumeration<String>getAttributeNames()Returns an Enumeration containing the attribute names available within this servlet context.ClassLoadergetClassLoader()Not implemented.ServletContextgetContext(String s)Not implemented.StringgetContextPath()Returns the context path.Set<SessionTrackingMode>getDefaultSessionTrackingModes()Not implemented.intgetEffectiveMajorVersion()Not implemented.intgetEffectiveMinorVersion()Not implemented.Set<SessionTrackingMode>getEffectiveSessionTrackingModes()Not implemented.FilterRegistrationgetFilterRegistration(String filterName)Not implemented.Map<String,? extends FilterRegistration>getFilterRegistrations()Not implemented.StringgetInitParameter(String name)Retrieves an initialization parameter.Enumeration<String>getInitParameterNames()Retrieves an Enumeration of initialization parameter names.JspConfigDescriptorgetJspConfigDescriptor()Not implemented.intgetMajorVersion()Not implemented.StringgetMimeType(String s)Not implemented.intgetMinorVersion()Not implemented.RequestDispatchergetNamedDispatcher(String s)Not implemented.StringgetRealPath(String path)Translates a path relative to the web application root into an absolute path.RequestDispatchergetRequestDispatcher(String s)Not implemented.URLgetResource(String s)Returns a URL to the resource that is mapped to a specified path.InputStreamgetResourceAsStream(String s)Returns the resource located at the named path as anInputStreamobject.Set<String>getResourcePaths(String s)Not implemented.StringgetServerInfo()Not implemented.ServletgetServlet(String s)Deprecated.As of Java Servlet API 2.1, with no direct replacement.ServletContextgetServletContext()Returns a reference to the object cast onto ServletContext type.StringgetServletContextName()Returns the context name.StringgetServletName()Returns the servlet name.Enumeration<String>getServletNames()Deprecated.As of Java Servlet API 2.1, with no replacement.ServletRegistrationgetServletRegistration(String servletName)Not implemented.Map<String,? extends ServletRegistration>getServletRegistrations()Not implemented.Enumeration<Servlet>getServlets()Deprecated.As of Java Servlet API 2.0, with no replacement.SessionCookieConfiggetSessionCookieConfig()Not implemented.TurbinegetTurbine()Returns a reference to the Turbine servlet that was initialized.StringgetVirtualServerName()Not implemented.voidinit(RunData data)Initialization requiring a HTTPGETrequest.voidinitialize()Causes this class to initialize itself which in turn initializes all of the Turbine Services that need to be initialized.voidlog(Exception e, String m)Deprecated.use log(String,Throwable) insteadvoidlog(String m)Logs a message.voidlog(String m, Throwable t)Logs an error message.voidremoveAttribute(String s)Not implemented.voidsetAttribute(String s, Object o)Not implemented.booleansetInitParameter(String name, String value)Not implemented.voidsetSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)Not implemented.
-
-
-
Field Detail
-
timeout
protected int timeout
-
CONFIGURATION_PATH_KEY
public static final String CONFIGURATION_PATH_KEY
Servlet initialization parameter name for the path to TurbineConfiguration.xml file used by Turbine- See Also:
- Constant Field Values
-
PROPERTIES_PATH_KEY
public static final String PROPERTIES_PATH_KEY
Servlet initialization parameter name for the path to Turbine.properties file used by Turbine- See Also:
- Constant Field Values
-
PROPERTIES_PATH_DEFAULT
public static final String PROPERTIES_PATH_DEFAULT
Default value of TurbineResources.properties file path (/WEB-INF/conf/TurbineResources.properties).- See Also:
- Constant Field Values
-
attributes
protected Map<String,Object> attributes
Servlet container (or emulator) attributes.
-
initParams
protected Map<String,String> initParams
Turbine servlet initialization parameters.
-
-
Constructor Detail
-
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
Turbineclass.- 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
Turbineclass.- 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 alsoTurbineXmlConfigto load aCONFIGURATION_PATH_KEY.- Parameters:
path- The web application root (i.e. the path for file lookup).properties- the relative path to TurbineResources.properties file
-
-
Method Detail
-
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:
initializein interfaceorg.apache.avalon.framework.activity.Initializable
-
init
public void init(RunData data)
Initialization requiring a HTTPGETrequest.- Parameters:
data- the Turbine request
-
dispose
public void dispose()
Shutdown the Turbine System, lifecycle style- Specified by:
disposein interfaceorg.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 ServletContext getServletContext()
Returns a reference to the object cast onto ServletContext type.- Specified by:
getServletContextin interfaceServletConfig- 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:
getRealPathin interfaceServletContext- Parameters:
path- A path relative to the web application root.- Returns:
- An absolute version of the supplied path, or
nullif the translated path doesn't map to a file or directory.
-
getInitParameter
public String getInitParameter(String name)
Retrieves an initialization parameter.- Specified by:
getInitParameterin interfaceServletConfig- Specified by:
getInitParameterin interfaceServletContext- Parameters:
name- the name of the parameter.- Returns:
- the value of the parameter.
-
getInitParameterNames
public Enumeration<String> getInitParameterNames()
Retrieves an Enumeration of initialization parameter names.- Specified by:
getInitParameterNamesin interfaceServletConfig- Specified by:
getInitParameterNamesin interfaceServletContext- Returns:
- an Enumeration of initialization parameter names.
-
getServletName
public String getServletName()
Returns the servlet name. Fixed value "Turbine" is returned.- Specified by:
getServletNamein interfaceServletConfig- Returns:
- the servlet name.
-
getServletContextName
public String getServletContextName()
Returns the context name. Fixed value "Turbine" is returned- Specified by:
getServletContextNamein interfaceServletContext- Returns:
- the context name
-
getContextPath
public String getContextPath()
Returns the context path. Fixed value "/turbine" is returned- Specified by:
getContextPathin interfaceServletContext- Returns:
- the context path
-
getResource
public URL getResource(String s) throws 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:
getResourcein interfaceServletContext- Parameters:
s- the path to the resource- Returns:
- a URL pointing to the resource
- Throws:
MalformedURLException- if unable to parse path
-
getResourceAsStream
public InputStream getResourceAsStream(String s)
Returns the resource located at the named path as anInputStreamobject.- Specified by:
getResourceAsStreamin interfaceServletContext- Parameters:
s- the path to the resource- Returns:
- an InputStream object from which the resource can be read
-
log
@Deprecated public void log(Exception e, String m)
Deprecated.use log(String,Throwable) insteadLogs an error message.- Specified by:
login interfaceServletContext- Parameters:
e- an Exception.m- a message.
-
log
public void log(String m)
Logs a message.- Specified by:
login interfaceServletContext- Parameters:
m- a message.
-
log
public void log(String m, Throwable t)
Logs an error message.- Specified by:
login interfaceServletContext- Parameters:
t- a Throwable object.m- a message.
-
getAttribute
public Object getAttribute(String s)
Returns the servlet container attribute with the given name, or null if there is no attribute by that name.- Specified by:
getAttributein interfaceServletContext
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Returns an Enumeration containing the attribute names available within this servlet context.- Specified by:
getAttributeNamesin interfaceServletContext
-
getContext
public ServletContext getContext(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getContextin interfaceServletContext
-
getMajorVersion
public int getMajorVersion()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getMajorVersionin interfaceServletContext
-
getMimeType
public String getMimeType(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getMimeTypein interfaceServletContext
-
getMinorVersion
public int getMinorVersion()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getMinorVersionin interfaceServletContext
-
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getNamedDispatcherin interfaceServletContext
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getRequestDispatcherin interfaceServletContext
-
getResourcePaths
public Set<String> getResourcePaths(String s)
Not implemented. A method in ServletContext (2.3) interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getResourcePathsin interfaceServletContext
-
getServerInfo
public String getServerInfo()
Not implemented. A method in ServletContext (2.3) interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getServerInfoin interfaceServletContext
-
getServlet
@Deprecated public Servlet getServlet(String s)
Deprecated.As of Java Servlet API 2.1, with no direct replacement.Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getServletin interfaceServletContext
-
getServletNames
@Deprecated public Enumeration<String> getServletNames()
Deprecated.As of Java Servlet API 2.1, with no replacement.Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getServletNamesin interfaceServletContext
-
getServlets
@Deprecated public Enumeration<Servlet> getServlets()
Deprecated.As of Java Servlet API 2.0, with no replacement.Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getServletsin interfaceServletContext
-
removeAttribute
public void removeAttribute(String s)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
removeAttributein interfaceServletContext
-
setAttribute
public void setAttribute(String s, Object o)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
setAttributein interfaceServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getEffectiveMajorVersionin interfaceServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getEffectiveMinorVersionin interfaceServletContext
-
setInitParameter
public boolean setInitParameter(String name, String value)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
setInitParameterin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, String className)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addServletin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addServletin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addServletin interfaceServletContext
-
createServlet
public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
createServletin interfaceServletContext- Throws:
ServletException
-
getServletRegistration
public ServletRegistration getServletRegistration(String servletName)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getServletRegistrationin interfaceServletContext
-
getServletRegistrations
public Map<String,? extends ServletRegistration> getServletRegistrations()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getServletRegistrationsin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, String className)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addFilterin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addFilterin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addFilterin interfaceServletContext
-
createFilter
public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
createFilterin interfaceServletContext- Throws:
ServletException
-
getFilterRegistration
public FilterRegistration getFilterRegistration(String filterName)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getFilterRegistrationin interfaceServletContext
-
getFilterRegistrations
public Map<String,? extends FilterRegistration> getFilterRegistrations()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getFilterRegistrationsin interfaceServletContext
-
getSessionCookieConfig
public SessionCookieConfig getSessionCookieConfig()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getSessionCookieConfigin interfaceServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
setSessionTrackingModesin interfaceServletContext
-
getDefaultSessionTrackingModes
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getDefaultSessionTrackingModesin interfaceServletContext
-
getEffectiveSessionTrackingModes
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getEffectiveSessionTrackingModesin interfaceServletContext
-
addListener
public void addListener(String className)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addListenerin interfaceServletContext
-
addListener
public <T extends EventListener> void addListener(T t)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addListenerin interfaceServletContext
-
addListener
public void addListener(Class<? extends EventListener> listenerClass)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
addListenerin interfaceServletContext
-
createListener
public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
createListenerin interfaceServletContext- Throws:
ServletException
-
getJspConfigDescriptor
public JspConfigDescriptor getJspConfigDescriptor()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getJspConfigDescriptorin interfaceServletContext
-
getClassLoader
public ClassLoader getClassLoader()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getClassLoaderin interfaceServletContext
-
declareRoles
public void declareRoles(String... roleNames)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
declareRolesin interfaceServletContext
-
getVirtualServerName
public String getVirtualServerName()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationExceptionupon invocation- Specified by:
getVirtualServerNamein interfaceServletContext
-
-