Refine search
@Before("execution(* *..rpc..*.*(..))") public void doBeforeInServiceLayer(JoinPoint joinPoint) { LOGGER.debug("doBeforeInServiceLayer"); startTime = System.currentTimeMillis(); }
@Before("webLog()") public void doBefore(JoinPoint joinPoint) { // 接收到请求,记录请求内容 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); // 记录下请求内容 LOGGER.info("URL : " + request.getRequestURL().toString() + ",IP : " + request.getRemoteAddr() + ",CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName() + ",ARGS : " + Arrays.toString(joinPoint.getArgs())); }
@Before("this(org.mp4parser.support.AbstractBox) && ((execution(public * * (..)) && !( " + "execution(* parseDetails()) || " + "execution(* getNumOfBytesToFirstChild()) || " + "execution(* getType()) || " + "execution(* isParsed()) || " + "execution(* getHeader(*)) || " + "execution(* parse()) || " + "execution(* getBox(*)) || " + "execution(* getSize()) || " + "execution(* getOffset()) || " + "execution(* setOffset(*)) || " + "execution(* parseDetails()) || " + "execution(* _parseDetails(*)) || " + "execution(* parse(*,*,*,*)) || " + "execution(* getIsoFile()) || " + "execution(* getParent()) || " + "execution(* setParent(*)) || " + "execution(* getUserType()) || " + "execution(* setUserType(*))) && " + "!@annotation(org.mp4parser.support.DoNotParseDetail)) || @annotation(org.mp4parser.support.ParseDetail))") public void before(JoinPoint joinPoint) { if (joinPoint.getTarget() instanceof AbstractBox) { if (!((AbstractBox) joinPoint.getTarget()).isParsed()) { //System.err.println(String.format("parsed detail %s", joinPoint.getTarget().getClass().getSimpleName())); ((AbstractBox) joinPoint.getTarget()).parseDetails(); } } else { throw new RuntimeException("Only methods in subclasses of " + AbstractBox.class.getName() + " can be annotated with ParseDetail"); } }
/** * 前置通知:在连接点执行前的通知,但不能阻止连接点前的执行(除非它抛出一个异常) */ // 引用多个切入点 // @Before("log6() OR log7()") // 引用单个切入点 @Before("logaa1()") public void beforeAdvice(JoinPoint point) { logger.info("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS"); logger.info("LoggerHandlerAop.beforeAdvice...time:" + DateUtil.now()); Signature signature = point.getSignature(); logger.info("所属类名称:" + signature.getDeclaringTypeName() + "\n代理类:" + signature.getClass() + "\n方法名称:" + signature.getName() + "\n所属类:" + signature.getDeclaringType()); Object[] args = point.getArgs(); logger.info("参数是:" + JSON.toJSONString(args)); logger.info("被织入的对象是:" + point.getTarget()); logger.info("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); }
@Before("call(* java.io.OutputStream.write(..))") public void write(JoinPoint thisJoinPoint) { OutputStream out = (OutputStream) thisJoinPoint.getTarget(); if (config.isDebug()) { config.logger.finest( thisJoinPoint.toString() + " with " + FileTools.dumpChain(out)); } latency(HIGH, thisJoinPoint, (OutputStream) thisJoinPoint.getTarget()); }
@Before(value="execution(void set*(*)) && this(modifiable) && args(newValue)", argNames="modifiable,newValue") public void recordModificationIfSetterArgumentDiffersFromOldValue( JoinPoint jp, MutableModifiable mixin, Object newValue) { Method correspondingGetter = getGetterFromSetter(((MethodSignature) jp.getSignature()).getMethod()); boolean modified = true; if (correspondingGetter != null) { try { Object oldValue = correspondingGetter.invoke(jp.getTarget());
@Before("execution(void *.additionalMethod(*))") public void log(JoinPoint jp) { System.out.println("Before " + jp.getSignature().getName()); } }
@Before("logPointCut()") public void doBefore(JoinPoint joinPoint) throws Throwable { // 接收到请求,记录请求内容 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); // 记录下请求内容 loggger.info("请求地址 : " + request.getRequestURL().toString()); loggger.info("HTTP METHOD : " + request.getMethod()); loggger.info("IP : " + request.getRemoteAddr()); loggger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName()); loggger.info("参数 : " + Arrays.toString(joinPoint.getArgs())); // loggger.info("参数 : " + joinPoint.getArgs()); }
@Before(EXECUTION_SEARCH) public void beforeFindBy(JoinPoint joinPoint) throws Throwable { try { Object target = joinPoint.getTarget(); if (!WebElement.class.isAssignableFrom(target.getClass())) { listener.beforeFindBy(castArgument(joinPoint, 0), null, driver); } else { listener.beforeFindBy(castArgument(joinPoint, 0), castTarget(joinPoint), driver); } } catch (Throwable t) { throw getRootCause(t); } }
@Before("call(* java.io.Reader+.read(..))") public void read(JoinPoint thisJoinPoint) { if (config.isDebug()) { Reader reader = (Reader) thisJoinPoint.getTarget(); config.logger.finest( thisJoinPoint.toString() + " with " + FileTools.dumpChain(reader)); } latency(HIGH, thisJoinPoint, (Reader) thisJoinPoint.getTarget()); }
@Before("pointcut()") public void doBefore(JoinPoint point) throws NoSuchMethodException { //获取拦截的方法名 Signature sig = point.getSignature(); MethodSignature msig = null; if (!(sig instanceof MethodSignature)) { LOGGER.error("该注解只能用于方法"); throw new IllegalArgumentException("该注解只能用于方法"); } msig = (MethodSignature) sig; Object target = point.getTarget(); //获取拦截方法的参数 Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); //获取操作业务的名称 BusinessLogAnnotation annotation = currentMethod.getAnnotation(BusinessLogAnnotation.class); String bussinessName = annotation.value(); LOGGER.info("进入{}方法...", bussinessName); } }
@Before("@annotation(com.entdiy.core.dao.router.RoutingDataSource)") private void routingAdvice(JoinPoint point) { MethodSignature methodSignature = (MethodSignature) point.getSignature(); RoutingDataSource datasource = methodSignature.getMethod().getAnnotation(RoutingDataSource.class); String customerType = datasource.value(); logger.debug(" Routing to Datasource: {}", customerType); datasourceHolder.set(customerType); }
@Before("execution(* *..controller..*.*(..))") public void doBeforeInServiceLayer(JoinPoint joinPoint) { LOGGER.debug("doBeforeInServiceLayer"); startTime = System.currentTimeMillis(); }
@Before("webLog()") public void doBefore(JoinPoint joinPoint){ startTime.set(System.currentTimeMillis()); //接收到请求,记录请求内容 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); HttpSession session = request.getSession(); // 记录下请求内容 LOGGER.info("URL : " + request.getRequestURL().toString()); LOGGER.info("HTTP_METHOD : " + request.getMethod()); LOGGER.info("IP : " + request.getRemoteAddr()); LOGGER.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName()); LOGGER.info("ARGS : " + Arrays.toString(joinPoint.getArgs())); }