xmlBlaster 2.2.0 API

org.xmlBlaster.protocol.http
Class BlasterHttpProxyServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.xmlBlaster.protocol.http.BlasterHttpProxyServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, I_LogListener

public class BlasterHttpProxyServlet
extends javax.servlet.http.HttpServlet
implements I_LogListener

This servlet doesn't leave the doGet() method after an invocation keeping a permanent http connection.

With the doGet() method you may login/logout to xmlBlaster, and receive your instant callbacks.
With the doPost() you can invoke publish/subscribe etc.

The logging output is redirected to the normal servlet log file. If you use Apache/Jserv, look into /var/log/httpd/jserv.log

Invoke for testing:
http://localhost/xmlBlaster/BlasterHttpProxyServlet?ActionType=login&xmlBlaster.loginName=martin&xmlBlaster.passwd=secret

Author:
Marcel Ruff xmlBlaster@marcelruff.info
See Also:
Serialized Form

Field Summary
static java.lang.String ENCODING
           
private  Global glob
           
private  java.lang.String header
           
private static java.util.logging.Logger log
           
private static boolean propertyRead
           
private static long serialVersionUID
           
 
Constructor Summary
BlasterHttpProxyServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          GET request from the browser, usually to do an initial login.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          POST request from the browser.
 void htmlOutput(java.lang.String htmlData, javax.servlet.http.HttpServletResponse response)
          Returns a HTML file to the Browser.
 void init(javax.servlet.ServletConfig conf)
          This method is invoked only once when the servlet is startet.
static void initSystemProperties(javax.servlet.ServletConfig conf)
          Setting the system properties.
 void log(java.util.logging.LogRecord record)
          Event fired by Logger.java through interface I_LogListener.
 void popupError(javax.servlet.http.HttpServletResponse response, java.lang.String error)
          Report an error to the browser, which displays it in an alert() message.
 void xmlOutput(java.lang.String xmlData, javax.servlet.http.HttpServletResponse response)
          Send XML-Data to browser.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, 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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

propertyRead

private static boolean propertyRead

header

private final java.lang.String header
See Also:
Constant Field Values

glob

private Global glob

log

private static java.util.logging.Logger log

ENCODING

public static final java.lang.String ENCODING
See Also:
Constant Field Values
Constructor Detail

BlasterHttpProxyServlet

public BlasterHttpProxyServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig conf)
          throws javax.servlet.ServletException
This method is invoked only once when the servlet is startet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
conf - init parameter of the servlet
Throws:
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  java.io.IOException
GET request from the browser, usually to do an initial login.

Used for login and for keeping a permanent http connection.
The sessionId from the login is delivered back to the browser, and will be used for all following calls to this and other servlets.
It is important that this login servlet generates the sessionId and no other servlet generates one - so call other servlets *after* successful login.

Example:
index.html?ActionType=login&xmlBlaster.loginName=karl&xmlBlaster.passwd=secret

Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   java.io.IOException
POST request from the browser. Handles the following requests 'ActionType' from the browser

This method is called through a SUBMIT of a HTML FORM,
the TARGET should be set to "requestFrame". The parameter ActionType must be set to one of the above methods.
For an explanation of these methods see the file xmlBlaster.idl

The asynchronous updates are pushed into the 'callbackFrame' of your browser

The key/qos values are expected to be URLEncoded

Allows simple subscribe/unSubscribe/erase of the form

?ActionType=subscribe&key.oid=cpuinfo
and complete key XML strings like
?ActionType=subscribe&key=<key oid='hello'></key>
as well.
QoS is optional, the content only needed when publishing

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
req - Data from browser
res - Response of the servlet
Throws:
javax.servlet.ServletException
java.io.IOException

initSystemProperties

public static final void initSystemProperties(javax.servlet.ServletConfig conf)
Setting the system properties.

These may be overwritten in zone.properties, e.g. servlets.default.initArgs=servlets.default.initArgs=org.xml.sax.parser=org.apache.crimson.parser.Parser2

We set the properties to choose JacORB and Suns XML parser as a default.


log

public void log(java.util.logging.LogRecord record)
Event fired by Logger.java through interface I_LogListener.

Log output from log.info(); etc. into Servlet log file.

Note that System.err.println("Hello"); will be printed into the Apache error log file /var/log/httpd.error_log
I don't know what other web servers are doing with it.

System.out.println("Hello"); will be printed to the console where you started the servlet engine.

Specified by:
log in interface I_LogListener

htmlOutput

public void htmlOutput(java.lang.String htmlData,
                       javax.servlet.http.HttpServletResponse response)
                throws javax.servlet.ServletException
Returns a HTML file to the Browser.

Parameters:
htmlData - the complete HTML page
response - the servlet response-object
Throws:
javax.servlet.ServletException
See Also:
HttpServletResponse

popupError

public void popupError(javax.servlet.http.HttpServletResponse response,
                       java.lang.String error)
Report an error to the browser, which displays it in an alert() message.

Parameters:
sessionId - The browser
error - The text to display

xmlOutput

public void xmlOutput(java.lang.String xmlData,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException
Send XML-Data to browser. The browser needs to handle the data.

Parameters:
xmlData - XML data
response - servlet response
Throws:
javax.servlet.ServletException

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.