Changeset ca6ce37 for router


Ignore:
Timestamp:
Mar 21, 2017 7:26:48 PM (3 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
4727706
Parents:
a00f11d
Message:

context: New ClientAppManagerImpl? in AppContext?, so registration
works there (for i2psnark-rpc in standalone)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/startup/RouterAppManager.java

    ra00f11d rca6ce37  
    2323 *  @since 0.9.4
    2424 */
    25 public class RouterAppManager implements ClientAppManager {
     25public class RouterAppManager extends ClientAppManagerImpl {
    2626   
    2727    private final RouterContext _context;
     
    3030    // this assumes clients do not override equals()
    3131    private final ConcurrentHashMap<ClientApp, String[]> _clients;
    32     // registered name to client
    33     private final ConcurrentHashMap<String, ClientApp> _registered;
    3432
    3533    public RouterAppManager(RouterContext ctx) {
     34        super(ctx);
    3635        _context = ctx;
    3736        _log = ctx.logManager().getLog(RouterAppManager.class);
    3837        _clients = new ConcurrentHashMap<ClientApp, String[]>(16);
    39         _registered = new ConcurrentHashMap<String, ClientApp>(8);
    4038        ctx.addShutdownTask(new Shutdown());
    4139    }
     
    9290     *  @param e may be null
    9391     */
     92    @Override
    9493    public void notify(ClientApp app, ClientAppState state, String message, Exception e) {
    9594        switch(state) {
     
    138137     *  @return true if successful, false if duplicate name
    139138     */
     139    @Override
    140140    public boolean register(ClientApp app) {
    141141        if (!_clients.containsKey(app)) {
     
    149149            _log.info("Client " + app.getDisplayName() + " REGISTERED AS " + app.getName());
    150150        // TODO if old app in there is not running and != this app, allow replacement
    151         return _registered.putIfAbsent(app.getName(), app) == null;
     151        return super.register(app);
    152152    }
    153153   
    154     /**
    155      *  Unregister with the manager. Name must be the same as that from register().
    156      *  Only required for apps used by other apps.
    157      *
    158      *  @param app non-null
    159      */
    160     public void unregister(ClientApp app) {
    161         _registered.remove(app.getName(), app);
    162     }
    163    
    164     /**
    165      *  Get a registered app.
    166      *  Only used for apps finding other apps.
    167      *  Do not hold a static reference.
    168      *  If you only need to find a port, use the PortMapper instead.
    169      *
    170      *  @param name non-null
    171      *  @return client app or null
    172      */
    173     public ClientApp getRegisteredApp(String name) {
    174         return _registered.get(name);
    175     }
    176 
    177154    /// end ClientAppManager interface
    178155
Note: See TracChangeset for help on using the changeset viewer.