|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.hippoecm.hst.site.container.HstSiteConfigServlet
public class HstSiteConfigServlet
HST Site Container Servlet This servlet should initialize all the components that can be accessed via HstServices from the each HST-based applications. Under portal environment, this servlet may not be used because the portal itself can initialize all the necessary component for each HST-based portlet application.
The configuration could be set by a properties file or an xml file. If you would set the configuration by a properties file, you can set an init parameter named 'hst-config-properties' for the servlet config or for the servlet context.
The parameter value for the properties file or the xml file is regarded as a web application context relative path or file system relative path if the path does not start with 'file:'. So, you should use a 'file:' prefixed URI for the path parameter value if you want to set an absolute path. When the path starts with a leading slash ('/'), the path is regarded as a servlet context relative path. If the path does not start with 'file:' nor with a leading slash ('/'), it is regarded as a relative path of the file system.
For example, you can add an init parameter named 'hst-config-properties' for this servlet config like the following:
<servlet>
<servlet-name>HstSiteConfigServlet</servlet-name>
<servlet-class>org.hippoecm.hst.site.container.HstSiteConfigServlet</servlet-class>
<init-param>
<param-name>hst-config-properties</param-name>
<param-value>/WEB-INF/hst-config.properties</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<context-param>
<param-name>hst-config-properties</param-name>
<param-value>/WEB-INF/hst-config.properties</param-value>
</context-param>
<!-- SNIP -->
<servlet>
<servlet-name>HstSiteConfigServlet</servlet-name>
<servlet-class>org.hippoecm.hst.site.container.HstSiteConfigServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
The servlet will retrieve the config init parameter first and it will retrieve the context init parameter
when the config init parameter is not set.
Also, the configuration can be set by an XML file which is of the XML configuration format of Apache Commons Configuration. If you want to set the configuration by the Apache Commons Configuration XML file, you should provide an init parameter named 'hst-configuration' for servlet config or servlet context. For example,
<servlet>
<servlet-name>HstSiteConfigServlet</servlet-name>
<servlet-class>org.hippoecm.hst.site.container.HstSiteConfigServlet</servlet-class>
<init-param>
<param-name>hst-configuration</param-name>
<param-value>/WEB-INF/hst-configuration.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Also, you can set context init parameter instead of the config init parameter like the following:
<context-param>
<param-name>hst-configuration</param-name>
<param-value>/WEB-INF/hst-configuration.xml</param-value>
</context-param>
<!-- SNIP -->
<servlet>
<servlet-name>HstSiteConfigServlet</servlet-name>
<servlet-class>org.hippoecm.hst.site.container.HstSiteConfigServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
/WEB-INF/hst-configuration.xml
file like the following example.
In this example, you can see that system properties can be aggregated, multiple properties files can be added and
system property values can be used to configure other properties file paths as well:
<?xml version='1.0'?>
<configuration>
<system/>
<properties fileName='${catalina.home}/conf/hst-config-1.properties'/>
<properties fileName='${catalina.home}/conf/hst-config-2.properties'/>
</configuration>
Please refer to the documentation of Apache Commons Configuration for details.
Field Summary | |
---|---|
protected boolean |
allRepositoriesAvailable
|
protected String[] |
assemblyOverridesConfigurations
|
protected boolean |
checkRepositoriesRunning
|
protected org.apache.commons.configuration.Configuration |
configuration
|
protected boolean |
forecefulReinitialization
|
static String |
HST_CONFIG_PROPERTIES_PARAM
|
static String |
HST_CONFIGURATION_PARAM
|
protected boolean |
initialized
|
protected Map<String[],Boolean> |
repositoryCheckingStatus
|
Constructor Summary | |
---|---|
HstSiteConfigServlet()
|
Method Summary | |
---|---|
protected boolean |
checkAllRepositoriesRunning()
|
void |
destroy()
|
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
In this application doGet and doPost are the same thing. |
protected String |
getConfigOrContextInitParameter(String paramName,
String defaultValue)
|
protected org.apache.commons.configuration.Configuration |
getConfiguration(javax.servlet.ServletConfig servletConfig)
The goal of this method is to load the configuration using parameters provided by servlet config parameters, and/or system parameters. |
protected File |
getResourceFile(String resourcePath)
Returns the physical resource file object. |
void |
init(javax.servlet.ServletConfig config)
Intialize Servlet. |
protected void |
initializeComponentManager(javax.servlet.ServletConfig config)
|
protected boolean |
isInitialized()
|
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String HST_CONFIGURATION_PARAM
public static final String HST_CONFIG_PROPERTIES_PARAM
protected String[] assemblyOverridesConfigurations
protected boolean initialized
protected boolean forecefulReinitialization
protected boolean checkRepositoriesRunning
protected boolean allRepositoriesAvailable
protected org.apache.commons.configuration.Configuration configuration
protected Map<String[],Boolean> repositoryCheckingStatus
Constructor Detail |
---|
public HstSiteConfigServlet()
Method Detail |
---|
public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
protected boolean isInitialized()
protected void initializeComponentManager(javax.servlet.ServletConfig config)
public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws IOException, javax.servlet.ServletException
doGet
in class javax.servlet.http.HttpServlet
IOException
javax.servlet.ServletException
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws IOException, javax.servlet.ServletException
doPost
in class javax.servlet.http.HttpServlet
req
- Servlet request.res
- Servlet response.
IOException
- a servlet exception.
javax.servlet.ServletException
- a servlet exception.public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
protected boolean checkAllRepositoriesRunning()
protected org.apache.commons.configuration.Configuration getConfiguration(javax.servlet.ServletConfig servletConfig) throws javax.servlet.ServletException
The goal of this method is to load the configuration using parameters provided by servlet config parameters, and/or system parameters. Some sane defaults are available as well.
You can use the commons configuration xml config, which by default should be in the WEB-INF folder. You can also configure the location of this file in init-params of the servlet. Check the example
Another way to configure commons configuration is to use a properties file. Again the location by default is in the WEB-INF folder, but you can change location and name of the file using init-params of the servlet
Example - using xml configuration and a system parameter-DConfig.dir=/usr/local/tomcat/config
hst-configuration.xml(in the WEB-INF folder)
<configuration> <properties fileName="${Config.dir}/site/hst-config.properties"/> </configuration>Example - using servlet init param for hst.properties
web.xml
<init-param> <param-name>hst-config-properties</param-name> <param-value>/usr/local/tomcat/config/site/hst-config.properties</param-value> </init-param>
servletConfig
- ServletConfig that contains the init params
javax.servlet.ServletException
- thrown if file's cannot be found or configuration problems arise.protected String getConfigOrContextInitParameter(String paramName, String defaultValue)
protected File getResourceFile(String resourcePath)
resourcePath
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |