我的漫漫程序之旅

专注于JavaWeb开发
随笔 - 39, 文章 - 310, 评论 - 411, 引用 - 0
数据加载中……

我的第一个aspectJ程序

MyClass.java:
package com;

public class MyClass
{
    
public void foo(int age, String name)
    
{
        System.out.println(
"Inside foo(int,String)");
    }


    
public static void main(String[] args)
    
{
        MyClass myClass 
= new MyClass();
        myClass.foo(
1"zdw");
    }


}

HelloWorld.aj:
package com;

public aspect HelloWorld
{
    
//切入点
    pointcut callPointcut() : call(void MyClass.foo(int,String));
    
//前置通知
    before() : callPointcut()
    
{
        System.out.println(
"Hello World");
        System.out.println(
"In the advice attached to the call pointcut");
    }

}
    


posted on 2008-01-10 18:04 々上善若水々 阅读(582) 评论(0)  编辑  收藏 所属分类: Spring


只有注册用户登录后才能发表评论。


网站导航: