Example usage for org.springframework.aop.support NameMatchMethodPointcutAdvisor setAdvice

List of usage examples for org.springframework.aop.support NameMatchMethodPointcutAdvisor setAdvice

Introduction

In this page you can find the example usage for org.springframework.aop.support NameMatchMethodPointcutAdvisor setAdvice.

Prototype

public void setAdvice(Advice advice) 

Source Link

Document

Specify the advice that this advisor should apply.

Usage

From source file:com.aop.ProxyFactoryTest.java

public static void main(String[] args) {
    UserService userService = new UserServiceImpl();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setTarget(userService);
    proxyFactory.setInterfaces(new Class[] { UserService.class });
    NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor();
    advisor.setMappedName("addUser");
    advisor.setAdvice(new CheckInterceptor());

    proxyFactory.addAdvisor(advisor);//from ww w  .  ja va2 s .  c o  m

    UserService userServiceProxy = (UserService) proxyFactory.getProxy();
    userServiceProxy.addUser();

}

From source file:com.newlandframework.avatarmq.netty.MessageEventWrapper.java

public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    super.channelRead(ctx, msg);

    ProxyFactory weaver = new ProxyFactory(wrapper);
    NameMatchMethodPointcutAdvisor advisor = new NameMatchMethodPointcutAdvisor();
    advisor.setMappedName(MessageEventWrapper.proxyMappedName);
    advisor.setAdvice(new MessageEventAdvisor(wrapper, msg));
    weaver.addAdvisor(advisor);//from  w  ww  .  j  a v a  2  s .c o  m

    MessageEventHandler proxyObject = (MessageEventHandler) weaver.getProxy();
    proxyObject.handleMessage(ctx, msg);
}