Changeset 0a2097a2


Ignore:
Timestamp:
Mar 24, 2017 1:07:17 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
b335ded1
Parents:
1ab67de
Message:

Addressbook: Remove static reference, hide implementation
Requires Android fix (ticket #1972)

Location:
apps/addressbook
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/build.xml

    r1ab67de r0a2097a2  
    11<?xml version="1.0"?>
    2 <project name="addressbook" default="war" basedir=".">
     2<project name="addressbook" default="all" basedir=".">
    33
    44        <property name="src" value="java/src"/>
  • apps/addressbook/java/src/net/i2p/addressbook/Daemon.java

    r1ab67de r0a2097a2  
    4444/**
    4545 * Main class of addressbook.  Performs updates, and runs the main loop.
     46 * As of 0.9.30, package private, run with DaemonThread.
    4647 *
    4748 * @author Ragnarok
    4849 *
    4950 */
    50 public class Daemon {
     51class Daemon {
    5152    public static final String VERSION = "2.0.4";
    52     private static final Daemon _instance = new Daemon();
    5353    private volatile boolean _running;
    5454    private static final boolean DEBUG = false;
     
    788788     */
    789789    public static void main(String[] args) {
     790        Daemon daemon = new Daemon();
    790791        if (args != null && args.length > 0 && args[0].equals("test"))
    791             _instance.test(args);
     792            daemon.test(args);
    792793        else
    793             _instance.run(args);
     794            daemon.run(args);
    794795    }
    795796
    796797    /** @since 0.9.26 */
    797     private static void test(String[] args) {
     798    public static void test(String[] args) {
    798799        Properties ctxProps = new Properties();
    799800        String PROP_FORCE = "i2p.naming.blockfile.writeInAppContext";
     
    876877     * refetch its subscriptions.
    877878     */
    878     public static void wakeup() {
    879         synchronized (_instance) {
    880             _instance.notifyAll();
    881         }
    882     }
    883 
    884     public static void stop() {
    885         _instance._running = false;
     879    public void wakeup() {
     880        synchronized (this) {
     881            notifyAll();
     882        }
     883    }
     884
     885    public void stop() {
     886        _running = false;
    886887        wakeup();
    887888    }
  • apps/addressbook/java/src/net/i2p/addressbook/DaemonThread.java

    r1ab67de r0a2097a2  
    3737
    3838    private final String[] args;
     39    private final Daemon daemon;
    3940
    4041    /**
     
    4546    public DaemonThread(String[] args) {
    4647        this.args = args;
     48        daemon = new Daemon();
    4749    }
    4850
     
    5759        //}
    5860        I2PAppContext.getGlobalContext().namingService().registerUpdater(this);
    59         Daemon.main(this.args);
    60         I2PAppContext.getGlobalContext().namingService().unregisterUpdater(this);
     61        try {
     62            if (args != null && args.length > 0 && args[0].equals("test"))
     63                daemon.test(args);
     64            else
     65                daemon.run(args);
     66        } finally {
     67            I2PAppContext.getGlobalContext().namingService().unregisterUpdater(this);
     68        }
    6169    }
    6270
    6371    public void halt() {
    64         Daemon.stop();
     72        daemon.stop();
    6573        interrupt();
    6674    }
    6775
    6876    /**
    69      *  The NamingServiceUpdater interface
    70      *  @param options ignored
     77     *  The NamingServiceUpdater interface.
     78     *  While this may be called directly, the recommended way
     79     *  is to call I2PAppContext.namingService().requestUpdate(Properties)
     80     *  which will call this.
     81     *
     82     *  @param options ignored, may be null
    7183     *  @since 0.8.7
    7284     */
Note: See TracChangeset for help on using the changeset viewer.