Beispiel #1
0
 /**
  * Check, parse, verify the <code>req</code>. Attribute a client thread to serve the client.
  *
  * @see xsul.http_server.HttpMiniServlet#service(xsul.http_server.HttpServerRequest,
  *     xsul.http_server.HttpServerResponse)
  */
 public void service(HttpServerRequest req, HttpServerResponse resp) throws HttpServerException {
   // Thread allocation for the new client
   try {
     XmlElement el = builder.parseFragmentFromInputStream(req.getInputStream());
     // FIXME XmlElement el =
     // builder.parseFragmentFromInputStream(req.getInputStream(),
     // req.getCharset());
     SoapUtil soapUtil = SoapUtil.selectSoapFragrance(el, soapFragrances);
     String path = req.getPath();
     //          Path Treatment to get arguments
     String arguments = null;
     if (path != null) {
       // Analysiing path
       if (path.startsWith("/")) {
         path = path.substring(1);
       }
       String method = req.getMethod();
       if (method.equals("GET")) {
         // Remove arguments from path
         int argStart = path.indexOf('?');
         if (argStart != -1) {
           // There are some arguments
           arguments = path.substring(argStart, path.length());
           path = path.replaceAll("\\?.*", "");
         }
       }
     }
     ClientConnection client = new ClientConnection(path, arguments, el, soapUtil);
     pool.execute(
         client); // NOTE: pool will now "execute" client (the sentence may be delayed ...)
     // Successful HTTP message transmission
     // Send Ok to the client
     this.sendHttpOk(resp);
   } catch (Exception e) {
     SendError.send(resp, "500", "Thread Interrupted Exception");
     logger.warning("Couldn't allocate a thread to the client", e);
   }
 }