Announcement Announcement Module
No announcement yet.
Dynamically add or remove AOP functionality Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamically add or remove AOP functionality

    Depending on the user who is logged into my application I wanted to add or remove bean definitions to the applicationContext.xml dynamically at run time

    Given below are the bean definitions that I wanted add/remove

    <bean id="timeStack" class="dummy.TimeStack" scope="session">

    <bean id="loggingInterceptor" class="dummy.TestAOP">
    <property name="timeStack" ref="timeStack" />
    <bean id="customerServiceProxy" class=" dPointcutAdvisor">
    <property name="advice">
    <ref local=" loggingInterceptor "/>
    <property name="patterns">


    I am trying to use the following piece of code to do the same:
    AutowireCapableBeanFactory factory = null;
    appContext = new ClassPathXmlApplicationContext("applicationContext .xml");
    factory = appContext.getAutowireCapableBeanFactory();
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) factory;
    GenericBeanDefinition beanDefinition = new GenericBeanDefinition();

    registry.registerBeanDefinition("timeStack", beanDefinition);

    But i am not getting how to add the <aop:scoped-proxy> tag dynamically. Please let me know whether I am on the right track or not