Как добавить или удалить Spring AOP прокси в работающем приложении без перезапуска сервера?
Примерно так
GenericApplicationContext ctx = new GenericApplicationContext();
BeanDefinitionBuilder promotion4Advice = BeanDefinitionBuilder.rootBeanDefinition(Promotion4Action.class).addPropertyValue("discountPercentage", 0.5);
promotion4Advice.addPropertyValue("discountCode", 16);
promotion4Advice.addPropertyValue("discountComment", "50% on regular item");
ctx.registerBeanDefinition("promotion4Advice", promotion4Advice.getBeanDefinition());
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ProxyFactoryBean.class);
builder.addPropertyValue("proxyTargetClass", true);
builder.addPropertyValue("interceptorNames", new String[] {"promotion4Advice"});
ctx.registerBeanDefinition("proxyFactoryBean", builder.getBeanDefinition());
Моя конфигурация XML выглядит такthis:
<bean id="promotion4Advice"
class="com.promotion.actions.Promotion4Action">
<property name="discountPercentage" value="0.5" />
<property name="discountCode" value="16" />
<property name="discountComment" value="50% on regular item" />
</bean>
<aop:config proxy-target-class="true">
<aop:aspect id="promotion4Aspect" ref="promotion4Advice">
<aop:pointcut id="promotion4PointCut"
expression="execution(* com.controller.ShoppingBagController.defaultHandler(javax.servlet.http.HttpServletRequest)) and args(request)" />
<aop:before pointcut-ref="promotion4PointCut" method="applyPromotion4"
arg-names="request" />
</aop:aspect>
<aop:aspect id="promotion4Aspect1" ref="promotion4Advice">
<aop:pointcut id="promotion4PointCut1"
expression="execution(* com.controller.ReviewOrderController.handleRequest(javax.servlet.http.HttpServletRequest)) and args(request)" />
<aop:before pointcut-ref="promotion4PointCut1" method="interceptOrderDetails"
arg-names="request" />
</aop:aspect>
<aop:aspect id="promotion4Aspect4" ref="promotion4Advice">
<aop:pointcut id="promotion4PointCut4"
expression="execution(* com.controller.ShoppingBagController.applyPromoCode(javax.servlet.http.HttpServletRequest, String, String)) and args(request, promoCode, mappedURL)" />
<aop:after pointcut-ref="promotion4PointCut4" method="interceptPromoCode"
arg-names="request,promoCode,mappedURL" />
</aop:aspect>
</aop:config>
Это одно из поощрений ... Как и выше, у меня есть 3 других и я хочу иметь возможность настроить их динамически через aop без изменения XML и перезапуска сервера.Пожалуйста, помогите