试图设计一个简单的方面,即在任何公共方法实施时,将“logg”字印成ole。
http://www.hchr.org。
@Aspect
public class LoggingAspect {
@Pointcut("execution(public * *(..))")
public void publicServices() {
};
@Before("publicServices()")
public void logg() {
System.out.println("logg");
}
}
http://www.ohchr.org。
<context:component-scan base-package="aspectlogging" />
<aop:aspectj-autoproxy/>
<bean id="loggingAspectHolder" class="aspectlogging.LoggingAspect"/>
<<>strong>simple bean:
package aspectlogging;
@Component
public class TestableBean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
<<>strongtest>:
public class TestLogging {
public static void main(String[] args) {
TestableBean tb = new TestableBean();
tb.setName("yes");
tb.getName();
}
}
I expect,that result of running of TestLogging
will be "logg" word in console,and no output returned.
Do I understand AOP correctly in this case?