package com.ij34.service;
public class Hello
{
public void he()
{
System.out.println("执行Hello的he方法");
}
public int addUser(String name , String pass)
{
System.out.println("执行Hello的addUser方法:" + name);
return 0;
}
}
View Code
package com.ij34.service;
public class Hi
{
public void hihi()
{
System.out.println("执行Hi组件的hihi()方法");
}
}
View Code
package com.ij34.bean;
import com.ij34.service.*;
public class Aspecttest
{
public static void main(String[] args)
{
Hello hello = new Hello();
hello.he();
hello.addUser("尼古拉特斯拉" , "");
Hi hi = new Hi();
hi.hihi();
}
}
View Code
package com.ij34.aspect;
public aspect AuthAspect {
before() : execution(* com.ij34.service .*.*(..)) {
System.out.println("模拟进行权限检查");
}
}
package com.ij34.aspect;
public aspect Logaspect {
pointcut log()
: execution(* com.ij34.service .*.*(..));
after(): log(){
System.out.println("模拟日志记录...");
}
}
package com.ij34.aspect;
public aspect TextAspect {
Object around(): call(* com.ij34.service .*.*(..)){
System.out.println("模拟开始事务... ");
Object o=proceed();
System.out.println("结束模拟事务");
return o;
}
}