I’d like to create a custom ServiceDiscoveryManger, but I’m running into a problem described here:
Let me explain why I want a custom manager:
We want to use disco#items for a client to advertise a complex hierarchy of nodes, possibly hundreds in all. In this situation, it’s impractical to use setNodeInformationProvider( node, provider ) to set the information for every node ahead of time. Instead, it’s much more sane to ‘look up’ the node info (or at least the child items) when the request comes in for each node.
Unfortunately, that static initializer block means that I can’t practically subclass ServiceDiscoveryManger, because simply loading that class tells ServiceDiscoveryManager to essentially ‘do its thing’ with a base implementation instance and even if I create a subclass I’ll have two packet listeners contending over the same messages. Furthermore the ConnectionListener and PacketListeners that are created by ServiceDiscovyeryManger are anonymous subclasses, so I can’t remove them once they’ve been added by ServiceDiscoveryManger either!
As far as I can tell, the only way I can avoid this is by removing ServiceDiscoveryManager from smack-config.xml, and hoping that no other piece of code references that class, so that it never gets loaded and attached to my connection(s). Amirite?