Cache KeyGenerator

The KeyGenerator to use for a given operation is now cached on startup
so that multiple calls to it does not resolve the instance to use over and
over again. Also updated the way a custom generator is resolved against
the bean factory to be consistent with the rest of the code.

Issue: SPR-10629