List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:de.hybris.platform.acceleratorservices.dataimport.batch.aop.TimeMeasurementAspect.java
License:Open Source License
/** * Invokes a method and measures the execution time. * /*from w w w . ja v a 2 s .c om*/ * @param pjp * @return result of the invocation * @throws Throwable */ public Object measure(final ProceedingJoinPoint pjp) throws Throwable { final String methodName = pjp.getTarget().getClass().getSimpleName() + "." + pjp.getSignature().getName(); final Object[] args = pjp.getArgs(); final long start = System.currentTimeMillis(); final Object result = pjp.proceed(); if (LOG.isInfoEnabled()) { final BatchHeader header = AspectUtils.getHeader(args); LOG.info("Processed " + methodName + (header == null ? "" : " [header=" + header + "]") + " in " + (System.currentTimeMillis() - start) + "ms"); } return result; }
From source file:de.hybris.platform.acceleratorstorefrontcommons.checkout.steps.validation.CheckoutStepValidationAspect.java
License:Open Source License
public Object validateCheckoutStep(final ProceedingJoinPoint pjp) throws Throwable { final MethodSignature methodSignature = (MethodSignature) pjp.getSignature(); final PreValidateCheckoutStep preValidateCheckoutStep = methodSignature.getMethod() .getAnnotation(PreValidateCheckoutStep.class); final CheckoutGroup checkoutGroup = getCheckoutFlowGroupMap() .get(getCheckoutFacade().getCheckoutFlowGroupForCheckout()); final CheckoutStep checkoutStepBean = checkoutGroup.getCheckoutStepMap() .get(preValidateCheckoutStep.checkoutStep()); final ValidationResults validationResults = checkoutStepBean .validate((RedirectAttributesModelMap) pjp.getArgs()[1]); if (checkoutStepBean.checkIfValidationErrors(validationResults)) { return checkoutStepBean.onValidation(validationResults); }//from ww w. j av a2 s . c o m return pjp.proceed(); }
From source file:de.kaiserpfalzEdv.vaadin.i18n.I18nInterceptor.java
License:Apache License
@Around("defaultSetCaption() || labelSetValue()") public Object doTranslation(final ProceedingJoinPoint invocation) { LOG.trace("Checking translations for {} ...", invocation.getSignature().getName()); Object result = null;/* w ww . ja v a 2s . c o m*/ Object[] args = invocation.getArgs(); args[0] = translate((String) args[0], UI.getCurrent().getLocale()); try { result = invocation.proceed(args); } catch (Throwable throwable) { LOG.error(throwable.getClass().getSimpleName() + " caught: " + throwable.getMessage(), throwable); } return result; }
From source file:de.zib.gndms.dspace.service.utils.DSpaceAspects.java
License:Apache License
@Around(value = "( inSubspaceServiceImpl() || inSliceKindServiceImpl() || inSliceServiceImpl() ) " + "&& args( subspaceId, .. )") public Object checkSubspaceExistence(final ProceedingJoinPoint pjp, final String subspaceId) throws Throwable { if (pjp.getSignature().getName().equals("createSubspace")) { if (subspaceProvider.exists(subspaceId)) { // TODO: this should be another exception... throw new UnauthorizedException("Subspace " + subspaceId + " does already exist."); }/* w w w . java 2 s . c o m*/ } else { if (!subspaceProvider.exists(subspaceId)) { throw new NoSuchResourceException("Subspace: " + subspaceId); } } return pjp.proceed(); }
From source file:de.zib.gndms.GORFX.service.util.GORFXAspects.java
License:Apache License
@Around(value = "inTaskServiceImpl() && args( taskId, .., String )") public Object logTaskId(ProceedingJoinPoint pjp, final String taskId) throws Throwable { MDC.put("TaskID", taskId); MDC.put("ServiceCall", pjp.getSignature().toLongString()); final Object ret = pjp.proceed(); MDC.remove("TaskID"); MDC.remove("ServiceCall"); return ret;/* ww w. j ava2 s . c o m*/ }
From source file:de.zib.gndms.GORFX.service.util.GORFXAspects.java
License:Apache License
@Around(value = "inTaskFlowServiceImpl() && args( type, taskFlowId, .., dn, wID )") public Object logTaskFlowId(ProceedingJoinPoint pjp, final String type, final String taskFlowId, final String dn, final String wID) throws Throwable { MDC.put("TaskFlowType", type); MDC.put("TaskFlowID", taskFlowId); MDC.put("WorkFlowID", wID); MDC.put("ServiceCall", pjp.getSignature().toLongString()); final Object ret = pjp.proceed(); MDC.remove("TaskFlowType"); MDC.remove("TaskFlowID"); MDC.remove("WorkFlowID"); MDC.remove("ServiceCall"); return ret;// www . ja v a 2 s .com }
From source file:de.zib.gndms.GORFX.service.util.GORFXAspects.java
License:Apache License
@Around(value = "inGORFXServiceImpl()") public Object logGORFXWithNewUUID(ProceedingJoinPoint pjp) throws Throwable { MDC.put("ServiceCall", pjp.getSignature().toLongString()); final Object ret = pjp.proceed(); MDC.remove("GORFXCall"); return ret;//from w ww . ja v a 2 s . c o m }
From source file:duokan.aop.ServiceMonitor.java
License:Apache License
@Around("execution(* duokan.service.*Service.*(..))") public Object around(ProceedingJoinPoint point) { long start = System.currentTimeMillis(); Object result = null;//from w w w . ja va2 s . co m try { result = point.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } /** http://www.yegor256.com/2014/06/01/aop-aspectj-java-method-logging.html */ logger.error("MethodName:{};;Arguments:{};;Result:{};;Calculated in [***[{}]***][msec]s", MethodSignature.class.cast(point.getSignature()).getMethod().getName(), point.getArgs(), result, System.currentTimeMillis() - start); return result; }
From source file:edu.eci.arsw.par1t.aspects.AspectsHandler.java
License:Open Source License
public Object analisis(ProceedingJoinPoint jp) { long start = System.currentTimeMillis(); Object object = null;/*from w w w. j av a2 s .c o m*/ try { MethodSignature signature = (MethodSignature) jp.getSignature(); Method method = signature.getMethod(); String nombre = method.getName(); object = jp.proceed(); start = System.currentTimeMillis() - start; if (jp.getTarget().toString().contains("DataLoaderOne")) { pw.println("Nombre del componente de carga : DataLoaderOne Tiempo " + start + " ms."); } else if (jp.getTarget().toString().contains("DataLoaderTwo")) { pw.println("Nombre del componente de carga : DataLoaderTwo Tiempo " + start + " ms."); } else if (jp.getTarget().toString().contains("SorterThree")) { pw.println("Nombre del componente de ordenamiendo : SorterThree Tiempo " + start + " ms."); } else if (jp.getTarget().toString().contains("SorterTwo")) { pw.println("Nombre del componente de ordenamiento: SorterTwo Tiempo " + start + " ms."); } } catch (Exception e) { e.printStackTrace(); } catch (Throwable ex) { ex.printStackTrace(); } pw.flush(); return object; }
From source file:edu.harvard.med.screensaver.ui.arch.view.aspects.UICommandExceptionHandlerAspect.java
License:Open Source License
private Object handleException(ProceedingJoinPoint joinPoint, Throwable t, String errorMessageId, String errorMessageArg) { AbstractBackingBean backingBean = (AbstractBackingBean) joinPoint.getTarget(); log.error("backing bean " + backingBean.getClass().getSimpleName() + " method " + joinPoint.getSignature().getName() + " threw " + t.getClass().getSimpleName() + ": " + t.getMessage(), t);/*from ww w . j a v a2 s . c o m*/ _messages.setFacesMessageForComponent(errorMessageId, null, errorMessageArg); if (backingBean instanceof EditableEntityViewer) { // TODO not working... // ((EntityViewer) backingBean).reload(); // this is the best we can do with the current design EditableEntityViewer editableViewer = (EditableEntityViewer) backingBean; return editableViewer.cancel(); } return ScreensaverConstants.REDISPLAY_PAGE_ACTION_RESULT; }