Changeset d7d058e


Ignore:
Timestamp:
Nov 29, 2009 5:58:24 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
412d641e
Parents:
4b6989e
Message:

addressbook servlet cleanup

Location:
apps/addressbook
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/java/src/net/i2p/addressbook/Servlet.java

    r4b6989e rd7d058e  
    2222package net.i2p.addressbook;
    2323
     24import java.io.IOException;
     25import java.io.PrintWriter;
    2426import java.util.Random;
    2527
     
    4042 */
    4143public class Servlet extends HttpServlet {
    42     private Thread _thread;
    43     private String _nonce;
     44    private Thread thread;
     45    private String nonce;
    4446    private static final String PROP_NONCE = "addressbook.nonce";
    4547
     
    5153     * see javax.servlet.Servlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
    5254     */
    53     public void service(HttpServletRequest request, HttpServletResponse response) {
     55    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    5456        //System.err.println("Got request nonce = " + request.getParameter("nonce"));
    55         if (_thread != null && request.getParameter("wakeup") != null &&
    56             _nonce != null && _nonce.equals(request.getParameter("nonce"))) {
     57        if (this.thread != null && request.getParameter("wakeup") != null &&
     58            this.nonce != null && this.nonce.equals(request.getParameter("nonce"))) {
    5759            //System.err.println("Sending interrupt");
    58             _thread.interrupt();
     60            this.thread.interrupt();
     61            // no output
     62        } else {
     63            PrintWriter out = response.getWriter();
     64            out.write("I2P addressbook OK");
    5965        }
    60         // no output
    6166    }
    6267
     
    7176            System.err.println("Addressbook init exception: " + exp);
    7277        }
    73         _nonce = "" + Math.abs((new Random()).nextLong());
     78        this.nonce = "" + Math.abs((new Random()).nextLong());
    7479        // put the nonce where susidns can get it
    75         System.setProperty(PROP_NONCE, _nonce);
     80        System.setProperty(PROP_NONCE, this.nonce);
    7681        String[] args = new String[1];
    7782        args[0] = config.getInitParameter("home");
    78         _thread = new DaemonThread(args);
    79         _thread.setDaemon(true);
    80         _thread.setName("Addressbook");
    81         _thread.start();
     83        this.thread = new DaemonThread(args);
     84        this.thread.setDaemon(true);
     85        this.thread.setName("Addressbook");
     86        this.thread.start();
    8287        System.out.println("INFO: Starting Addressbook " + Daemon.VERSION);
    8388        //System.out.println("INFO: config root under " + args[0]);
  • apps/addressbook/web.xml

    r4b6989e rd7d058e  
    1717    <servlet-mapping>
    1818      <servlet-name>addressbook</servlet-name>
    19       <url-pattern>/</url-pattern>
     19      <url-pattern>*</url-pattern>
    2020    </servlet-mapping>
    2121
Note: See TracChangeset for help on using the changeset viewer.