当前位置: 首页>>代码示例>>Java>>正文


Java AfterThrowing类代码示例

本文整理汇总了Java中org.aspectj.lang.annotation.AfterThrowing的典型用法代码示例。如果您正苦于以下问题:Java AfterThrowing类的具体用法?Java AfterThrowing怎么用?Java AfterThrowing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AfterThrowing类属于org.aspectj.lang.annotation包,在下文中一共展示了AfterThrowing类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
/**
 * Advice that logs methods throwing exceptions.
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles("dev")) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'",
            joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(),
            e.getCause() != null ? e.getCause() : "NULL", e.getMessage(),
            e
        );

    } else {
        log.error("Exception in {}.{}() with cause = {}",
            joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(),
            e.getCause() != null ? e.getCause() : "NULL"
        );
    }
}
 
开发者ID:Cinderpup,项目名称:RoboInsta,代码行数:22,代码来源:LoggingAspect.java

示例2: execution

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(pointcut = "execution(* cn.org.once.cstack.service.ModuleService.remove(..)) " +
    "|| execution(* cn.org.once.cstack.service.ModuleService.initModule(..))",
    throwing = "e")
public void afterThrowingModule(StaticPart staticPart,
                                Exception e)
    throws ServiceException {
    User user = this.getAuthentificatedUser();
    Message message = null;
    logger.debug("CALLED CLASS : " + staticPart.getSignature().getName());
    switch (staticPart.getSignature().getName().toUpperCase()) {
        case initModule:
            message = MessageUtils.writeAfterThrowingModuleMessage(e, user,
                initModule);
            break;
        case deleteType:
            message = MessageUtils.writeAfterThrowingModuleMessage(e, user,
                deleteType);
            break;
    }
    if (message != null) {
        messageService.create(message);
    }
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:24,代码来源:ModuleAspect.java

示例3: afterThrowingLoggable

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(value = "execution(@org.smartlog.aop.Loggable * *(..))", throwing = "t")
public void afterThrowingLoggable(final JoinPoint joinPoint, final Throwable t) throws Throwable {
    final LogContext ctx = SmartLog.throwable(t);

    if (ctx.level() == null) {
        // use ERROR level by default when got uncaught exception
        ctx.level(LogLevel.ERROR);
    }

    final Object result = ctx.result();
    if (result == null) {
        ctx.result(t.toString());
    } else {
        ctx.result(result.toString() + "; " + t.toString());
    }

    finish(joinPoint, ctx);
}
 
开发者ID:ivnik,项目名称:smartlog,代码行数:19,代码来源:LogAspect.java

示例4: doAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(throwing = "ex", pointcut = "webLog()")
public void doAfterThrowing(Throwable ex) {
    //有异常
    WebOosLog commLogger = commLoggerThreadLocal.get();
    if (ex instanceof BusinessException) {
        commLogger.setActionResCode(ResponseStatus.BUSINESS_FAILED);
    } else if (ex instanceof ValidateException) {
        commLogger.setActionResCode(ResponseStatus.VALIDATE_ERR);
    } else if (ex instanceof LoginTimeoutException) {
        commLogger.setActionResCode(ResponseStatus.LOGIN_TIME_OUT);
    } else if (ex instanceof NoPrivilegeException) {
        commLogger.setActionResCode(ResponseStatus.NO_PRIVILEGE);
    } else {
        commLogger.setActionResCode(ResponseStatus.SYSTEM_ERR);
    }
    commLogger.setReqEndTime(new Date());
    commLogger.setReqDealTime((int) (commLogger.getReqEndTime().getTime() - commLogger.getReqStartTime().getTime()));
    commLogger.setIsUndefinedException(true);
    commLogger.setExcepStackInfo(ExceptionUtil.parseException(ex));

    loggerRecordService.doRecord(commLogger);

    logger.debug("EXCEPTION : " + ExceptionUtil.parseException(ex));
    logger.debug("SPEND TIME : " + commLogger.getReqDealTime() + "ms");
    logger.debug("***************请求" + commLogger.getActionDesc() + "结束***************");
}
 
开发者ID:DomKing,项目名称:springbootWeb,代码行数:27,代码来源:WebLogAspect.java

示例5: doException

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(pointcut = "controllerAspect()", throwing = "exception")
    public void doException(JoinPoint joinPoint, Exception exception) {
    	HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
		// 读取session中的用户
//		User user = SessionUtils.getUserFromSession(request);
		
//		if(null == user){
//			logger.info("未登录日志不记录");
//			return;
//		}
		
		try {
			Object[] args = getLogMethodDescription(joinPoint);

			// *========数据库日志=========*//
//			logService.saveLog(user.getId(), user.getAccount(), LogType.EXCEPTION_LOG,
//					IpUtils.getIpAddr(request), args[0].toString() + "-->" + exception.getMessage(),
//					user.getManufacturerId(), reqDescription(request));

		} catch (Exception e) {
			// 记录本地异常日志
			logger.error(e);
			e.printStackTrace();
		}  
    }
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:26,代码来源:SystemLogAspect.java

示例6: LogToDB

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(throwing = "ex", pointcut = "execution(* com.github.izhangzhihao.SSMSeedProject.*.*.*(..)))")
public void LogToDB(JoinPoint joinPoint, Throwable ex) {
    //出错行
    int lineNumber = ex.getStackTrace()[0].getLineNumber();
    //方法签名
    Signature signature = joinPoint.getSignature();
    //参数
    Object[] args = joinPoint.getArgs();
    //拼接参数
    StringBuilder argString = new StringBuilder();
    if (args.length > 0)
        for (Object arg : args)
            argString.append(arg);
    ex.printStackTrace();
    log.error("方法" + signature, "参数" + argString, "错误行:" + lineNumber, "时间" + new Date(), "异常内容" + ex.toString());
}
 
开发者ID:izhangzhihao,项目名称:SSMSeedProject,代码行数:17,代码来源:LogAspect.java

示例7: afterThrowingAdvice

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
/**
	 * After throwing advice.
	 *
	 * @param joinPoint the join point
	 * @param error the error
	 */
	@AfterThrowing(pointcut = "selectAll()", throwing = "error")
	public void afterThrowingAdvice(JoinPoint joinPoint, Throwable error) {
		if (isAlreadySysPointCut(error)) {
			return;
		}
		setAlreadySysPointCut(error);
		if (error instanceof TestDataException) {
			ITestResult itr = Reporter.getCurrentTestResult();
			itr.setThrowable(error);
		}
//		String[] fullST = Utils.stackTrace(error, false);
//		LogbackWriter.writeSysError(joinPoint.getTarget().toString()+ error.hashCode()  + fullST[1] );
		Class<?> cls = joinPoint.getTarget().getClass();
		if (null == cls) throw GlobalUtils.createInternalError("jvm");
		LogbackWriter.writeSysError(cls,  error);
		
	}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:24,代码来源:SystemLogger.java

示例8: ExceptionLog

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
/**
 * 出现异常自动记录日志
 * @param ex 异常
 */
@AfterThrowing(pointcut="methods()",
	    throwing="ex")
public void ExceptionLog(Exception ex) {
	LoginInfo loginUser = UserContextHolder.getUser();
	//保证用户已经登陆后并通过菜单访问功能时才记录操作时间
	if (loginUser != null ) {
		Log log = new Log();
		log.setDf("0");
		log.setIp(loginUser.getIp());
		log.setPermission(loginUser.getPermission());
		log.setTs(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		log.setType("APP_LOG001");
		log.setUsername(loginUser.getUserName());
		logManager.save(log);
	}
}
 
开发者ID:545473750,项目名称:zswxsqxt,代码行数:21,代码来源:AfterThrowingUtil.java

示例9: auditAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(
        pointcut = "execution(* (@javax.jws.WebService *).*(..))",
        throwing = "throwable")
public void auditAfterThrowing(JoinPoint joinPoint, Throwable throwable) throws Throwable {
  String id = getId();
  Class targetClass = joinPoint.getTarget().getClass();
  String methodName = joinPoint.getSignature().getName();
  Object[] args = joinPoint.getArgs();

  LOG.info("[" + id + "] After exception: " + targetClass.getName() + "." + methodName + " with " + args.length + " params");

  AuditEntity ae = AuditEntity.getInstance(
          new Timestamp(new Date().getTime()).toString(),
          methodName,
          objectsToString(args),
          throwable != null ? throwable.toString() : null,
          STATE_EXCEPTION
  );

  LOG.info("[" + id + "] Exception: " + ae);
}
 
开发者ID:stockholmuniversity,项目名称:cxf-server,代码行数:22,代码来源:AuditAspect.java

示例10: springBeanPointcut

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:18,代码来源:LoggingAspect.java

示例11: logAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
/**
 * Advice that logs methods throwing exceptions.
 *
 * @param joinPoint join point for advice
 * @param e exception
 */
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);

    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
    }
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:18,代码来源:LoggingAspect.java

示例12: doAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
/**
 * @param joinPoint
 * @param e
 */
@AfterThrowing(value = "doAfterThrowing()", throwing = "e")
public void doAfterThrowing(JoinPoint joinPoint, Throwable e) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("className", joinPoint.getTarget().getClass().getName());
    map.put("methodName", method.getName());
    map.put("args", JSONUtils.toJSONString(joinPoint.getArgs().toString()));
    map.put("errorMsg", e.getMessage());
    logger.error(JSONUtils.toJSONString(map));
}
 
开发者ID:melonlee,项目名称:LazyREST,代码行数:17,代码来源:ExceptionLogAspect.java

示例13: logAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(pointcut = "loggingPointcut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
    if (env.acceptsProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)) {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause(), e);
    } else {
        log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
            joinPoint.getSignature().getName(), e.getCause());
    }
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:11,代码来源:LoggingAspect.java

示例14: afterThrowingServer

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(pointcut = "execution(* cn.org.once.cstack.ServerService.updateType(..))", throwing = "e")
public void afterThrowingServer(StaticPart staticPart, Exception e) throws ServiceException {
	User user = this.getAuthentificatedUser();
	Message message = null;
	logger.debug("CALLED CLASS : " + staticPart.getSignature().getName());
	switch (staticPart.getSignature().getName().toUpperCase()) {
	case updateType:
		message = MessageUtils.writeAfterThrowingModuleMessage(e, user, updateType);
		break;
	}
	if (message != null) {
		messageService.create(message);
	}
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:15,代码来源:ServerAspect.java

示例15: logAfterThrowing

import org.aspectj.lang.annotation.AfterThrowing; //导入依赖的package包/类
@AfterThrowing(pointcut = "execution(* cn.org.once.cstack.service.*.*(..))",
        throwing= "error")
public void logAfterThrowing(Throwable error) {
    if(error.getMessage() != null && error.getMessage()
            .contains("org.hibernate.exception.JDBCConnectionException: could not extract ResultSet")) {
        publisher.publishEvent(new DatabaseConnectionFailEvent("Database connection has been lost"));
    }
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:9,代码来源:ErrorHandlerAspect.java


注:本文中的org.aspectj.lang.annotation.AfterThrowing类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。