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>
attributes
Servlet container (or emulator) attributes.static String
CONFIGURATION_PATH_KEY
Servlet initialization parameter name for the path to TurbineConfiguration.xml file used by Turbineprotected Map<String,String>
initParams
Turbine servlet initialization parameters.static String
PROPERTIES_PATH_DEFAULT
Default value of TurbineResources.properties file path (/WEB-INF/conf/TurbineResources.properties
).static String
PROPERTIES_PATH_KEY
Servlet initialization parameter name for the path to Turbine.properties file used by Turbineprotected File
root
Filenames are looked up in this directory.protected int
timeout
-
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.Dynamic
addFilter(String filterName, Class<? extends Filter> filterClass)
Not implemented.FilterRegistration.Dynamic
addFilter(String filterName, String className)
Not implemented.FilterRegistration.Dynamic
addFilter(String filterName, Filter filter)
Not implemented.void
addListener(Class<? extends EventListener> listenerClass)
Not implemented.void
addListener(String className)
Not implemented.<T extends EventListener>
voidaddListener(T t)
Not implemented.ServletRegistration.Dynamic
addServlet(String servletName, Class<? extends Servlet> servletClass)
Not implemented.ServletRegistration.Dynamic
addServlet(String servletName, String className)
Not implemented.ServletRegistration.Dynamic
addServlet(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.void
declareRoles(String... roleNames)
Not implemented.void
dispose()
Shutdown the Turbine System, lifecycle styleObject
getAttribute(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.ClassLoader
getClassLoader()
Not implemented.ServletContext
getContext(String s)
Not implemented.String
getContextPath()
Returns the context path.Set<SessionTrackingMode>
getDefaultSessionTrackingModes()
Not implemented.int
getEffectiveMajorVersion()
Not implemented.int
getEffectiveMinorVersion()
Not implemented.Set<SessionTrackingMode>
getEffectiveSessionTrackingModes()
Not implemented.FilterRegistration
getFilterRegistration(String filterName)
Not implemented.Map<String,? extends FilterRegistration>
getFilterRegistrations()
Not implemented.String
getInitParameter(String name)
Retrieves an initialization parameter.Enumeration<String>
getInitParameterNames()
Retrieves an Enumeration of initialization parameter names.JspConfigDescriptor
getJspConfigDescriptor()
Not implemented.int
getMajorVersion()
Not implemented.String
getMimeType(String s)
Not implemented.int
getMinorVersion()
Not implemented.RequestDispatcher
getNamedDispatcher(String s)
Not implemented.String
getRealPath(String path)
Translates a path relative to the web application root into an absolute path.RequestDispatcher
getRequestDispatcher(String s)
Not implemented.URL
getResource(String s)
Returns a URL to the resource that is mapped to a specified path.InputStream
getResourceAsStream(String s)
Returns the resource located at the named path as anInputStream
object.Set<String>
getResourcePaths(String s)
Not implemented.String
getServerInfo()
Not implemented.Servlet
getServlet(String s)
Deprecated.As of Java Servlet API 2.1, with no direct replacement.ServletContext
getServletContext()
Returns a reference to the object cast onto ServletContext type.String
getServletContextName()
Returns the context name.String
getServletName()
Returns the servlet name.Enumeration<String>
getServletNames()
Deprecated.As of Java Servlet API 2.1, with no replacement.ServletRegistration
getServletRegistration(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.SessionCookieConfig
getSessionCookieConfig()
Not implemented.Turbine
getTurbine()
Returns a reference to the Turbine servlet that was initialized.String
getVirtualServerName()
Not implemented.void
init(RunData data)
Initialization requiring a HTTPGET
request.void
initialize()
Causes this class to initialize itself which in turn initializes all of the Turbine Services that need to be initialized.void
log(Exception e, String m)
Deprecated.use log(String,Throwable) insteadvoid
log(String m)
Logs a message.void
log(String m, Throwable t)
Logs an error message.void
removeAttribute(String s)
Not implemented.void
setAttribute(String s, Object o)
Not implemented.boolean
setInitParameter(String name, String value)
Not implemented.void
setSessionTrackingModes(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
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 alsoTurbineXmlConfig
to 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:
initialize
in interfaceorg.apache.avalon.framework.activity.Initializable
-
init
public void init(RunData data)
Initialization requiring a HTTPGET
request.- Parameters:
data
- the Turbine request
-
dispose
public void dispose()
Shutdown the Turbine System, lifecycle style- Specified by:
dispose
in 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:
getServletContext
in 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:
getRealPath
in interfaceServletContext
- 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 String getInitParameter(String name)
Retrieves an initialization parameter.- Specified by:
getInitParameter
in interfaceServletConfig
- Specified by:
getInitParameter
in 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:
getInitParameterNames
in interfaceServletConfig
- Specified by:
getInitParameterNames
in interfaceServletContext
- Returns:
- an Enumeration of initialization parameter names.
-
getServletName
public String getServletName()
Returns the servlet name. Fixed value "Turbine" is returned.- Specified by:
getServletName
in interfaceServletConfig
- Returns:
- the servlet name.
-
getServletContextName
public String getServletContextName()
Returns the context name. Fixed value "Turbine" is returned- Specified by:
getServletContextName
in interfaceServletContext
- Returns:
- the context name
-
getContextPath
public String getContextPath()
Returns the context path. Fixed value "/turbine" is returned- Specified by:
getContextPath
in 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:
getResource
in 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 anInputStream
object.- Specified by:
getResourceAsStream
in 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:
log
in interfaceServletContext
- Parameters:
e
- an Exception.m
- a message.
-
log
public void log(String m)
Logs a message.- Specified by:
log
in interfaceServletContext
- Parameters:
m
- a message.
-
log
public void log(String m, Throwable t)
Logs an error message.- Specified by:
log
in 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:
getAttribute
in interfaceServletContext
-
getAttributeNames
public Enumeration<String> getAttributeNames()
Returns an Enumeration containing the attribute names available within this servlet context.- Specified by:
getAttributeNames
in interfaceServletContext
-
getContext
public ServletContext getContext(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getContext
in interfaceServletContext
-
getMajorVersion
public int getMajorVersion()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getMajorVersion
in interfaceServletContext
-
getMimeType
public String getMimeType(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getMimeType
in interfaceServletContext
-
getMinorVersion
public int getMinorVersion()
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getMinorVersion
in interfaceServletContext
-
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getNamedDispatcher
in interfaceServletContext
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String s)
Not implemented. A method in ServletConfig or ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getRequestDispatcher
in interfaceServletContext
-
getResourcePaths
public Set<String> getResourcePaths(String s)
Not implemented. A method in ServletContext (2.3) interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getResourcePaths
in interfaceServletContext
-
getServerInfo
public String getServerInfo()
Not implemented. A method in ServletContext (2.3) interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getServerInfo
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
getServlet
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
getServletNames
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
getServlets
in interfaceServletContext
-
removeAttribute
public void removeAttribute(String s)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
removeAttribute
in interfaceServletContext
-
setAttribute
public void setAttribute(String s, Object o)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
setAttribute
in interfaceServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getEffectiveMajorVersion
in interfaceServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getEffectiveMinorVersion
in interfaceServletContext
-
setInitParameter
public boolean setInitParameter(String name, String value)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
setInitParameter
in interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, String className)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addServlet
in interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addServlet
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
addServlet
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
createServlet
in interfaceServletContext
- Throws:
ServletException
-
getServletRegistration
public ServletRegistration getServletRegistration(String servletName)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getServletRegistration
in interfaceServletContext
-
getServletRegistrations
public Map<String,? extends ServletRegistration> getServletRegistrations()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getServletRegistrations
in interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, String className)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addFilter
in interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addFilter
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
addFilter
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
createFilter
in interfaceServletContext
- Throws:
ServletException
-
getFilterRegistration
public FilterRegistration getFilterRegistration(String filterName)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getFilterRegistration
in interfaceServletContext
-
getFilterRegistrations
public Map<String,? extends FilterRegistration> getFilterRegistrations()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getFilterRegistrations
in interfaceServletContext
-
getSessionCookieConfig
public SessionCookieConfig getSessionCookieConfig()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getSessionCookieConfig
in interfaceServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
setSessionTrackingModes
in interfaceServletContext
-
getDefaultSessionTrackingModes
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getDefaultSessionTrackingModes
in interfaceServletContext
-
getEffectiveSessionTrackingModes
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getEffectiveSessionTrackingModes
in interfaceServletContext
-
addListener
public void addListener(String className)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addListener
in interfaceServletContext
-
addListener
public <T extends EventListener> void addListener(T t)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addListener
in interfaceServletContext
-
addListener
public void addListener(Class<? extends EventListener> listenerClass)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
addListener
in 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 throwUnsuportedOperationException
upon invocation- Specified by:
createListener
in interfaceServletContext
- Throws:
ServletException
-
getJspConfigDescriptor
public JspConfigDescriptor getJspConfigDescriptor()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getJspConfigDescriptor
in interfaceServletContext
-
getClassLoader
public ClassLoader getClassLoader()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getClassLoader
in interfaceServletContext
-
declareRoles
public void declareRoles(String... roleNames)
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
declareRoles
in interfaceServletContext
-
getVirtualServerName
public String getVirtualServerName()
Not implemented. A method in ServletContext interface that is not implemented and will throwUnsuportedOperationException
upon invocation- Specified by:
getVirtualServerName
in interfaceServletContext
-
-