I understand your intent - You basically want to set the beanFactory **only** for the *FileNameGenerator* that was instantiated as the default, not for any user-passed-in ones. Wouldn't the current implementation, though, create some level of ambiguity? Let's say, the user passes in a custom instance of the *DefaultFileNameGenerator* using *setFileNameGenerator*, then his specified beanFactory will be overridden. However, when s(he) passes in another custom non-DefaultFileNameGenerator-based instance of a *BeanFactoryAware* instance, then the beanFactory will not be overridden. 

Theoretically, you almost want to not only check if the instance is of type *DefaultFileNameGenerator* but also, whether the actual available instance was set via setFileNameGenerator or not. 

Maybe I am ways too nitpicky here, and if you feel differently I certainly can go ahead and merge the PR (Which looks good otherwise). Just wanted to mention it.