Changeset 32793ac1


Ignore:
Timestamp:
Jun 16, 2011 9:38:08 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
f8ab2c1
Parents:
83ee57a
Message:

i2ptunnel shutdown hook

File:
1 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java

    r83ee57a r32793ac1  
    2727 */
    2828public class TunnelControllerGroup {
    29     private final Log _log;
     29    private Log _log;
    3030    private static TunnelControllerGroup _instance;
    3131    static final String DEFAULT_CONFIG_FILE = "i2ptunnel.config";
     
    5656        _sessions = new HashMap(4);
    5757        loadControllers(_configFile);
     58        I2PAppContext.getGlobalContext().addShutdownTask(new Shutdown());
    5859    }
    5960
     
    7071                return;
    7172            }
     73        }
     74    }
     75
     76    /**
     77     *  Warning - destroys the singleton!
     78     *  @since 0.8.8
     79     */
     80    private static class Shutdown implements Runnable {
     81        public void run() {
     82            shutdown();
     83        }
     84    }
     85
     86    /**
     87     *  Warning - destroys the singleton!
     88     *  Caller must root a new context before calling instance() or main() again.
     89     *  @since 0.8.8
     90     */
     91    public static void shutdown() {
     92        synchronized (TunnelControllerGroup.class) {
     93            if (_instance == null) return;
     94            _instance.unloadControllers();
     95            _instance._log = null;
     96            _instance = null;
    7297        }
    7398    }
Note: See TracChangeset for help on using the changeset viewer.