List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
public Object debugThreadCreateStartEndAbort(ProceedingJoinPoint proceedingJoinPoint, Runnable runnable) throws Throwable { if (runnable instanceof ParallelSenderExecutor || runnable instanceof IsolatedServiceExecutor) { RequestReplyExecutor requestReplyExecutor = (RequestReplyExecutor) runnable; String createThreadId = Misc.createSimpleUUID(); Executor executor = new Executor(); executor.setIbisDebugger(ibisDebugger); executor.setRequestReplyExecutor(requestReplyExecutor); executor.setCreateThreadId(createThreadId); ibisDebugger.createThread(requestReplyExecutor, createThreadId, requestReplyExecutor.getCorrelationID()); Object[] args = proceedingJoinPoint.getArgs(); args[0] = executor;/*from ww w . j ava 2s.co m*/ return proceedingJoinPoint.proceed(args); } else { return proceedingJoinPoint.proceed(); } }
From source file:nl.nn.ibistesttool.IbisDebuggerAdvice.java
License:Apache License
private Object debugSenderInputAbort(ProceedingJoinPoint proceedingJoinPoint, ISender sender, String correlationId, String message) throws Throwable { message = ibisDebugger.senderInput(sender, correlationId, message); String result = null;//from www . jav a2 s.c om // For SenderWrapperBase continue even when it needs to be stubbed // because for SenderWrapperBase this will be checked when it calls // sendMessage on his senderWrapperProcessor, hence // debugSenderGetInputFrom will be called. if (!ibisDebugger.stubSender(sender, correlationId) || sender instanceof SenderWrapperBase) { try { Object[] args = proceedingJoinPoint.getArgs(); args[1] = message; result = (String) proceedingJoinPoint.proceed(args); } catch (Throwable throwable) { throw ibisDebugger.senderAbort(sender, correlationId, throwable); } } return result; }
From source file:nl.strohalm.cyclos.aop.TraceAspect.java
License:Open Source License
/** * Execute the trace//from w w w .j a va 2s . c o m */ private Object doTrace(final ProceedingJoinPoint joinPoint) throws Throwable { // Retrieve the method reference final Signature signature = joinPoint.getSignature(); final Method method = ((MethodSignature) signature).getMethod(); // Retrieve the permission descriptor for that method final ServicePermissionsDescriptor descriptor = getPermissionDescriptor(method); if (descriptor.isSkipPermissionCheck() || (descriptor.isForSystem() && CurrentInvocationData.isSystemInvocation())) { // only log client invocations not annotated with the DontEnforcePermission annotation or marked as traceable. if ((!descriptor.isSkipPermissionCheck() || descriptor.isTraceableAction()) && !CurrentInvocationData.isSystemInvocation()) { return executeAndLogAction(null, joinPoint); } else { // This is not an action, proceed normally return joinPoint.proceed(); } } else if (descriptor.isOnlyForSystem() && !CurrentInvocationData.isSystemInvocation()) { throw new PermissionDeniedException(); } else if (!descriptor.isAnnotated()) { throw new IllegalArgumentException("The method '" + method + "' is not secured correctly. It must be annotated using some of the security annotations."); } else { // This is an action - verify related member permission final Object[] args = joinPoint.getArgs(); final PermissionCheck check = descriptor.checkPermission(args.length == 0 ? null : args[0]); if (!check.isGranted()) { // Determine if log is being generated final boolean generateLog = loggingHandler.isTraceEnabled() && LoggedUser.isValid(); if (generateLog) { loggingHandler.logPermissionDenied(LoggedUser.user(), method, args); } throw new PermissionDeniedException(); } // Log the action execution return executeAndLogAction(check, joinPoint); } }
From source file:nl.strohalm.cyclos.aop.TraceAspect.java
License:Open Source License
private Object executeAndLogAction(final PermissionCheck check, final ProceedingJoinPoint joinPoint) throws Throwable { Object[] args = null;/*from ww w . j av a 2 s . c o m*/ Signature signature = null; Method method = null; Permission permission = null; // Determine if log is being generated final boolean generateLog = loggingHandler.isTraceEnabled() && LoggedUser.isValid(); if (generateLog) { args = joinPoint.getArgs(); signature = joinPoint.getSignature(); method = ((MethodSignature) signature).getMethod(); permission = check == null ? null : check.getPermission(); } try { final Object retVal = joinPoint.proceed(); if (generateLog) { loggingHandler.trace(LoggedUser.remoteAddress(), LoggedUser.user(), permission, method, args, retVal); } return retVal; } catch (final Throwable t) { if (generateLog) { loggingHandler.traceError(LoggedUser.user(), permission, method, args, t); } throw t; } }
From source file:nl.thehyve.podium.common.aop.logging.LoggingAspect.java
License:Apache License
/** * Advice that logs when a method is entered and exited. * * @param joinPoint The binding joinpoint * @throws Throwable Throws IllegalArgumentException * @return Object The result object// w ww. ja va2s .c o m */ @Around("loggingPointcut()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { if (log.isDebugEnabled()) { log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); } try { Object result = joinPoint.proceed(); if (log.isDebugEnabled()) { log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), result); } return result; } catch (IllegalArgumentException e) { log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); throw e; } }
From source file:org.a3badran.platform.logging.aspect.LogRequestAspect.java
License:MIT License
@Around(value = "@annotation(LogRequest)", argNames = "joinPoint,LogRequest") public Object log(ProceedingJoinPoint joinPoint, LogRequest logRequest) throws Throwable { String name = logRequest.value(); // use method name if @LogRequest(name) is null if (name == null || name.isEmpty()) { name = joinPoint.getSignature().getName(); if (joinPoint.getTarget() != null && joinPoint.getTarget().getClass() != null) { name = joinPoint.getTarget().getClass().getSimpleName() + "." + name; }//from w w w .j a v a 2 s . co m } // start the scope RequestScope scope = RequestLogger.startScope(name); try { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); String methodName = signature.getMethod().getName(); Class<?>[] parameterTypes = signature.getMethod().getParameterTypes(); Annotation[][] annotations; annotations = joinPoint.getTarget().getClass().getMethod(methodName, parameterTypes) .getParameterAnnotations(); int i = 0; for (Object arg : joinPoint.getArgs()) { for (Annotation annotation : annotations[i]) { if (annotation.annotationType() == LogParam.class) { String string = arg == null ? "null" : arg.toString(); RequestLogger.addInfo(((LogParam) annotation).value(), string); } } i++; } // run the method // NOTE: exceptions thrown before the actual method is called will result in failure. // TODO: configure the ability to bypass exception prior to method calling. return joinPoint.proceed(); } catch (Throwable t) { if (RequestLogger.getRequestErrorHandler() != null) { RequestLogger.getRequestErrorHandler().handleError(t); } else { RequestLogger.addError(t.toString()); } throw t; } finally { // close the scope no matter what RequestLogger.endScope(scope); } }
From source file:org.apache.atlas.aspect.AtlasAspect.java
License:Apache License
@Around("@annotation(org.apache.atlas.aspect.Loggable) && execution(* *(..))") public Object logAroundLoggable(ProceedingJoinPoint joinPoint) throws Throwable { Signature methodSign = joinPoint.getSignature(); String methodName = methodSign.getDeclaringType().getSimpleName() + "." + methodSign.getName(); if (LOG.isDebugEnabled()) { LOG.debug(String.format("==> %s(%s)", methodName, Arrays.toString(joinPoint.getArgs()))); }/*from w w w.j a va2s . co m*/ Object response = joinPoint.proceed(); if (LOG.isDebugEnabled()) { LOG.debug(String.format("<== %s(%s): %s", methodName, Arrays.toString(joinPoint.getArgs()), response instanceof List ? ((List) response).size() : response)); } return response; }
From source file:org.apache.falcon.aspect.AbstractFalconAspect.java
License:Apache License
@Around("@annotation(org.apache.falcon.monitors.Monitored)") public Object logAroundMonitored(ProceedingJoinPoint joinPoint) throws Throwable { String methodName = joinPoint.getSignature().getName(); Object[] args = joinPoint.getArgs(); Object result;/*from w w w.ja v a 2 s . c o m*/ ResourceMessage.Status status; long startTime = System.nanoTime(); long endTime; try { result = joinPoint.proceed(); } catch (Exception e) { endTime = System.nanoTime(); status = ResourceMessage.Status.FAILED; publishMessage(getResourceMessage( joinPoint.getSignature().getDeclaringType().getSimpleName() + "." + methodName, args, status, endTime - startTime)); throw e; } endTime = System.nanoTime(); status = ResourceMessage.Status.SUCCEEDED; publishMessage( getResourceMessage(joinPoint.getSignature().getDeclaringType().getSimpleName() + "." + methodName, args, status, endTime - startTime)); return result; }
From source file:org.apache.falcon.aspect.AbstractFalconAspect.java
License:Apache License
@Around("@annotation(org.apache.falcon.monitors.Alert)") public Object logAroundAlert(ProceedingJoinPoint joinPoint) throws Throwable { String methodName = joinPoint.getSignature().getName(); String event = ResourcesReflectionUtil.getResourceMonitorName( joinPoint.getSignature().getDeclaringType().getSimpleName() + "." + methodName); Object[] args = joinPoint.getArgs(); Object result;// w w w .ja va 2 s .c om try { result = joinPoint.proceed(); } finally { AlertMessage alertMessage = new AlertMessage(event, args[0].toString(), args[1].toString()); publishAlert(alertMessage); } return result; }
From source file:org.apache.falcon.aspect.AbstractFalconAspect.java
License:Apache License
@Around("@annotation(org.apache.falcon.monitors.Auditable)") public Object logAroundAudit(ProceedingJoinPoint joinPoint) throws Throwable { Object[] args = joinPoint.getArgs(); Object result;//from w ww .j a v a 2 s . co m try { result = joinPoint.proceed(); } finally { AuditMessage auditMessage = new AuditMessage(getStringValue(args[0], "Unknown-User"), getStringValue(args[1], "Unknown-Address"), getStringValue(args[2], "Unknown-Host"), getStringValue(args[3], "Unknown-URL"), getStringValue(args[4], "Unknown-Address"), getStringValue(args[5], "Unknown-Time")); publishAudit(auditMessage); } return result; }