Unregistering disabled managers

Issue #30 closed
Markus KARG created an issue

I notived that it is apparently a common pattern in the Babbler source code to register listeners even for disabled managers, and then ask for being enabled within the handleMessage listener.

This seems to be an unnecessary effort: A disabled manager will never react upon messages, so why notify it upon each single message? And an enabled manager will react upon each single message, but has to check its enabled flag again and again and again...

Performance could be improved and code complexity could be reduced, by simply registering and deregistering within setEnable(boolean), instead of just storing a flag and checkint it again and again...

Comments (4)

  1. Christian Schudt repo owner
    • changed status to open

    This is (was) more complicated than it seems, if you want to have a consistent state between service discovery features and enabled managers.

    E.g. you could also disable a feature by removing it from Service Discovery:

    xmppSession.getManager(ServiceDiscoveryManager.class).removeFeature(new Feature(Ping.NAMESPACE));
    

    But there was no event and no association from ServiceDiscoveryManager to PingManager, which could unregister listeners from it.

    This problem is now resolved with 762c563, so that this issue #30 can be resolved more easily.

  2. Log in to comment