當前位置: 首頁>>代碼示例>>Java>>正文


Java AfterReturning類代碼示例

本文整理匯總了Java中org.aspectj.lang.annotation.AfterReturning的典型用法代碼示例。如果您正苦於以下問題:Java AfterReturning類的具體用法?Java AfterReturning怎麽用?Java AfterReturning使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AfterReturning類屬於org.aspectj.lang.annotation包,在下文中一共展示了AfterReturning類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: afterReturn

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
/**
 * @param joinPoint
 */
@AfterReturning("logAnnoAspect()")

public void afterReturn(JoinPoint joinPoint) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    LogModify logModifyAnno = method.getAnnotation(LogModify.class);
    if (null != logModifyAnno) {

        BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
        Log log = new Log();
        log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
        log.setAction(ACTION + logModifyAnno.resource());
        log.setResource(entity.getLogResource());
        log.setResourceId(entity.getId());
        logService.insert(log);
    }
}
 
開發者ID:melonlee,項目名稱:PowerApi,代碼行數:21,代碼來源:LogModifyAdvice.java

示例2: afterReturn

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
/**
 * @param joinPoint
 */
@AfterReturning("logAnnoAspect()")

public void afterReturn(JoinPoint joinPoint) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    LogDelete logDelete = method.getAnnotation(LogDelete.class);
    if (null != logDelete) {
        BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
        Log log = new Log();
        log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
        log.setAction(Constants.LOG_ACTION_DELETE + logDelete.resource());
        log.setResource(entity.getLogResource());
        log.setResourceId(entity.getId());
        logService.insert(log);
    }
}
 
開發者ID:melonlee,項目名稱:PowerApi,代碼行數:20,代碼來源:LogDeleteAdvice.java

示例3: afterReturningServer

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(pointcut = "execution(* cn.org.once.cstack.ServerService.create(..)) "
		+ "|| execution(* cn.org.once.cstack.ServerService.updateType(..))", returning = "result")
public void afterReturningServer(StaticPart staticPart, Object result) throws MonitorException {
	try {
		if (result == null)
			return;
		Server server = (Server) result;
		User user = server.getApplication().getUser();
		Message message = null;
		switch (staticPart.getSignature().getName().toUpperCase()) {
		case createType:
			message = MessageUtils.writeServerMessage(user, server, createType);
			break;
		case updateType:
			message = MessageUtils.writeServerMessage(user, server, updateType);
			break;

		}
		logger.info(message.toString());
		messageService.create(message);

	} catch (ServiceException e) {
		throw new MonitorException("Error afterReturningApplication", e);
	}
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:26,代碼來源:ServerAspect.java

示例4: afterReturningFileExplorer

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning("execution(* cn.org.once.cstack.service.FileService.deleteFilesFromContainer(..))"
		+ " || execution(* cn.org.once.cstack.service.FileService.sendFileToContainer(..))")
public void afterReturningFileExplorer(JoinPoint joinPoint) throws ServiceException {
	Message message = new Message();
	User user = getAuthentificatedUser();
	message.setDate(new Date());
	message.setType(Message.INFO);
	message.setAuthor(user);
	message.setApplicationName((String) joinPoint.getArgs()[0]);

	switch (joinPoint.getSignature().getName().toUpperCase()) {
	case "DELETEFILESFROMCONTAINER":
		message.setEvent(user.getLogin() + " has removed this file : " + joinPoint.getArgs()[2]);
		break;
	}
	this.messageService.create(message);
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:18,代碼來源:FileExplorerAspect.java

示例5: afterReturningDeployment

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(pointcut = "execution(* cn.org.once.cstack.service.DeploymentService.create(..))", returning = "result")
public void afterReturningDeployment(StaticPart staticPart, Object result)
    throws MonitorException {
    try {
        if (result == null)
            return;
        Deployment deployment = (Deployment) result;
        User user = deployment.getApplication().getUser();
        Message message = null;
        switch (staticPart.getSignature().getName().toUpperCase()) {
            case createType:
                message = MessageUtils.writeDeploymentMessage(user, deployment,
                    createType);
                break;
        }

        if (message != null) {
            logger.info(message.toString());
            messageService.create(message);
        }

    } catch (ServiceException e) {
        throw new MonitorException("Error afterReturningApplication", e);

    }
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:27,代碼來源:DeploymentAspect.java

示例6: updateCache

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning ("@annotation(fr.gael.dhus.spring.cache.IncrementCache)")
public void updateCache (JoinPoint joinPoint)
{
   IncrementCache annotation = ((MethodSignature) joinPoint.getSignature ())
         .getMethod ().getAnnotation (IncrementCache.class);

   Cache cache = getCacheManager().getCache(annotation.name());
   if (cache != null)
   {
      synchronized (cache)
      {
         Integer old_value = cache.get (annotation.key (), Integer.class);
         cache.clear ();
         if (old_value == null)
         {
            return;
         }
         cache.put (annotation.key (), (old_value + annotation.value ()));
      }
   }
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:22,代碼來源:CacheAspectDefinition.java

示例7: deleteServiceCallCalls

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
/**
 * 管理員刪除操作日誌(後置通知)
 * 
 */
@AfterReturning(value = "deleteServiceCall()", argNames = "rtv", returning = "rtv")
public void deleteServiceCallCalls(JoinPoint joinPoint, Object rtv)
		throws Throwable {
	// 獲取方法名
	String methodName = joinPoint.getSignature().getName();
	StringBuffer rs = new StringBuffer();
	rs.append(methodName);
	String className = null;
	for (Object info : joinPoint.getArgs()) {
		// 獲取對象類型
		className = info.getClass().getName();
		className = className.substring(className.lastIndexOf(".") + 1);
		rs.append("[參數1,類型:" + className + ",值:(id:"
				+ joinPoint.getArgs()[0] + ")");
	}
	// 創建日誌對象
	LogInfoEntity log = new LogInfoEntity();
	log.setUserId(ShiroAuthenticationManager.getUserId());// 用戶編號
	log.setAccountName(ShiroAuthenticationManager.getUserAccountName());
	log.setCreateTime(new Date(System.currentTimeMillis()));// 操作時間
	log.setContent(rs.toString());// 操作內容
	log.setOperation("delete");// 操作

	logService.log(log);// 添加日誌
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:30,代碼來源:LogAspect.java

示例8: after

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
/**
 * @param data
 * @throws ClassNotFoundException
 * @throws HttpMessageNotWritableException
 * @throws IOException
 */
@AfterReturning(pointcut = "point()", returning = "data")
public void after(JoinPoint jp, Object data) throws Exception {
    MethodInvocationProceedingJoinPoint joinPoint = (MethodInvocationProceedingJoinPoint) jp;
    Class<?> clazz = joinPoint.getSignature().getDeclaringType();
    if (AnnotationUtils.findAnnotation(clazz, FeignClient.class) == null) {
        log.debug("未找到feign 客戶端");
        return;
    }
    CustomSecurityContext securityContext = SecurityContextHystrixRequestVariable.getInstance().get();
    ErrorResult errorResult = null;
    if (securityContext != null && (errorResult = securityContext.getErrorResult()) != null) {
        if (errorResult.getHttpStatus() != HttpStatus.OK.value()) {
            Class<?> exceptionClass = Class.forName(errorResult.getException());
            Constructor<?> constructor = exceptionClass.getConstructor(new Class[]{String.class, String.class});
            throw (CustomException) constructor
                    .newInstance(new Object[]{errorResult.getMessage(), errorResult.getCode()});
        }
    }
    SecurityContextHystrixRequestVariable.getInstance().remove();
}
 
開發者ID:zhaoqilong3031,項目名稱:spring-cloud-samples,代碼行數:27,代碼來源:DefaultFeignExceptionHandlerInterceptor.java

示例9: doAfterReturning

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(returning = "ret", pointcut = "webLog()")
public void doAfterReturning(Object ret) {
    // 處理完請求,返回內容
    WebOosLog commLogger = commLoggerThreadLocal.get();
    commLogger.setActionResCode(ResponseStatus.SUCCESS);
    commLogger.setReqEndTime(new Date());
    commLogger.setReqDealTime((int) (commLogger.getReqEndTime().getTime() - commLogger.getReqStartTime().getTime()));
    commLogger.setResponseData(JSON.toJSONString(ret));
    commLogger.setIsUndefinedException(false);

    loggerRecordService.doRecord(commLogger);

    logger.debug("RESPONSE : " + JSON.toJSONString(ret));
    logger.debug("SPEND TIME : " + commLogger.getReqDealTime() + "ms");
    logger.debug("***************請求" + commLogger.getActionDesc() + "結束***************");
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:17,代碼來源:WebLogAspect.java

示例10: afterCreate

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(pointcut = "execution(* com.digirati.elucidate.repository.AnnotationStoreRepository.createAnnotation(..))", returning = "w3cAnnotation")
public void afterCreate(W3CAnnotation w3cAnnotation) {

    for (RegisteredListener synchronousRegisteredListener : synchronousRegisteredListeners) {
        LOGGER.info(String.format("Notifying synchronous listener [%s] of CREATE on W3CAnnotation [%s]", synchronousRegisteredListener, w3cAnnotation));
        synchronousRegisteredListener.notifyCreate(w3cAnnotation);
        LOGGER.info(String.format("Synchronous listener [%s] has finished processing CREATE on W3CAnnotation [%s]", synchronousRegisteredListener, w3cAnnotation));
    }

    for (RegisteredListener asynchronousRegisteredListener : asynchronousRegisteredListeners) {
        taskExecutor.execute(() -> {
            LOGGER.info(String.format("Notifying asynchronous listener [%s] of CREATE on W3CAnnotation [%s]", asynchronousRegisteredListener, w3cAnnotation));
            asynchronousRegisteredListener.notifyCreate(w3cAnnotation);
            LOGGER.info(String.format("Asynchronous listener [%s] has finished processing CREATE on W3CAnnotation [%s]", asynchronousRegisteredListener, w3cAnnotation));
        });
    }

}
 
開發者ID:dlcs,項目名稱:elucidate-server,代碼行數:19,代碼來源:AnnotationListenerAspect.java

示例11: afterUpdate

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(pointcut = "execution(* com.digirati.elucidate.repository.AnnotationStoreRepository.updateAnnotation(..))", returning = "w3cAnnotation")
public void afterUpdate(W3CAnnotation w3cAnnotation) {

    for (RegisteredListener synchronousRegisteredListener : synchronousRegisteredListeners) {
        LOGGER.info(String.format("Notifying synchronous listener [%s] of UPDATE on W3CAnnotation [%s]", synchronousRegisteredListener, w3cAnnotation));
        synchronousRegisteredListener.notifyUpdate(w3cAnnotation);
        LOGGER.info(String.format("Synchronous listener [%s] has finished processing UPDATE on W3CAnnotation [%s]", synchronousRegisteredListener, w3cAnnotation));
    }

    for (RegisteredListener asynchronousRegisteredListener : asynchronousRegisteredListeners) {
        taskExecutor.execute(() -> {
            LOGGER.info(String.format("Notifying asynchronous listener [%s] of UPDATE on W3CAnnotation [%s]", asynchronousRegisteredListener, w3cAnnotation));
            asynchronousRegisteredListener.notifyUpdate(w3cAnnotation);
            LOGGER.info(String.format("Asynchronous listener [%s] has finished processing UPDATE on W3CAnnotation [%s]", asynchronousRegisteredListener, w3cAnnotation));
        });
    }
}
 
開發者ID:dlcs,項目名稱:elucidate-server,代碼行數:18,代碼來源:AnnotationListenerAspect.java

示例12: afterDelete

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(pointcut = "execution(* com.digirati.elucidate.repository.AnnotationStoreRepository.deleteAnnotation(..))", returning = "w3cAnnotation")
public void afterDelete(W3CAnnotation w3cAnnotation) {

    for (RegisteredListener synchronousRegisteredListener : synchronousRegisteredListeners) {
        LOGGER.info(String.format("Notifying synchronous listener [%s] of DELETE on W3CAnnotation [%s]", synchronousRegisteredListener, w3cAnnotation));
        synchronousRegisteredListener.notifyDelete(w3cAnnotation);
        LOGGER.info(String.format("Synchronous listener [%s] has finished processing DELETE on W3CAnnotation [%s]", synchronousRegisteredListener, w3cAnnotation));
    }

    for (RegisteredListener asynchronousRegisteredListener : asynchronousRegisteredListeners) {
        taskExecutor.execute(() -> {
            LOGGER.info(String.format("Notifying asynchronous listener [%s] of DELETE on W3CAnnotation [%s]", asynchronousRegisteredListener, w3cAnnotation));
            asynchronousRegisteredListener.notifyDelete(w3cAnnotation);
            LOGGER.info(String.format("Asynchronous listener [%s] has finished processing DELETE on W3CAnnotation [%s]", asynchronousRegisteredListener, w3cAnnotation));
        });
    }
}
 
開發者ID:dlcs,項目名稱:elucidate-server,代碼行數:18,代碼來源:AnnotationListenerAspect.java

示例13: updateCache

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning ("@annotation(fr.gael.dhus.spring.cache.IncrementCache)")
public void updateCache (JoinPoint joinPoint)
{
   IncrementCache annotation = ((MethodSignature) joinPoint.getSignature ())
         .getMethod ().getAnnotation (IncrementCache.class);

   Cache cache = cacheManager.getCache (annotation.name ());
   if (cache != null)
   {
      synchronized (cache)
      {
         Integer old_value = cache.get (annotation.key (), Integer.class);
         cache.clear ();
         if (old_value == null)
         {
            return;
         }
         cache.put (annotation.key (), (old_value + annotation.value ()));
      }
   }

}
 
開發者ID:SentinelDataHub,項目名稱:DataHubSystem,代碼行數:23,代碼來源:CacheAspectDefinition.java

示例14: processViewName

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning(pointcut = "execution(* com.poseidon.*.*Controller..*(..)))", returning = "result")
public void processViewName(JoinPoint joinPoint, Object result) {

	final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
	Method method = methodSignature.getMethod();

	ViewName annotation = method.getAnnotation(ViewName.class);
	
	if(annotation == null){
		return;
	}
	
	String errorView = annotation.errorView();
	if(errorView!= null && !errorView.isEmpty()){
		buildModelAndView(result, errorView);
		return;
	}
	
	String name = annotation.name();
	Class<?> returnType = method.getReturnType();
	if(!returnType.isAssignableFrom(ModelAndView.class)){
		throw new ViewNameException("Para usar a annotation @ViewName é preciso que o metodo retorne ModelAndView.");
	}
	buildModelAndView(result, name);
	
}
 
開發者ID:tudoNoob,項目名稱:poseidon,代碼行數:27,代碼來源:ViewNameProcessAdvice.java

示例15: args

import org.aspectj.lang.annotation.AfterReturning; //導入依賴的package包/類
@AfterReturning("execution (* net.jforum.services.ModerationService.moveTopics(..)) && args(toForumId, log, topicIds)")
public void moveTopics(int toForumId, ModerationLog log, int... topicIds) {
	if (!ArrayUtils.isEmpty(topicIds)) {
		this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalPosts#" + toForumId));
		this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalTopics#" + toForumId));
		Cache cache = this.factoryImplementor.getSecondLevelCacheRegion("net.jforum.entities.Forum");

		if (cache != null) {
			cache.remove("net.jforum.entities.Forum#" + toForumId);
		}

		Topic topic = (Topic)this.sessionFactory.getCurrentSession().get(Topic.class, topicIds[0]);
		Forum forum = topic.getForum();

		this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalPosts#" + forum.getId()));
		this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalTopics#" + forum.getId()));

		Cache cache2 = this.factoryImplementor.getSecondLevelCacheRegion("net.jforum.entities.Forum");

		if (cache2 != null) {
			cache2.remove("net.jforum.entities.Forum#" + forum.getId());
		}
	}
}
 
開發者ID:eclipse123,項目名稱:JForum,代碼行數:25,代碼來源:CacheEvictionRules.java


注:本文中的org.aspectj.lang.annotation.AfterReturning類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。