|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.GenericServlet javax.servlet.http.HttpServlet org.xmlBlaster.protocol.http.ajax.AjaxServlet
public class AjaxServlet
This servlet supports requests from a browser, it queries the topic given by "gpsTopicId" configuration which needs to contain GPS coordinates (published for example by a PDA).
Use xmlBlaster/demo/http/gps.html to display the coordinates in a map.
Callback messages are send as xml to the browser:<xmlBlasterResponse> <update> <qos>...</qos> <key>...</key> <content>...</content> </update> </xmlBlasterResponse>
Field Summary | |
---|---|
private java.util.Map |
blasterInstanceMap
key is the browser sessionId |
private java.util.Set |
blockedIPs
|
private ContextNode |
contextNode
|
private int |
maxInactiveInterval
|
private int |
maxUserSessions
We support additional admin sessions |
private JmxMBeanHandle |
mbeanHandle
My JMX registration |
private java.util.Properties |
props
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
AjaxServlet()
|
Method Summary | |
---|---|
void |
add(java.lang.String sessionId,
BlasterInstance blasterInstance)
|
void |
addBlockedIP(java.lang.String ip)
|
java.lang.String |
cleanupOldSessionsKeepGivenAmount(int maxSessions,
java.lang.String notificationText,
boolean creationTimestamp)
|
private void |
cleanupSession(javax.servlet.http.HttpServletRequest req)
|
void |
clearBlockedIPs()
|
void |
destroy()
|
void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
ServletSessionTimeout according to specification: The default timeout period for sessions is defined by the servlet container and can be obtained via the getMaxInactiveInterval method of the HttpSession interface. |
void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
|
boolean |
get(javax.servlet.http.HttpServletRequest req,
java.lang.String key,
boolean defaultVal)
|
int |
get(javax.servlet.http.HttpServletRequest req,
java.lang.String key,
int defaultVal)
|
long |
get(javax.servlet.http.HttpServletRequest req,
java.lang.String key,
long defaultVal)
|
private BlasterInstance |
getBlasterInstance(javax.servlet.http.HttpServletRequest req)
|
BlasterInstance[] |
getBlasterInstances()
|
java.lang.String[] |
getBlockedIPs()
|
private int |
getConfProp(java.lang.String key,
int def)
|
ContextNode |
getContextNode()
|
java.lang.String |
getInfo(javax.servlet.http.HttpServletRequest req)
|
java.lang.String |
getInfo(javax.servlet.http.HttpServletRequest req,
boolean more,
boolean all)
|
private java.util.Locale |
getLocale(javax.servlet.http.HttpServletRequest request)
|
int |
getMaxUserSessions()
|
int |
getNumBlasterInstances()
|
boolean |
getReqProp(javax.servlet.http.HttpServletRequest req,
java.lang.String key,
boolean def)
Access a boolean parameter. |
java.lang.String |
getServletInfo()
|
private java.lang.String |
getText(javax.servlet.http.HttpServletRequest request,
java.lang.String key,
java.lang.String defaultVal,
java.lang.String arg1,
java.lang.String arg2)
Support for internationalization of exceptions. |
private BlasterInstance |
hasBlasterInstance(javax.servlet.http.HttpServletRequest req)
|
void |
init(javax.servlet.ServletConfig conf)
|
boolean |
isBlockedIP(java.lang.String ip)
|
void |
log(java.lang.String text)
|
boolean |
maxUserSessionsReached(javax.servlet.http.HttpServletRequest req)
|
void |
removeBlasterInstance(java.lang.String sessionId)
|
void |
setMaxUserSessions(int maxUserSessions)
|
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, getServletName, init, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private java.util.Properties props
private int maxInactiveInterval
private ContextNode contextNode
private JmxMBeanHandle mbeanHandle
private java.util.Set blockedIPs
private java.util.Map blasterInstanceMap
private int maxUserSessions
Constructor Detail |
---|
public AjaxServlet()
Method Detail |
---|
private int getConfProp(java.lang.String key, int def)
public void init(javax.servlet.ServletConfig conf) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
javax.servlet.ServletException
public void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
doPost
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
public java.lang.String getInfo(javax.servlet.http.HttpServletRequest req)
public java.lang.String getInfo(javax.servlet.http.HttpServletRequest req, boolean more, boolean all)
private java.util.Locale getLocale(javax.servlet.http.HttpServletRequest request)
private java.lang.String getText(javax.servlet.http.HttpServletRequest request, java.lang.String key, java.lang.String defaultVal, java.lang.String arg1, java.lang.String arg2)
request
- key
- The key to lookup the textdefaultVal
- The text to take if not foundarg1
- Can be nullarg2
- Can be null
private void cleanupSession(javax.servlet.http.HttpServletRequest req)
public boolean getReqProp(javax.servlet.http.HttpServletRequest req, java.lang.String key, boolean def)
req
- key
- The URL keydef
- The default if not found
public void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
ServletSessionTimeout according to specification: The default timeout period for sessions is defined by the servlet container and can be obtained via the getMaxInactiveInterval method of the HttpSession interface. This timeout can be changed by the Developer using the setMaxInactiveInterval method of the HttpSession interface. The timeout periods used by these methods are defined in seconds. By definition, if the timeout period for a session is set to -1, the session will never expire.
We have set the maxInactiveInterval to 1800 sec in web.xml (30 min):
If no Ajax call arrives after the given timeout the servlet-session dies, as a browser user may choose to halt NMEA updates we must set this to a high enough value. The web.xml setting <session-config>
doGet
in class javax.servlet.http.HttpServlet
javax.servlet.ServletException
java.io.IOException
public boolean get(javax.servlet.http.HttpServletRequest req, java.lang.String key, boolean defaultVal)
public long get(javax.servlet.http.HttpServletRequest req, java.lang.String key, long defaultVal)
public int get(javax.servlet.http.HttpServletRequest req, java.lang.String key, int defaultVal)
public void add(java.lang.String sessionId, BlasterInstance blasterInstance)
public void removeBlasterInstance(java.lang.String sessionId)
private BlasterInstance hasBlasterInstance(javax.servlet.http.HttpServletRequest req) throws XmlBlasterException
req
-
XmlBlasterException
private BlasterInstance getBlasterInstance(javax.servlet.http.HttpServletRequest req) throws XmlBlasterException
XmlBlasterException
public java.lang.String getServletInfo()
getServletInfo
in interface javax.servlet.Servlet
getServletInfo
in class javax.servlet.GenericServlet
public int getNumBlasterInstances()
getNumBlasterInstances
in interface AjaxServletMBean
public BlasterInstance[] getBlasterInstances()
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
public void log(java.lang.String text)
log
in class javax.servlet.GenericServlet
public ContextNode getContextNode()
public java.lang.String cleanupOldSessionsKeepGivenAmount(int maxSessions, java.lang.String notificationText, boolean creationTimestamp)
cleanupOldSessionsKeepGivenAmount
in interface AjaxServletMBean
public boolean isBlockedIP(java.lang.String ip)
public void addBlockedIP(java.lang.String ip)
public void clearBlockedIPs()
clearBlockedIPs
in interface AjaxServletMBean
public java.lang.String[] getBlockedIPs()
getBlockedIPs
in interface AjaxServletMBean
public int getMaxUserSessions()
getMaxUserSessions
in interface AjaxServletMBean
public void setMaxUserSessions(int maxUserSessions)
setMaxUserSessions
in interface AjaxServletMBean
public boolean maxUserSessionsReached(javax.servlet.http.HttpServletRequest req)
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |