Search Results

Search found 1 results on 1 pages for 'user146714'.

Page 1/1 | 1 

  • Programatically Add a AnnotationSessionFactoryBean

    - by user146714
    Hi, I have a class that implements BeanDefinitionRegistryPostProcessor. I am trying to add an AnnotationSessionFactoryBean to my Spring Context in either postProcessBeanFactory or postProcessBeanDefinitionRegistry. I need to do this programatically so that I can configure the object at runtime. I am trying to do: @Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry bdr) throws BeansException { RootBeanDefinition bd = new RootBeanDefinition( AnnotationSessionFactoryBean.class); // fails here.. can not cast AnnotationSessionFactoryBean asfb = (AnnotationSessionFactoryBean)bd; bdr.registerBeanDefinition("sessionFactory", asfb); thanks for your help --updated with solution: had to do a: GenericBeanDefinition bd = new GenericBeanDefinition(); bd.setBeanClass(AnnotationSessionFactoryBean.class); bd.getPropertyValues().add("dataSource", dataSource); bdr.registerBeanDefinition("sessionFactory", bd);

    Read the article

1