Changeset 3939 for trunk/pfixcore

Show
Ignore:
Timestamp:
11/21/08 14:20:13 (2 months ago)
Author:
mtld
Message:

fixed NPE problem with abstract bean definitions containing no class declaration

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pfixcore/ChangeLog

    r3938 r3939  
     12008-11-21  Martin Leidig  <mleidig@schlund.de> 
     2 
     3        Fixed issues with abstract bean definitions containing no class 
     4        declaration and leading to NPEs. 
     5 
     6        * src/org/pustefixframework/container/spring/beans/AnnotationBeanDefinitionPostProcessor.java 
     7        * src/org/pustefixframework/container/spring/http/PustefixHandlerMapping.java 
     8        * projects/sample1/conf/spring.xml 
     9 
    1102008-11-21  Martin Leidig  <mleidig@schlund.de> 
    211 
  • trunk/pfixcore/projects/sample1/conf/spring.xml

    r3926 r3939  
    99  <context:annotation-config/> 
    1010 
    11   <bean id="testdata" class="de.schlund.pfixcore.example.TestData" scope="session"
     11  <bean id="testdata" class="de.schlund.pfixcore.example.TestData" scope="session" parent="testdata_base"
    1212    <aop:scoped-proxy/> 
    13     <property name="text" value="${testdata.defaulttext}"/> 
    1413    <property name="data" ref="${ref.testdata}"/> 
    1514  </bean> 
     
    2120  <bean id="global_testdata_prod" class="de.schlund.pfixcore.example.TestData"> 
    2221    <property name="text" value="baz"/> 
     22  </bean> 
     23 
     24  <bean id="testdata_base" abstract="true"> 
     25    <property name="text" value="${testdata.defaulttext}"/> 
    2326  </bean> 
    2427 
  • trunk/pfixcore/src/org/pustefixframework/container/spring/beans/AnnotationBeanDefinitionPostProcessor.java

    r3929 r3939  
    8686        for (String beanName : beanFactory.getBeanDefinitionNames()) { 
    8787            BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); 
    88             if (beanDefinition.getBeanClassName().equals("org.springframework.aop.scope.ScopedProxyFactoryBean")) { 
     88            if (!beanDefinition.isAbstract() && beanDefinition.getBeanClassName().equals("org.springframework.aop.scope.ScopedProxyFactoryBean")) { 
    8989                PropertyValue value = beanDefinition.getPropertyValues().getPropertyValue("targetBeanName"); 
    9090                if (value != null) { 
     
    106106     */ 
    107107    private void processBeanDefinition(String beanName, BeanDefinition beanDefinition, ConfigurableListableBeanFactory beanFactory) { 
     108        if(beanDefinition.isAbstract()) return; 
    108109        ClassLoader beanClassLoader = getClassLoader(beanFactory); 
    109110        Class<?> beanClass; 
     
    206207            } 
    207208            BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); 
     209            if(beanDefinition.isAbstract()) continue; 
    208210            Class<?> beanClass; 
    209211            try { 
  • trunk/pfixcore/src/org/pustefixframework/container/spring/http/PustefixHandlerMapping.java

    r3868 r3939  
    5151        ApplicationContext applicationContext = getApplicationContext(); 
    5252        for (String beanName : applicationContext.getBeanDefinitionNames()) { 
    53             if (HandlerInterceptor.class.isAssignableFrom(applicationContext.getType(beanName)) 
    54                     || WebRequestInterceptor.class.isAssignableFrom(applicationContext.getType(beanName))) { 
    55                 // Ignore scoped beans - there should be a scoped proxy that 
    56                 // will be used instead. 
    57                 if (!applicationContext.isPrototype(beanName) 
    58                         && !applicationContext.isSingleton(beanName)) { 
    59                     continue; 
    60                 } 
    61                 Object bean = applicationContext.getBean(beanName); 
    62                 if (!interceptors.contains(bean)) { 
    63                     interceptors.add(bean); 
     53            Class clazz = applicationContext.getType(beanName); 
     54            if(clazz != null) { 
     55                if (HandlerInterceptor.class.isAssignableFrom(clazz) 
     56                        || WebRequestInterceptor.class.isAssignableFrom(clazz)) { 
     57                    // Ignore scoped beans - there should be a scoped proxy that 
     58                    // will be used instead. 
     59                    if (!applicationContext.isPrototype(beanName) 
     60                            && !applicationContext.isSingleton(beanName)) { 
     61                        continue; 
     62                    } 
     63                    Object bean = applicationContext.getBean(beanName); 
     64                    if (!interceptors.contains(bean)) { 
     65                        interceptors.add(bean); 
     66                    } 
    6467                } 
    6568            }