Dynamic proxy   動態(tài)代理

Befor talking about runtime weaving, let's take a look at Java dynamic proxy.

在說運行時織入之間,我們先看看java動態(tài)代理

電腦培訓,計算機培訓,平面設(shè)計培訓,網(wǎng)頁設(shè)計培訓,美工培訓,Web培訓,Web前端開發(fā)培訓

public class DynamicProxyTest {    public interface Vehicle
    {        void whistle();
    }    public static class Boat implements Vehicle
    {
        @Override        public void whistle()
        {
            System.out.println( "Boat whistle!" );
        }
    }    public static class VehicleHandler implements InvocationHandler
    {
        private Object proxied;

        public VehicleHandler(Object proxied )
        {
            this.proxied = proxied;
        }

        public Object invoke(Object proxy, Method method, Object[] args ) throws Throwable
        {
            checkVehicle();
            return meth