orz.neptune.prospring3.ch6.HelloWorldAOPExample.java Source code

Java tutorial

Introduction

Here is the source code for orz.neptune.prospring3.ch6.HelloWorldAOPExample.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package orz.neptune.prospring3.ch6;

import org.springframework.aop.framework.ProxyFactory;

/**
 *
 * @author Administrator
 */
public class HelloWorldAOPExample {

    public static void main(String[] args) {
        MessageWriter target = new MessageWriter();

        ProxyFactory pf = new ProxyFactory();

        pf.addAdvice(new MessageDecorator());
        pf.setTarget(target);

        MessageWriter proxy = (MessageWriter) pf.getProxy();

        target.writeMessage();

        System.out.println("");

        proxy.writeMessage();
    }
}