List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed() throws Throwable;
From source file:de.ebf.aopspringdemo.camera.CameraAspect_90.java
@Around("within(de.ebf.aopspringdemo.camera.*)") public void onWithinCameraPackageAround(ProceedingJoinPoint proceedingJoinPoint) { Utilities.writeToConsole("within camera package, before..."); try {/*from w w w .jav a 2s . c o m*/ proceedingJoinPoint.proceed(); } catch (Throwable throwable) { Utilities.writeToConsole(throwable.getMessage()); } Utilities.writeToConsole("within camera package, after..."); }
From source file:de.ebf.aopspringdemo.Logger.java
@Around("phoneCameraSnap()") public void onWillAndDidTakePhonePhoto(ProceedingJoinPoint proceedingJoinPoint) { Utilities.writeToConsole("phone photo will be taken (around)..."); try {//from ww w .j av a 2 s . c o m proceedingJoinPoint.proceed(); } catch (Throwable e) { } Utilities.writeToConsole("phone photo taken (around)."); }
From source file:de.escidoc.core.aa.security.aop.SecurityInterceptor.java
License:Open Source License
/** * Continue the invocation./*from w w w. j a va 2 s . c o m*/ * * @param joinPoint The current {@link ProceedingJoinPoint}. * @return Returns the result of the continued invocation. * @throws Throwable Thrown in case of an error during proceeding the method call. */ private static Object proceed(final ProceedingJoinPoint joinPoint) throws Throwable { return joinPoint.proceed(); }
From source file:de.escidoc.core.common.util.aop.HibernateInterceptor.java
License:Open Source License
/** * Continue the invocation.// ww w . j a va2s .c o m * * @param joinPoint The current {@link ProceedingJoinPoint}. * @return Returns the result of the continued invocation. * @throws Throwable Thrown in case of an error during proceeding the method call. */ private static Object proceed(final ProceedingJoinPoint joinPoint) throws Throwable { return joinPoint.proceed(); }
From source file:de.escidoc.core.common.util.aop.TraceInterceptor.java
License:Open Source License
@Around("execution(public * de.escidoc.core..*.* (..))" + " && !within(de.escidoc.core.common.util.aop..*)") public Object traceMethod(final ProceedingJoinPoint joinPoint) throws Throwable, Exception { if (LOGGER.isDebugEnabled()) { final StaticPart staticPart = joinPoint.getStaticPart(); final Signature signature = staticPart.getSignature(); final String depthString = getDepthString(); try {/*from w w w . j a v a2 s . c om*/ LOGGER.debug(createMessage(true, depthString, signature)); final Object returnValue = joinPoint.proceed(); LOGGER.debug(createMessage(false, depthString, signature)); return returnValue; } catch (final Exception e) { LOGGER.debug(createExceptionMessage(depthString, e)); throw e; } } return joinPoint.proceed(); }
From source file:de.escidoc.core.common.util.aop.XmlHeaderInterceptor.java
License:Open Source License
/** * Around advice to add xml header information and (in case of REST) a style sheet to the method result.<br> Note: * As it is not possible to return different references when using after-returning advises, the around advice is * used here./* ww w .ja v a 2 s . c o m*/ * * @param joinPoint The current {@link ProceedingJoinPoint}. * @return Returns the changed result. * @throws Throwable Thrown in case of an error. */ @Around("execution(public java.lang.String de.escidoc.core.*.service.*.*(..))" + " && !execution(* de.escidoc.core..*.SemanticStoreHandler*.*(..))" + " && !execution(* de.escidoc.core.common..*.*(..))") public Object processResult(final ProceedingJoinPoint joinPoint) throws Throwable { return post(joinPoint.proceed()); }
From source file:de.forsthaus.backend.util.db.logging.ServiceLogging.java
License:Open Source License
public Object logging(ProceedingJoinPoint call) throws Throwable { startTimes.add(Long.valueOf(System.nanoTime())); try {/*from w ww . j ava 2 s.c o m*/ // LOG.info("Start call: " + call.toShortString()); return call.proceed(); } finally { methodName = call.toShortString(); finishTime = (System.nanoTime() - startTimes.remove().longValue()) / 1000000; if (startTimes.isEmpty()) { methodName = StringUtils.substring(methodName, 10, -1); // LOG.info("Execution time: " + finishTime + "ms " + // methodName); loggingService.saveStatistics(statistics, methodName, finishTime); init(); } } }
From source file:de.gmorling.methodvalidation.spring.ValidationInterceptor.java
License:Apache License
@Around("execution(public * *(..)) && @within(de.gmorling.methodvalidation.spring.AutoValidating)") public Object validateMethodInvocation(ProceedingJoinPoint pjp) throws Throwable { Object result;//from w w w .j a va 2 s. c o m MethodSignature signature = (MethodSignature) pjp.getSignature(); MethodValidator methodValidator = validator.unwrap(MethodValidator.class); Set<MethodConstraintViolation<Object>> parametersViolations = methodValidator .validateAllParameters(pjp.getTarget(), signature.getMethod(), pjp.getArgs()); if (!parametersViolations.isEmpty()) { throw new MethodConstraintViolationException(parametersViolations); } result = pjp.proceed(); //Execute the method Set<MethodConstraintViolation<Object>> returnValueViolations = methodValidator .validateReturnValue(pjp.getTarget(), signature.getMethod(), result); if (!returnValueViolations.isEmpty()) { throw new MethodConstraintViolationException(returnValueViolations); } return result; }
From source file:de.huxhorn.lilith.tracing.TracingAspect.java
License:Open Source License
public Object trace(ProceedingJoinPoint call) throws Throwable { if (logger == null) { setLoggerName(null);//from ww w . j a v a 2 s . co m // this initializes the logger } Signature signature = call.getSignature(); Class<?> clazz = signature.getDeclaringType(); Object theTarget = call.getTarget(); if (theTarget != null) { clazz = theTarget.getClass(); } String fullClassName = clazz.getName(); String methodName = signature.getName(); StringBuilder msg = new StringBuilder(); if (showingModifiers) { msg.append(Modifier.toString(signature.getModifiers())).append(' '); } if (usingShortClassName) { msg.append(clazz.getSimpleName()); } else { msg.append(fullClassName); } msg.append('.').append(methodName); String methodBaseName = msg.toString(); if (signature instanceof MethodSignature) { MethodSignature methodSignature = (MethodSignature) signature; msg.append('('); if (showingParameterValues) { Object[] args = call.getArgs(); boolean first = true; for (Object arg : args) { if (first) { first = false; } else { msg.append(", "); } msg.append(SafeString.toString(arg, SafeString.StringWrapping.ALL, SafeString.StringStyle.GROOVY, SafeString.MapStyle.GROOVY)); } } else { Method method = methodSignature.getMethod(); Class<?>[] parameterTypes = method.getParameterTypes(); boolean first = true; for (Class<?> param : parameterTypes) { if (first) { first = false; } else { msg.append(", "); } msg.append(param.getSimpleName()); } if (method.isVarArgs()) { int length = msg.length(); msg.delete(length - 2, length); // cut of existing [] msg.append("..."); } } msg.append(')'); } String methodSignatureString = msg.toString(); String previousClass = MDC.get(TRACED_CLASS_MDC_KEY); String previousMethod = MDC.get(TRACED_METHOD_MDC_KEY); long nanoSeconds = 0; try { MDC.put(TRACED_CLASS_MDC_KEY, fullClassName); MDC.put(TRACED_METHOD_MDC_KEY, methodName); if (logger.isInfoEnabled(ENTERING_MARKER)) logger.info(ENTERING_MARKER, "{} entered.", methodSignatureString); Object result; nanoSeconds = System.nanoTime(); result = call.proceed(); nanoSeconds = System.nanoTime() - nanoSeconds; profile(methodBaseName, methodSignatureString, nanoSeconds); if (result == null || !showingParameterValues) { if (logger.isInfoEnabled(EXITING_MARKER)) logger.info(EXITING_MARKER, "{} returned.", methodSignatureString); } else { if (logger.isInfoEnabled(EXITING_MARKER)) logger.info(EXITING_MARKER, "{} returned {}.", methodSignatureString, result); } return result; } catch (Throwable t) { nanoSeconds = System.nanoTime() - nanoSeconds; profile(methodBaseName, methodSignatureString, nanoSeconds); if (logger.isInfoEnabled(THROWING_MARKER)) logger.info(THROWING_MARKER, "{} failed.", methodSignatureString, t); throw t; // rethrow } finally { if (previousClass == null) { MDC.remove(TRACED_CLASS_MDC_KEY); } else { MDC.put(TRACED_CLASS_MDC_KEY, previousClass); } if (previousMethod == null) { MDC.remove(TRACED_METHOD_MDC_KEY); } else { MDC.put(TRACED_METHOD_MDC_KEY, previousMethod); } } }
From source file:de.hybris.platform.acceleratorservices.dataimport.batch.aop.ExceptionHandlerAspect.java
License:Open Source License
/** * Invokes a method and wraps all Exceptions in a {@link BatchException}. * //from w w w .j ava2 s . co m * @param pjp * @return result of the invocation * @throws Throwable */ public Object execute(final ProceedingJoinPoint pjp) throws Throwable { final BatchHeader header = AspectUtils.getHeader(pjp.getArgs()); try { return pjp.proceed(); } catch (final Exception e) { throw new BatchException(e.getMessage(), header, e); } }