List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:com.samples.platform.util.ServiceExecutionLogAspect.java
License:Open Source License
/** * Aspect around the execution of the services. * * @param joinPoint/* ww w. j a v a 2 s. com*/ * The {@link ProceedingJoinPoint}. * @return the result of the service execution. * @throws Throwable */ @Around(value = "execution(* com.qpark.eip.service.*.*(..)) || execution(* com.samples.platform.service.*.*(..)) ") public Object invokeAspect(final ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); String signatureName = this.getSignatureName(joinPoint); this.logger.debug("+{}", signatureName); Object result = null; try { result = joinPoint.proceed(); } catch (Throwable t) { this.logger.debug(" {} failed with {}: {}", signatureName, t.getClass().getSimpleName(), t.getMessage()); throw t; } finally { this.logger.debug("-{} {}", signatureName, getDuration(System.currentTimeMillis() - start)); } return result; }
From source file:com.sastix.cms.common.services.aop.MethodMonitor.java
License:Apache License
@Around("execution(* com.sastix..services..*.*(..))") public Object logServiceAccess(ProceedingJoinPoint joinPoint) throws Throwable { if (!LOG.isDebugEnabled()) { return joinPoint.proceed(); // if not on DEBUG, no point in writing anything }//from www .j av a2s . c o m String name = joinPoint.getSignature().getName(); LOG.debug("==> {}({})", name, argsAsStrings(joinPoint.getArgs())); try { Object obj = joinPoint.proceed(); //continue on the intercepted method LOG.debug("<== {}(...) = {}", name, argsAsStrings(obj)); return obj; } catch (Throwable t) { LOG.error("<==! {}(...) => EXCEPTION {}", new Object[] { name, t.getMessage() }); if (t.getCause() != null) { LOG.error("<==! caused by: {} - message: {}", t.getCause(), t.getCause().getMessage()); } LOG.error("<==! exception log: ", t); throw t; } }
From source file:com.sccl.attech.common.advice.CustomJsonFilterAdvice.java
License:Open Source License
/** * Do around./*from ww w . java 2 s. c o m*/ * * @param pjp the pjp * @return the object * @throws Throwable the throwable */ @Around("execution(* com.sccl.attech.modules.template.web.*.*(..))") public Object doAround(ProceedingJoinPoint pjp) throws Throwable { MethodSignature msig = (MethodSignature) pjp.getSignature(); HttpServletResponse response = getResponse(pjp.getArgs()); CustomJsonFilter annotation = msig.getMethod().getAnnotation(CustomJsonFilter.class); CustomJsonFilters annotations = msig.getMethod().getAnnotation(CustomJsonFilters.class); if ((annotation == null && annotations == null) || null == response) { return pjp.proceed(); } JsonMapper mapper = new JsonMapper(); if (annotation != null) { Class<?> mixin = annotation.mixin(); Class<?> target = annotation.target(); if (target != null) { mapper.addMixInAnnotations(target, mixin); } else { mapper.addMixInAnnotations(msig.getMethod().getReturnType(), mixin); } } if (annotations != null) { CustomJsonFilter[] filters = annotations.filters(); for (CustomJsonFilter filter : filters) { Class<?> mixin = filter.mixin(); Class<?> target = filter.target(); if (target != null) { mapper.addMixInAnnotations(target, mixin); } else { mapper.addMixInAnnotations(msig.getMethod().getReturnType(), mixin); } } } try { // response.setCharacterEncoding("UTF-8"); mapper.writeValue(response.getOutputStream(), pjp.proceed()); return null; } catch (Exception ex) { throw new RuntimeException(ex); } // return null; }
From source file:com.shigengyu.hyperion.logging.services.WorkflowExecutionServiceLoggingAspect.java
License:Apache License
@Around("execution(* com.shigengyu.hyperion.services.WorkflowExecutionService.execute(..))") public TransitionExecutionResult aroundExecute(ProceedingJoinPoint joinPoint) { try {// w w w.j a va 2 s .co m WorkflowInstance workflowInstance = (WorkflowInstance) joinPoint.getArgs()[0]; Object transition = joinPoint.getArgs()[1]; LOGGER.debug("Before executing transition [{}] on workflow instance [{}]", transition, workflowInstance); TransitionExecutionResult result = (TransitionExecutionResult) joinPoint.proceed(); LOGGER.debug("After executing transition [{}] on workflow instance [{}]", transition, workflowInstance); return result; } catch (WorkflowExecutionException e) { LOGGER.error(ExceptionUtils.getFullStackTrace(e)); throw e; } catch (Throwable e) { LOGGER.error(ExceptionUtils.getFullStackTrace(e)); throw new RuntimeException("Unexcepted exception type caught when executing workflow transition.", e); } }
From source file:com.si.xe.trader.infra.util.ProfilingAspect.java
License:Apache License
@Around("methodsToBeProfiled()") public Object profile(ProceedingJoinPoint pjp) throws Throwable { StopWatch sw = new StopWatch(getClass().getSimpleName()); try {/*from www . j a va2 s . co m*/ sw.start(pjp.getSignature().getName()); return pjp.proceed(); } finally { sw.stop(); System.out.println(sw.getLastTaskName() + sw.shortSummary()); } }
From source file:com.skplanet.tcloud.common.OmcLogAdvice.java
License:Open Source License
/** * <pre>/*from w ww. jav a 2s .c o m*/ * ? ?? ?? ? . * </pre> * @param joinPoint AOP ? ?(logging,exception,etc...) ? ? ? * @return {@link Object} * @throws Throwable */ public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable { long startTime = System.currentTimeMillis(); // String startTimeStr = ""; // Map<String, Object> inResutlMap = new HashMap<String, Object>(); // Map<String, Object> outResutlMap = new HashMap<String, Object>(); // Map<String, Object> etcResutlMap = new HashMap<String, Object>(); // StopWatch stopWatch = new StopWatch(); // ? Signature signature = joinPoint.getSignature(); // String targetClassName = joinPoint.getTarget().getClass().getName(); // Class Name Object returnObj = null; // String hostAddress = ""; HttpServletRequest request = null; String key1 = ""; try { // Service ? - ETC SimpleDateFormat sdfYMDHMS = new SimpleDateFormat("yyyyMMddHHmmss"); startTimeStr = sdfYMDHMS.format(new Date(startTime)); etcResutlMap.put("serviceName", OmcLogAdvice.JobConstants.SERVICE_NAME); etcResutlMap.put("startTimeStr", startTimeStr); // etcResutlMap.put("hostName", hostName+" / "+hostAddress); etcResutlMap.put("hostName", localHostName); etcResutlMap.put("direction", OmcLogAdvice.JobConstants.DIRECTION_REP); // Service inResutlMap = getMakeIn(targetClassName, signature.getName(), joinPoint.getArgs(), request); stopWatch.start(joinPoint.toShortString()); // ? // Access ? IP? ? . // if (isAccessIp(inResutlMap.get("sysModule"), inResutlMap.get("clientIp"))) { if (true) { returnObj = joinPoint.proceed(); // Service ? if (stopWatch.isRunning()) { stopWatch.stop(); // ? } // Service outResutlMap = getMakeOut(returnObj, inResutlMap); outResutlMap.put("totalTimeSeconds", stopWatch.getTotalTimeMillis()); // if (inResutlMap.get("requestUrl").toString().contains("regMemberTOI") || // sjsim@20120920 inResutlMap.get("requestUrl").toString().contains("regIdpMemberTOI") || inResutlMap.get("requestUrl").toString().contains("modifyMemberIdTOI") || inResutlMap.get("requestUrl").toString().contains("ssoLoginTOI") || inResutlMap.get("signatureName").toString().contains("getSendEmail")) { // sjsim@20130207 String keyStr = inResutlMap.get("key1").toString(); if (JobConstants.SERVICE_RESULT_CODE_SUCC.equals(outResutlMap.get("resultCode"))) { if (keyStr.length() >= 5) { if (!keyStr.subSequence(0, 5).equals("memNo")) { ModelAndView mav = (ModelAndView) returnObj; String memNo = mav.getModel().get("memNo").toString(); inResutlMap.put("key1", "memNo=" + memNo); } } } else { if (keyStr.length() >= 7) { if (!keyStr.subSequence(0, 7).equals("loginId")) { ModelAndView mav = (ModelAndView) returnObj; String loginId = mav.getModel().get("loginId").toString(); inResutlMap.put("key1", "loginId=" + loginId); } } } } else if (JobConstants.SERVICE_SYS_NAME_REQUEST.equals(inResutlMap.get("signatureName"))) { if (JobConstants.SERVICE_RESULT_CODE_SUCC.equals(outResutlMap.get("resultCode"))) { if (!inResutlMap.get("key1").toString().subSequence(0, 5).equals("memNo")) { ModelAndView mav = (ModelAndView) returnObj; String memNo = mav.getModel().get("memNo").toString(); key1 = "memNo=" + memNo; inResutlMap.put("key1", key1); } } else { if (!inResutlMap.get("key1").toString().subSequence(0, 7).equals("loginId")) { ModelAndView mav = (ModelAndView) returnObj; String loginId = mav.getModel().get("loginId").toString(); key1 = "loginId=" + loginId; inResutlMap.put("key1", key1); } } // ? ? ? KEY1 ? sjsim@20130104 // ? ? , ? Key1 ? ? 2013.01.22. jhkwon } else if ("joinMdn".equals(signature.getName()) || "loginMdn".equals(signature.getName()) || "secedeMdn".equals(signature.getName())) { ModelAndView mav = (ModelAndView) returnObj; String memNo = mav.getModel().get("memNo").toString(); key1 = "memNo=" + memNo; inResutlMap.put("key1", key1); } else if ("loginMdnEx".equals(signature.getName())) { ModelAndView mav = (ModelAndView) returnObj; String memNo = mav.getModel().get("memNo").toString(); key1 = "memNo=" + memNo; inResutlMap.put("key1", key1); String userMdn = "userMdn=" + StringUtils.defaultString(mav.getModel().get("userMdn").toString()); String etc = userMdn; inResutlMap.put("etc", etc); } else if ("getSmsKey".equals(signature.getName()) || "getSmsKeyTOI".equals(signature.getName())) { ModelAndView mav = (ModelAndView) returnObj; String gubun = ","; String mdn = key1 + gubun + "mdn=" + StringUtils.defaultString(mav.getModel().get("mdn").toString()); String userMdnType = "userMdnType=" + StringUtils.defaultString(mav.getModel().get("userMdnType").toString()); //String smsAuthKey = "smsAuthKey="+StringUtils.defaultString(mav.getModel().get("smsAuthKey").toString()); //String etc=mdn+gubun+userMdnType+gubun+smsAuthKey; String etc = mdn + gubun + userMdnType + gubun; inResutlMap.put("etc", etc); } else if (inResutlMap.get("signatureName").toString().contains("startup")) { // dikey@20130220 for (Object object : joinPoint.getArgs()) { if (object instanceof HttpServletRequest) { request = (HttpServletRequest) object; } } // key1? ? ?? key2? T store? ? mdn if (request != null) { String etc = (String) inResutlMap.get("etc"); String deviceId = request.getParameter("deviceId") == null ? "" : request.getParameter("deviceId"); etc = etc + "|deviceId=" + deviceId; String userAgent = null; userAgent = request.getHeader("user-agent"); if (userAgent != null && !userAgent.trim().isEmpty()) { if (userAgent.contains("T store")) { etc = etc + new StringBuffer("|mdn=").append( request.getParameter("mdn") == null ? "" : request.getParameter("mdn")) .toString(); } } /* * Tstore -Tcloud? * - T store? T cloud? ? ?? T cloud ? UV - * startup.do ? etc? tctd-src? ?? append * 2013-11-26 jung-su.jang */ ModelAndView mav = (ModelAndView) returnObj; if (mav != null && mav.getModel() != null && mav.getModel().get("tcdSrc") != null) { String tcdSrc = mav.getModel().get("tcdSrc").toString(); etc += tcdSrc != null ? "|tcd-src=" + tcdSrc : ""; } String referer = request.getParameter("referer") == null ? "" : request.getParameter("referer"); etc = etc + "|referer=" + referer; String pushId = request.getParameter("pushId"); if (pushId != null && !"".equals(pushId)) { etc = etc + "|pushId=" + pushId; } inResutlMap.put("etc", etc); } } else if ("deviceToDevice".equals(signature.getName())) { // sjsim@20130402 String etc = (String) inResutlMap.get("etc"); ModelAndView mav = (ModelAndView) returnObj; String medTyCd = mav.getModel().get("medTyCd").toString(); etc += "|medTyCd=" + medTyCd; inResutlMap.put("etc", etc); } else if ("omcLog".equals(signature.getName()) || "omcDetailLog".equals(signature.getName())) { // dikey@20130423 ModelAndView mav = (ModelAndView) returnObj; inResutlMap.put("key2", mav.getModel().get("key2").toString()); } String requestUrl = inResutlMap.get("requestUrl") == null ? "" : inResutlMap.get("requestUrl").toString(); if (requestUrl.contains("regMemberTOI.do") || requestUrl.contains("mdnJoin.do") || requestUrl.contains("regIdpMemberTOI.do")) { ModelAndView mav = (ModelAndView) returnObj; if (mav.getModel().get("key2") != null) inResutlMap.put("key2", mav.getModel().get("key2").toString()); } /* Tstore-Tcloud ? omc ?? ?? ?? * ? requestHeader? ? ? ?? ?? ? * ? ? put 2013-11-14 jung-su.Jang */ if ("sync".equals(signature.getName())) { HttpServletRequest syncRequest = null; Object[] args = joinPoint.getArgs(); for (Object object : args) { if (object instanceof HttpServletRequest) { syncRequest = (HttpServletRequest) object; } } String tcdSrc = (String) syncRequest.getAttribute("tcdSrc"); if (tcdSrc != null && !"".equals(tcdSrc)) { String etc = (String) inResutlMap.get("etc"); etc += "|tcd-src=" + tcdSrc; inResutlMap.put("etc", etc); } } if ("startupsc".equals(signature.getName())) { ModelAndView mav = (ModelAndView) returnObj; if (mav != null && mav.getModel() != null) { inResutlMap.put("sessionID", mav.getModel().get("sessionID") != null && mav.getModel().get("sessionID").toString() != null ? mav.getModel().get("sessionID").toString() : ""); inResutlMap.put("key1", "memNo=" + mav.getModel().get("key1") != null && mav.getModel().get("key1").toString() != null ? mav.getModel().get("key1").toString() : "memNo="); inResutlMap.put("etc", mav.getModel().get("etc") != null && mav.getModel().get("etc").toString() != null ? mav.getModel().get("etc").toString() : "tcd-src=1"); } } if ("checkJoinMdn".equals(signature.getName())) { ModelAndView mav = (ModelAndView) returnObj; if (mav != null && mav.getModel() != null) { inResutlMap.put("etc", "uesrMdn=" + StringUtils.defaultString(mav.getModel().get("userMdn").toString())); } } // ? ? ?? log . /* Tstore-Tcloud ? mdnJoinNew ? ? OMC ? ?? * && !"mdnJoinNew".equals(signature.getName()) * 2013.11.18 jung-su.Jang */ // ? ? ?? log . if (!"".equals(inResutlMap.get("sysModule")) && !(inResutlMap.get("sysModule").equals(JobConstants.SERVICE_SYS_NAME_SAMPLE)) && !"mdnJoinNew".equals(signature.getName()) && !"mdnJoinNewForm".equals(signature.getName())) { //logger.info(makeLogString(inResutlMap, outResutlMap, etcResutlMap, true)); // artf120005 Token Expire ? OMC Log ? by jaeyeon.hwang 2014.03.13 if (!CodeMessage.RESPONSE_CODE_EXPIRED_TOKEN.equals(outResutlMap.get("resultCode"))) { logger.info(getFilterOmc(makeLogString(inResutlMap, outResutlMap, etcResutlMap, true))); } } } return returnObj; } catch (UserHandleableException ue) { if (!JobConstants.SERVICE_RESULT_UNAUTHORIZED_IP.equals(ue.getErrorCode())) { // IP? if (stopWatch.isRunning()) { stopWatch.stop(); // ? } outResutlMap.put("totalTimeSeconds", stopWatch.getTotalTimeMillis()); // outResutlMap.put("resultCode", ue.getErrorCode()); /* Tstore-Tcloud ? omc ?? ?? ?? * ? requestHeader? ? ? ?? ?? ? * ? ? put 2013-11-14 jung-su.Jang * */ if ("startupsc".equals(signature.getName()) || "mdnJoinNew".equals(signature.getName())) { inResutlMap.put("etc", "tcd-src=1"); if ("startupsc".equals(signature.getName())) { outResutlMap.put("resultCode", CodeMessage.RESPONSE_CODE_FAIL); logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, false)); } } /* artf113224 mdnLogin - TOKEN Expire ?? memNo by * Token Expired AOP ? OMC ? * jaeyeon.hwang 2014.02.18 */ if (!"startupsc".equals(signature.getName()) //artf120005 TokenExpire ? OMC Log by jaeyeon.hwang 2014.03.13 && !CodeMessage.RESPONSE_CODE_EXPIRED_TOKEN.equals(ue.getErrorCode())) { if (JobConstants.SERVICE_RESULT_CODE_FAIL.equals(ue.getErrorCode())) { logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, false)); } else { logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, true)); } } } throw new Exception(ue); } catch (Exception e) { if (stopWatch.isRunning()) { stopWatch.stop(); // ? } outResutlMap.put("totalTimeSeconds", stopWatch.getTotalTimeMillis()); // outResutlMap.put("resultCode", JobConstants.SERVICE_RESULT_CODE_FAIL); /* Tstore-Tcloud ? omc ?? ?? ?? * ? requestHeader? ? ? ?? ?? ? * ? ? put 2013-11-14 jung-su.Jang * */ if ("startupsc".equals(signature.getName()) || "mdnJoinNew".equals(signature.getName())) { inResutlMap.put("etc", "tcd-src=1"); if ("startupsc".equals(signature.getName())) { outResutlMap.put("resultCode", CodeMessage.RESPONSE_CODE_FAIL); } } else { logger.error(makeLogString(inResutlMap, outResutlMap, etcResutlMap, false)); } throw new Exception(e); } }
From source file:com.skplanet.tcloud.common.ParamAdvice.java
License:Open Source License
public Object doParamFilter(ProceedingJoinPoint joinPoint) throws Throwable { TCParam controllerTcParam = joinPoint.getTarget().getClass().getAnnotation(TCParam.class); String targetMethodName = StringUtils.nvlStr(joinPoint.getSignature().getName()); // ex) Object[] argObjs = joinPoint.getArgs(); // ? ? ?? //boolean isProceed = false; // ? String[] filterTypes = null;/*w w w .java2s.com*/ String[] methodNames = null; logger.debug("controllerTcParam : " + controllerTcParam + " >> targetMethodName : " + targetMethodName); try { if (controllerTcParam != null) { filterTypes = controllerTcParam.filterTypes(); methodNames = controllerTcParam.methodNames(); for (String methodName : methodNames) { if (targetMethodName.contains(methodName)) doParamProcess(filterTypes, argObjs); } } } catch (Exception e) { logger.error("? AOP !!!", e); } return joinPoint.proceed(); }
From source file:com.smallchill.core.aop.BeforeAop.java
License:Apache License
@Around("cutBefore()") public Object doBefore(ProceedingJoinPoint point) throws Throwable { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest();//from www .ja v a2s . co m MethodSignature ms = (MethodSignature) point.getSignature(); Method method = ms.getMethod(); Object[] args = point.getArgs(); Class<?> clazz = point.getTarget().getClass(); Before before = method.getAnnotation(Before.class); Interceptor ic = before.value().newInstance(); Object result = ic.intercept(new Invocation(clazz, method, args, request)); if (null == result) { return point.proceed(); } else { return result; } }
From source file:com.smallchill.core.aop.PermissionAop.java
License:Apache License
@Around("cutPermission()") public Object doPermission(ProceedingJoinPoint point) throws Throwable { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) .getRequest();//from w w w .j a v a 2 s . c o m MethodSignature ms = (MethodSignature) point.getSignature(); Method method = ms.getMethod(); Permission permission = method.getAnnotation(Permission.class); Object[] permissions = permission.value(); if ((permissions.length == 1 && Func.format(permissions[0]).equals("ALL")) || permissions == null || permissions.length == 0) { // boolean result = PermissionCheckManager.checkAll(request); if (result) { return point.proceed(); } else { throw new NoPermissionException(); } } else { // boolean result = PermissionCheckManager.check(permissions, request); if (result) { return point.proceed(); } else { throw new NoPermissionException(); } } }
From source file:com.snapdeal.archive.aspect.ArchivingExceptionHandlingAspect.java
License:Open Source License
/** * This method is a retry mechanism for various method, It will retry the method the given number of times in case * of exception/*from w w w . ja v a 2 s .co m*/ * * @param pjp * @throws Throwable */ @Around("markArchive() || insertIntoArchivalDb() || verifyCount() || deleteData()") public void wrapExceptionHandling(ProceedingJoinPoint pjp) throws Throwable { int i = 0; while (i < maxRetryCount) { try { pjp.proceed(); break; } catch (Throwable e) { i++; int tryCount = i + 1; SystemLog.logMessage("Some exception occurred ivoking method " + pjp.getSignature().getName() + ". Trying for " + tryCount + " time"); if (i == maxRetryCount - 1) { SystemLog.logException("Cannot complete the method " + pjp.getSignature().getName() + " evene after trying " + maxRetryCount + " times..."); throw e; } } } }