Context : A lot of beans managed by Spring (more than 2500 beans) and about 120 endpoints managed by CXF
The loading time of the 120 web services is approximately 4 minutes, too long for me !!
I identified an area for improvement :
Slowness comes from getExtension(Class<T> extensionType) method
Here, Spring is looking for beans of a Class in his big context...
Great, but if no beans are found, the next time this method is called with the same Class, this method is looking again in Spring beans (by getBeansOfType) !!!
it can be easily improved by adding an emptyBeanExtensions Set which goal is to identify wich Class has no Spring beans.
Exemple (I saved more than 1 minute loading time with this code):
public final <T> T getExtension(Class<T> extensionType)
Object obj = extensions.get(extensionType);
if (obj == null && !emptyExtensions.contains(extensionType))
ConfiguredBeanLocator loc = (ConfiguredBeanLocator) extensions.get(ConfiguredBeanLocator.class);
if (loc == null)
if (loc != null)
Collection<?> objs = loc.getBeansOfType(extensionType);
if (objs != null)
for (Object o : objs)
obj = extensions.get(extensionType);
if (null != obj)