java aspect调用,在Spring 中使用@Aspect 控制自定义注解的操作

  • Post author:
  • Post category:java


spring 中使用@aspect 控制自定义注解

1.定义系统日志注解类

@target(elementtype.method)

@retention(retentionpolicy.runtime)

@documented

public @interface syslog {

string value() default “”;

}

2.定义切面处理类

package com.kxs.common.aspect;

import com.google.gson.gson;

import com.kxs.common.annotation.syslog;

import com.kxs.common.utils.httpcontextutils;

import com.kxs.common.utils.iputils;

import com.kxs.modules.sys.entity.syslogentity;

import com.kxs.modules.sys.entity.sysuserentity;

import com.kxs.modules.sys.service.syslogservice;

import org.apache.shiro.securityutils;

import org.aspectj.lang.proceedingjoinpoint;

import org.aspectj.lang.annotation.around;

import org.aspectj.lang.annotation.aspect;

import org.aspectj.lang.annotation.pointcut;

impor