ws-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sreenath Nampally <sreen...@tigr.ORG>
Subject doPost/doGet methods of Servlet in xmlrpc3.0 (latest version)
Date Tue, 15 Aug 2006 16:41:52 GMT
Hello all,

We were using xmlrpc1.2-b1 but we are planning to use a 'timeout'
when executing the 'executeAsync' methods.  To do that we moved to
the latest xmlrpc-3.0, but I got stuck at implementing the 'doPost' and
'doGet' methods for my servlet class (Which is given below)

Can somebody tell me how will the 'doPost' method from v1.2-b1
will transfom into v3.0 ?  Seems like the 'execute' method  in
XmlRpcServer  class do not accept an InputStream any more.

execute (java.io.InputStream is)   CHANGED TO 
execute(XmlRpcRequest pRequest)  in XmlRpcServer class.

A sample 'doPost' imlementation code for this change will help.

Also,  is there a way to implement a timeout mechanism in 1.2-b1 ?


Thanks
Sree

------------------------------------------------------------------------------
public class CommandServlet extends HttpServlet {

    private static final long serialVersionUID = 6449353904844527876L;
    private XmlRpcServer xmlRpc;
   
    public void init(ServletConfig config) throws ServletException {
        boolean fileHandlesValid = hasMinimumFilehandles();
        if (! fileHandlesValid) {
            System.out.println("Warning! Check the hard ulimit setting 
		for open filehandles!");
        }
        try {
            int maxThreads = 
		Integer.parseInt(HTCConfig.getProperty("xml.rpc.max.threads"));
            System.out.println("Setting max threads in XMLRPC to " + 
							maxThreads);
            xmlRpc = new XmlRpcServer();
            xmlRpc.setMaxThreads(maxThreads);
           
            PropertyHandlerMapping phm = new PropertyHandlerMapping();
           
            //Provide the handler classes directly,
            phm.addHandler("HTCServer", 
CommandServer.getInstance().getClass());
            phm.addHandler("MWServer", Server.getInstance().getClass());
            xmlRpc.setHandlerMapping(phm);
        }
        catch (Exception x) {
            throw new ServletException("Servlet initialization error: " 
+ x.toString ());
        }
    }
   
    private boolean hasMinimumFilehandles() {
        boolean valid = false;
        try {
            int maxFileHandles = Ulimit.getMaxOpenFileHandles();
            int minimumFileHandles =  
Integer.parseInt(HTCConfig.getProperty("minimum.filehandles"));
            if (maxFileHandles >= minimumFileHandles) {
                valid = true;
            }
        } catch (Exception e) {
            // Ignored. A problem determining the ulimit should not 
cause the service to fail.
        }
        return valid;
    }

    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    {
       // Implementation for the old version
        byte[] result = xmlRpc.execute(req.getInputStream ());
        res.setContentType("text/xml");
        res.setContentLength(result.length);
        OutputStream output = res.getOutputStream();
        output.write(result);
        output.flush();
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    {
// Implementation for the old version
        byte[] result = xmlRpc.execute(req.getInputStream ());
        res.setContentType("text/xml");
        res.setContentLength(result.length);
        OutputStream output = res.getOutputStream();
        output.write(result);
        output.flush();
    }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: xmlrpc-user-unsubscribe@ws.apache.org
For additional commands, e-mail: xmlrpc-user-help@ws.apache.org


Mime
View raw message