DefaultAdvisorAutoProxyCreator这个类功能更为强大,这个类的奇妙之处是他实现了BeanProcessor接口,当ApplicationContext读如所有的Bean配置信息后,这个类将扫描上下文,寻找所有的Advistor(一个Advisor是一个切入点和一个通知的组成),将这些Advisor应用到所有符合切入点的Bean中
业务接口:
package
StaticAdvisorTest;
public interface Shopping ... {
public String buySomething(String type);
public String buyAnything(String type);
public String sellSomething(String type);
public String sellAnything(String type);
}
public interface Shopping ... {
public String buySomething(String type);
public String buyAnything(String type);
public String sellSomething(String type);
public String sellAnything(String type);
}
业务实现类:
package
AutoProxyTwo;
public class ShoppingImplA implements Shopping ... {
private Customer customer;
public Customer getCustomer() ...{
return customer;
}
public void setCustomer(Customer customer) ...{
this.customer = customer;
}
public String buySomething(String type) ...{
System.out.println(this.getCustomer().getName()+" bye "+type+" success");
return null;
}
public String buyAnything(String type) ...{
System.out.println(this.getCustomer().getName()+" bye "+type+" success");
return null;
}
public String sellAnything(String type)
public class ShoppingImplA implements Shopping ... {
private Customer customer;
public Customer getCustomer() ...{
return customer;
}
public void setCustomer(Customer customer) ...{
this.customer = customer;
}
public String buySomething(String type) ...{
System.out.println(this.getCustomer().getName()+" bye "+type+" success");
return null;
}
public String buyAnything(String type) ...{
System.out.println(this.getCustomer().getName()+" bye "+type+" success");
return null;
}
public String sellAnything(String type)