when Jsr181HandlerMapping.processBeans() called, it will iterate all the bean in app context
private void processBeans(ApplicationContext beanFactory, AnnotationServiceFactory serviceFactory)
{
String[] beanNames = beanFactory.getBeanDefinitionNames();
// Take any bean name or alias that has a web service annotation
for (int i = 0; i < beanNames.length; i++)
{
if (!beanFactory.isSingleton(beanNames[i])) continue;
Class clazz;
Object bean;
try
{
clazz = getApplicationContext().getType(beanNames[i]);
bean = beanFactory.getBean(beanNames[i]);
but if a abstract bean in context, beanFactory.getBean may force spring create abstract bean, and raise a BeanIsAbstractException error.
org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'abstractTxDefinition': Bean definition is abstract
so we must check the bean definition first, like this
ConfigurableApplicationContext.getBeanFactory().getBeanDefinition().isAbstract()
maybe we also need to add a service adapter to process lazy init bean.
private void processBeans(ApplicationContext beanFactory, AnnotationServiceFactory serviceFactory)
{
String[] beanNames = beanFactory.getBeanDefinitionNames();
ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext) beanFactory;
// Take any bean name or alias that has a web service annotation
for (int i = 0; i < beanNames.length; i++)
{
BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanNames[i]);
if (!def.isSingleton() || def.isAbstract()) continue;