public class TurbineConfig extends Object implements ServletConfig, ServletContext, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable
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.
Modifier and Type | Field and 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 Turbine
|
protected 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 Turbine
|
protected File |
root
Filenames are looked up in this directory.
|
protected int |
timeout |
ORDERED_LIBS, TEMPDIR
Constructor and Description |
---|
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.
|
TurbineConfig(String path,
String properties)
Constructs a TurbineConfig.
|
Modifier and Type | Method and Description |
---|---|
FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends Filter> filterClass)
Not implemented.
|
FilterRegistration.Dynamic |
addFilter(String filterName,
Filter filter)
Not implemented.
|
FilterRegistration.Dynamic |
addFilter(String filterName,
String className)
Not implemented.
|
void |
addListener(Class<? extends EventListener> listenerClass)
Not implemented.
|
void |
addListener(String className)
Not implemented.
|
<T extends EventListener> |
addListener(T t)
Not implemented.
|
ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends Servlet> servletClass)
Not implemented.
|
ServletRegistration.Dynamic |
addServlet(String servletName,
Servlet servlet)
Not implemented.
|
ServletRegistration.Dynamic |
addServlet(String servletName,
String className)
Not implemented.
|
<T extends Filter> |
createFilter(Class<T> clazz)
Not implemented.
|
<T extends EventListener> |
createListener(Class<T> clazz)
Not implemented.
|
<T extends Servlet> |
createServlet(Class<T> clazz)
Not implemented.
|
void |
declareRoles(String... roleNames)
Not implemented.
|
void |
dispose()
Shutdown the Turbine System, lifecycle style
|
Object |
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
an
InputStream 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 HTTP
GET 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) instead
|
void |
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.
|
protected int timeout
public static final String CONFIGURATION_PATH_KEY
public static final String PROPERTIES_PATH_KEY
public static final String PROPERTIES_PATH_DEFAULT
/WEB-INF/conf/TurbineResources.properties
).protected Map<String,Object> attributes
protected Map<String,String> initParams
public TurbineConfig(String path, Map<String,Object> attributes, Map<String,String> initParams)
For the list of recognized init parameters, see
Turbine
class.
path
- The web application root (i.e. the path for file lookup).attributes
- Servlet container (or emulator) attributes.initParams
- initialization parameters.public TurbineConfig(String path, Map<String,String> initParams)
For the list of recognized init parameters, see
Turbine
class.
path
- The web application root (i.e. the path for file lookup).initParams
- initialization parameters.public TurbineConfig(String path, String properties)
path
- The web application root (i.e. the path for file lookup).properties
- the relative path to TurbineResources.properties filepublic void initialize()
initialize
in interface org.apache.avalon.framework.activity.Initializable
public void init(RunData data)
GET
request.data
- the Turbine requestpublic void dispose()
dispose
in interface org.apache.avalon.framework.activity.Disposable
public Turbine getTurbine()
public ServletContext getServletContext()
getServletContext
in interface ServletConfig
public String getRealPath(String path)
getRealPath
in interface ServletContext
path
- A path relative to the web application root.null
if the translated path doesn't map to a file or directory.public String getInitParameter(String name)
getInitParameter
in interface ServletConfig
getInitParameter
in interface ServletContext
name
- the name of the parameter.public Enumeration<String> getInitParameterNames()
getInitParameterNames
in interface ServletConfig
getInitParameterNames
in interface ServletContext
public String getServletName()
getServletName
in interface ServletConfig
public String getServletContextName()
getServletContextName
in interface ServletContext
public String getContextPath()
getContextPath
in interface ServletContext
public URL getResource(String s) throws MalformedURLException
getResource
in interface ServletContext
s
- the path to the resourceMalformedURLException
- if unable to parse pathpublic InputStream getResourceAsStream(String s)
InputStream
object.getResourceAsStream
in interface ServletContext
s
- the path to the resource@Deprecated public void log(Exception e, String m)
log
in interface ServletContext
e
- an Exception.m
- a message.public void log(String m)
log
in interface ServletContext
m
- a message.public void log(String m, Throwable t)
log
in interface ServletContext
t
- a Throwable object.m
- a message.public Object getAttribute(String s)
getAttribute
in interface ServletContext
public Enumeration<String> getAttributeNames()
getAttributeNames
in interface ServletContext
public ServletContext getContext(String s)
UnsuportedOperationException
upon invocationgetContext
in interface ServletContext
public int getMajorVersion()
UnsuportedOperationException
upon invocationgetMajorVersion
in interface ServletContext
public String getMimeType(String s)
UnsuportedOperationException
upon invocationgetMimeType
in interface ServletContext
public int getMinorVersion()
UnsuportedOperationException
upon invocationgetMinorVersion
in interface ServletContext
public RequestDispatcher getNamedDispatcher(String s)
UnsuportedOperationException
upon invocationgetNamedDispatcher
in interface ServletContext
public RequestDispatcher getRequestDispatcher(String s)
UnsuportedOperationException
upon invocationgetRequestDispatcher
in interface ServletContext
public Set<String> getResourcePaths(String s)
UnsuportedOperationException
upon invocationgetResourcePaths
in interface ServletContext
public String getServerInfo()
UnsuportedOperationException
upon invocationgetServerInfo
in interface ServletContext
@Deprecated public Servlet getServlet(String s)
UnsuportedOperationException
upon invocationgetServlet
in interface ServletContext
@Deprecated public Enumeration<String> getServletNames()
UnsuportedOperationException
upon invocationgetServletNames
in interface ServletContext
@Deprecated public Enumeration<Servlet> getServlets()
UnsuportedOperationException
upon invocationgetServlets
in interface ServletContext
public void removeAttribute(String s)
UnsuportedOperationException
upon invocationremoveAttribute
in interface ServletContext
public void setAttribute(String s, Object o)
UnsuportedOperationException
upon invocationsetAttribute
in interface ServletContext
public int getEffectiveMajorVersion()
UnsuportedOperationException
upon invocationgetEffectiveMajorVersion
in interface ServletContext
public int getEffectiveMinorVersion()
UnsuportedOperationException
upon invocationgetEffectiveMinorVersion
in interface ServletContext
public boolean setInitParameter(String name, String value)
UnsuportedOperationException
upon invocationsetInitParameter
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, String className)
UnsuportedOperationException
upon invocationaddServlet
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
UnsuportedOperationException
upon invocationaddServlet
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
UnsuportedOperationException
upon invocationaddServlet
in interface ServletContext
public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException
UnsuportedOperationException
upon invocationcreateServlet
in interface ServletContext
ServletException
public ServletRegistration getServletRegistration(String servletName)
UnsuportedOperationException
upon invocationgetServletRegistration
in interface ServletContext
public Map<String,? extends ServletRegistration> getServletRegistrations()
UnsuportedOperationException
upon invocationgetServletRegistrations
in interface ServletContext
public FilterRegistration.Dynamic addFilter(String filterName, String className)
UnsuportedOperationException
upon invocationaddFilter
in interface ServletContext
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
UnsuportedOperationException
upon invocationaddFilter
in interface ServletContext
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
UnsuportedOperationException
upon invocationaddFilter
in interface ServletContext
public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException
UnsuportedOperationException
upon invocationcreateFilter
in interface ServletContext
ServletException
public FilterRegistration getFilterRegistration(String filterName)
UnsuportedOperationException
upon invocationgetFilterRegistration
in interface ServletContext
public Map<String,? extends FilterRegistration> getFilterRegistrations()
UnsuportedOperationException
upon invocationgetFilterRegistrations
in interface ServletContext
public SessionCookieConfig getSessionCookieConfig()
UnsuportedOperationException
upon invocationgetSessionCookieConfig
in interface ServletContext
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
UnsuportedOperationException
upon invocationsetSessionTrackingModes
in interface ServletContext
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
UnsuportedOperationException
upon invocationgetDefaultSessionTrackingModes
in interface ServletContext
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
UnsuportedOperationException
upon invocationgetEffectiveSessionTrackingModes
in interface ServletContext
public void addListener(String className)
UnsuportedOperationException
upon invocationaddListener
in interface ServletContext
public <T extends EventListener> void addListener(T t)
UnsuportedOperationException
upon invocationaddListener
in interface ServletContext
public void addListener(Class<? extends EventListener> listenerClass)
UnsuportedOperationException
upon invocationaddListener
in interface ServletContext
public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
UnsuportedOperationException
upon invocationcreateListener
in interface ServletContext
ServletException
public JspConfigDescriptor getJspConfigDescriptor()
UnsuportedOperationException
upon invocationgetJspConfigDescriptor
in interface ServletContext
public ClassLoader getClassLoader()
UnsuportedOperationException
upon invocationgetClassLoader
in interface ServletContext
public void declareRoles(String... roleNames)
UnsuportedOperationException
upon invocationdeclareRoles
in interface ServletContext
public String getVirtualServerName()
UnsuportedOperationException
upon invocationgetVirtualServerName
in interface ServletContext
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.