Announcement Announcement Module
Collapse
No announcement yet.
Dynamically add or remove AOP functionality Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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">
    <aop:scoped-proxy/>
    </bean>

    <bean id="loggingInterceptor" class="dummy.TestAOP">
    <property name="timeStack" ref="timeStack" />
    </bean>
    <bean id="customerServiceProxy" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">
    <property name="advice">
    <ref local=" loggingInterceptor "/>
    </property>
    <property name="patterns">
    <value>test.pack.*</value>
    </property>

    </bean>


    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();
    beanDefinition.setBeanClass(TimeStack.class);
    beanDefinition.setAutowireCandidate(true);


    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
Working...
X