My code is as follows:
spring.xml
<bean id="logInterceptor" class="apptools.jira.interceptor.LogInterceptor"></bean> <aop:config proxy-target-class="true"> <aop:aspect ref="logInterceptor"> <aop:pointcut id="logAspect" expression="execution(* apptools.jira.dao.impl.*(..))"/> <aop:around method="around" pointcut-ref="logAspect" /> </aop:aspect> </aop:config>
atlassian-plugin.xml
<plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> <param name="plugin-icon">images/pluginIcon.png</param> <param name="plugin-logo">images/pluginLogo.png</param> <param name="emailFormat">html</param> <bundle-instructions> <Import-Package>org.aspectj*;version="1.6.1",*</Import-Package> </bundle-instructions> </plugin-info>
pom.xml
<dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.1</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.1</version> </dependency>
LogInterceptor
package apptools.jira.interceptor; import org.apache.log4j.Logger; import org.aspectj.lang.ProceedingJoinPoint; /** * * @author yf.wu * */ public class LogInterceptor { static Logger logger = Logger.getLogger(LogInterceptor.class); public Object around(ProceedingJoinPoint joinPoint) throws Throwable { StringBuffer sb = new StringBuffer(); try { System.out.println(joinPoint.getSignature().getName() + " Start---------------------------------------"); logger.info(joinPoint.getSignature().getName() + " Dao Start---------------------------------------"); Object result = joinPoint.proceed(); System.out.println(joinPoint.getSignature().getName() + " Dao End---------------------------------------"); logger.info(joinPoint.getSignature().getName() + " Dao End---------------------------------------"); return result; } catch (Exception e) { sb.append("Method start:" + joinPoint.getTarget().getClass() + "." + joinPoint.getSignature().getName() + "() "); sb.append("Error info:[" + e.getMessage() + "]"); logger.error(sb.toString()); } return "error"; } } when jira server start, no error occurs, but logInterceptor did not work. Thanks in advance.
Community moderators have prevented the ability to post new answers.
Hello everyone,
Does anyone have solution for this?
Thanks,
A.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @yunfeng wu
do you solve your problems? I try to work with aop within my JIRA plugin too. I have the problem, that my aspect bean can't be created cause:
Error creating bean with name 'myInterceptor' defined in URL [bundle://171.0:0/META-INF/spring/Sprint-Customer.xml]:
java.lang.NoClassDefFoundError: org/aspectj/lang/reflect/AjTypeSystem
Is it working for you? Thanks in advanced.
Tobias
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, did you solve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.