thomaschen2046

firegod2005 2013-09-23 09:17:50
bean.xml
<!-- spring关于AOP面向切面编程的配置 -->
<bean id="logInterceptor" class="thomas.aop.LogInterceptor"></bean>
<aop:config>
<aop:pointcut id="bussinessService" expression="execution(public * thomas.service.*.*(..))"/>
<aop:aspect id="logAspect" ref="logInterceptor">
<!-- <aop:before method="before" pointcut-ref="bussinessService"/> -->
<aop:around method="aroundMethod" pointcut-ref="bussinessService"/>
</aop:aspect>
</aop:config>

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import thomas.log.Logger;

//@Aspect
//@Component
public class LogInterceptor {
//@Pointcut("execution(public * com.bjsxt.service..*.add(..))")
public void myMethod(){};

//@Before("myMethod()")
public void before() {
System.out.println("method before");
}

//@Around("myMethod()")
public Object aroundMethod(ProceedingJoinPoint pjp) throws Throwable {
Logger.info("oooOO Class: " + pjp.getTarget() + " | method: " + pjp.getSignature().getName() + " Start");
Object obj = pjp.proceed();
Logger.info("oooOO Class: " + pjp.getTarget() + " | method: " + pjp.getSignature().getName() + " End");
return obj;
}

}
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:beans.xml</param-value>
</context-param>
...全文
79 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
firegod2005 2013-09-25
  • 打赏
  • 举报
回复
Subversive: http://download.eclipse.org/technology/subversive/1.1/update-site/ m2eSubversive: http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-subversive/0.13.0/N/0.13.0.201302121311/

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧