For my proposal:
1- if the client provide a name, then this name overwrite all the AdaptorManager logic
2- If there's no name then the AdaptorManager rely on the underlying adaptor to provide one.
3- >> uniqueness is a problem for whoever is issuing the "add" command
I still think that if the one that is doing the add is automatically able to figure out a unique name in order to avoid duplicate in a distributed environment without talking to anyone else, then the that logic can be pushed down the adaptorManager, who is the only one to have the global vision.
4- >> isDuplicate() need to be called for each existing adaptor, every time we create one
No. the AdaptorManager, receive a Add command then call a isDuplicate's method to the factory,
Here the workfow:
4.1- At the factory level, if there's no adaptor already registered for this AdaptorType then there's no duplicate
4.1.1- if it's not a duplicate The AdaptorManger call the factory to create the adaptor
18.104.22.168- The factory create the new adaptor and register that instance as the instance that will provide all answers for the isDuplicate call for that specific AdaptorType (hash.put(AdaptorType, adaptor) )
4.1.2- if there's already one adaptor registered for the AdaptorType then the factory return hash.get(AdaptorType).isDuplicate(...)
22.214.171.124- At the AdaptorManager level if it's a duplicate then it returns the existing adaptor based on the name, otherwise call the factory
So there's no iteration over any adaptors, just a get from a hash based on AdaptorType + 1 call to isDuplicate(..) and therefore there's no performance issue