EJBRootContext currently initializes the affinity using getProviderUri(). However, the changes introduced in
WFNC-14 mean that this value can now change. We should consider how to handle such changes.
Some thoughts from David on this (see https://github.com/wildfly/wildfly-naming-client/pull/27):
- We can't have mutable locators, therefore we can't have mutable affinities.
- We can and do have mutable proxies, where we can modify the locator (including its affinity), the weak affinity, and other things.
- It is possible to modify URI affinity, or introduce a new affinity type which has multiple URI values, though this might add a layer of complexity to an already too-complex system. In a lot of ways it makes sense though, especially if weak affinity were used to "pin" to a node.
- A hybrid idea might be to add an indirection layer to the proxy itself, so the proxy uses a Supplier. But, this is going to be very difficult to make work with the existing serialization format of the proxy invocation handler.
- It is possible to track all the proxies associated with a naming provider, and go through and rewire their strong affinities whenever the connection turns over. This might also be fairly complex, and would require the use of weak references (wildfly-common has a good reference-cleaning facility though), so we'd only want to do it in the multi-provider case.
Of all these ideas, the last one is probably the most achievable, if arguably a bit ugly.