Package nl.vpro.web.servlet
Class ConfigurationServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- nl.vpro.web.servlet.ConfigurationServlet
-
- All Implemented Interfaces:
Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class ConfigurationServlet extends javax.servlet.http.HttpServlet
Serves a 'configuration.js' for javascript clients. Expects an init param "name" with that it determines the 'environment' via- Either it is the system property vpro.[name].env
- If that is missing it is the application context variable vpro/[name]/env
- If that is missing too, it is
ConfigurationServlet.Environment.PROD
- The resource [name].properties
- The resource [name].[env];properties (if exists)
- The file /WEB-INF/classes/[name].properties (if exists)
- The file /WEB-INF/classes/[name].[env];properties (if exists)
- The file ${user.home}/conf/[name].properties (if exists)
- The file ${user.home}/conf/[name].[env];properties (if exists)
- Since:
- 0.3
- Author:
- Michiel Meeuwissen
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
ConfigurationServlet.Environment
-
Constructor Summary
Constructors Constructor Description ConfigurationServlet()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
static Context
getContext()
protected ConfigurationServlet.Environment
getEnvironment()
protected long
getLastModified(javax.servlet.http.HttpServletRequest req)
protected String
getName()
protected Map<String,Object>
getProperties(javax.servlet.http.HttpServletRequest req)
static Map<String,Object>
getProperties(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
protected Map<String,String>
getSystem(javax.servlet.http.HttpServletRequest req)
void
init()
protected void
merge(javax.servlet.http.HttpServletRequest req, File file, Map<String,Object> map)
protected void
merge(javax.servlet.http.HttpServletRequest req, InputStream is, Map<String,Object> map)
protected void
mergeServletContextResource(javax.servlet.http.HttpServletRequest req, String path, Map<String,Object> map)
protected void
write(String varName, @NonNull OutputStream outputStream, @NonNull Map<String,String> system, @NonNull Map<String,Object> props)
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, service, service
-
-
-
-
Method Detail
-
getContext
public static Context getContext() throws NamingException
- Throws:
NamingException
-
getProperties
public static Map<String,Object> getProperties(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
-
init
public void init()
- Overrides:
init
in classjavax.servlet.GenericServlet
-
getLastModified
protected long getLastModified(javax.servlet.http.HttpServletRequest req)
- Overrides:
getLastModified
in classjavax.servlet.http.HttpServlet
-
doGet
protected void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws IOException
- Overrides:
doGet
in classjavax.servlet.http.HttpServlet
- Throws:
IOException
-
write
protected void write(String varName, @NonNull OutputStream outputStream, @NonNull Map<String,String> system, @NonNull Map<String,Object> props) throws IOException
- Throws:
IOException
-
merge
protected void merge(javax.servlet.http.HttpServletRequest req, InputStream is, Map<String,Object> map) throws IOException
- Throws:
IOException
-
merge
protected void merge(javax.servlet.http.HttpServletRequest req, File file, Map<String,Object> map) throws IOException
- Throws:
IOException
-
mergeServletContextResource
protected void mergeServletContextResource(javax.servlet.http.HttpServletRequest req, String path, Map<String,Object> map) throws IOException
- Throws:
IOException
-
getSystem
protected Map<String,String> getSystem(javax.servlet.http.HttpServletRequest req) throws IOException
- Throws:
IOException
-
getEnvironment
protected ConfigurationServlet.Environment getEnvironment()
-
getProperties
protected Map<String,Object> getProperties(javax.servlet.http.HttpServletRequest req) throws IOException
- Throws:
IOException
-
getName
protected String getName()
-
-