List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:org.apache.rave.synchronization.SynchronizingAspectTest.java
License:Apache License
private ProceedingJoinPoint prepareJoinPoint(String expectedDiscriminator, String expectedId, TestService service, Method expectedMethod, TestObject argument, Object[] joinPointArgs) throws Throwable { MethodSignature methodSignature = createMock(MethodSignature.class); expect(methodSignature.getMethod()).andReturn(expectedMethod); replay(methodSignature);/*w w w . j a v a2s . c o m*/ ProceedingJoinPoint joinPoint = createMock(ProceedingJoinPoint.class); expect(joinPoint.getSignature()).andReturn(methodSignature); expect(joinPoint.getTarget()).andReturn(service); expect(joinPoint.getArgs()).andReturn(joinPointArgs); expect(joinPoint.proceed()).andReturn(expectedMethod.invoke(service, argument)); replay(joinPoint); Lock lock = new ReentrantLock(); expect(lockService.borrowLock(expectedDiscriminator, expectedId)).andReturn(lock); lockService.returnLock(lock); replay(lockService); return joinPoint; }
From source file:org.apache.rocketmq.console.aspect.admin.MQAdminAspect.java
License:Apache License
@Around(value = "mQAdminMethodPointCut() || multiMQAdminMethodPointCut()") public Object aroundMQAdminMethod(ProceedingJoinPoint joinPoint) throws Throwable { long start = System.currentTimeMillis(); Object obj = null;// w w w . j a va 2s.com try { MQAdminInstance.initMQAdminInstance(); obj = joinPoint.proceed(); } finally { MQAdminInstance.destroyMQAdminInstance(); logger.info("op=look method={} cost={}", joinPoint.getSignature().getName(), System.currentTimeMillis() - start); } return obj; }
From source file:org.apache.servicecomb.tracing.zipkin.ZipkinSpanAspect.java
License:Apache License
@Around("execution(@org.apache.servicecomb.tracing.Span * *(..)) && @annotation(spanAnnotation)") public Object advise(ProceedingJoinPoint joinPoint, Span spanAnnotation) throws Throwable { String spanName = spanAnnotation.spanName(); String callPath = spanAnnotation.callPath(); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); LOG.debug("Generating zipkin span for method {}", method.toString()); if ("".equals(spanName)) { spanName = method.getName();// w ww .j a v a 2 s . c o m } if ("".equals(callPath)) { callPath = method.toString(); } return adviser.invoke(spanName, callPath, joinPoint::proceed); }
From source file:org.apache.syncope.core.logic.LogicInvocationHandler.java
License:Apache License
@Around("execution(* org.apache.syncope.core.logic.AbstractLogic+.*(..))") public Object around(final ProceedingJoinPoint joinPoint) throws Throwable { Class<?> clazz = joinPoint.getTarget().getClass(); Object[] input = joinPoint.getArgs(); String category = clazz.getSimpleName(); MethodSignature ms = (MethodSignature) joinPoint.getSignature(); Method method = ms.getMethod(); String event = joinPoint.getSignature().getName(); AuditElements.Result result = null; Object output = null;//from w ww .ja v a 2 s .c o m Object before = null; try { LOG.debug("Before {}.{}({})", clazz.getSimpleName(), event, input == null || input.length == 0 ? "" : Arrays.asList(input)); try { before = ((AbstractLogic) joinPoint.getTarget()).resolveBeanReference(method, input); } catch (UnresolvedReferenceException ignore) { LOG.debug("Unresolved bean reference ..."); } output = joinPoint.proceed(); result = AuditElements.Result.SUCCESS; LOG.debug("After returning {}.{}: {}", clazz.getSimpleName(), event, output); return output; } catch (Throwable t) { output = t; result = AuditElements.Result.FAILURE; LOG.debug("After throwing {}.{}", clazz.getSimpleName(), event); throw t; } finally { notificationManager.createTasks(AuditElements.EventCategoryType.LOGIC, category, null, event, result, before, output, input); auditManager.audit(AuditElements.EventCategoryType.LOGIC, category, null, event, result, before, output, input); } }
From source file:org.apache.syncope.core.rest.controller.ControllerHandler.java
License:Apache License
@Around("execution(* org.apache.syncope.core.rest.controller.AbstractController+.*(..))") public Object around(final ProceedingJoinPoint joinPoint) throws Throwable { final Class<?> clazz = joinPoint.getTarget().getClass(); final Object[] input = joinPoint.getArgs(); final String category = clazz.getSimpleName(); final MethodSignature ms = (MethodSignature) joinPoint.getSignature(); Method method = ms.getMethod(); final String event = joinPoint.getSignature().getName(); AuditElements.Result result = null; Object output = null;//from w ww .j a va 2 s . c om Object before = null; try { LOG.debug("Before {}.{}({})", clazz.getSimpleName(), event, input == null || input.length == 0 ? "" : Arrays.asList(input)); try { before = ((AbstractController) joinPoint.getTarget()).resolveBeanReference(method, input); } catch (UnresolvedReferenceException ignore) { LOG.debug("Unresolved bean reference ..."); } output = joinPoint.proceed(); result = AuditElements.Result.SUCCESS; LOG.debug("After returning {}.{}: {}", clazz.getSimpleName(), event, output); return output; } catch (Throwable t) { output = t; result = AuditElements.Result.FAILURE; LOG.debug("After throwing {}.{}", clazz.getSimpleName(), event); throw t; } finally { notificationManager.createTasks(AuditElements.EventCategoryType.REST, category, null, event, result, before, output, input); auditManager.audit(AuditElements.EventCategoryType.REST, category, null, event, result, before, output, input); } }
From source file:org.apache.tuscany.sca.aspectj.TimingAspect.java
License:Apache License
@Around("timedCall()") public Object timedSection(ProceedingJoinPoint jp) throws Throwable { System.out.println("Timing Around timedSection jp=" + jp); long start = System.currentTimeMillis(); try {/*from ww w .ja v a 2s .c o m*/ return jp.proceed(); } finally { long end = System.currentTimeMillis(); System.out.println("Timing Around timedSection Roundtrip is " + (end - start) + "ms for jp.getSignature=" + jp.getSignature()); } }
From source file:org.apereo.inspektr.aspect.TraceLogAspect.java
License:Apache License
/** * Added TRACE-level log entries for the executing target. * * @param proceedingJoinPoint the proceeding join point * @return the object//w w w .j a v a 2 s .c o m * @throws Throwable the throwable */ @Around("(execution (public * org.apereo..*.*(..))) && !(execution( * org.apereo..*.set*(..)))") public Object traceMethod(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable { Logger logger = null; try { logger = this.getLog(proceedingJoinPoint); } catch (final Throwable t) { t.printStackTrace(); } if (logger == null) { System.err.println("Could not obtain logger object from the proceeding joinpoint"); return proceedingJoinPoint.proceed(); } Object returnVal = null; final String methodName = proceedingJoinPoint.getSignature().getName(); try { if (logger.isTraceEnabled()) { final Object[] args = proceedingJoinPoint.getArgs(); final String arguments; if (args == null || args.length == 0) { arguments = ""; } else { arguments = Arrays.deepToString(args); } logger.trace("Entering method [{}] with arguments [{}]", methodName, arguments); } returnVal = proceedingJoinPoint.proceed(); return returnVal; } finally { logger.trace("Leaving method [{}] with return value [{}].", methodName, returnVal != null ? returnVal.toString() : "null"); } }
From source file:org.apereo.portal.concurrency.caching.RequestCacheAspect.java
License:Apache License
protected final CacheStatistics getCacheStatistics(ProceedingJoinPoint pjp, RequestCache requestCache) { final Signature signature = pjp.getSignature(); final String signatureString = signature.toString(); CacheStatistics cacheStatistics = this.methodStats.get(signatureString); if (cacheStatistics == null) { final CacheStatistics newStats = new CacheStatistics(); cacheStatistics = ConcurrentMapUtils.putIfAbsent(this.methodStats, signatureString, newStats); if (this.mBeanExportOperations != null && cacheStatistics == newStats) { final String nameString = "uPortal:section=Cache,RequestCache=RequestCache,name=" + EhcacheHibernateMbeanNames.mbeanSafe(signatureString); try { final ObjectName name = new ObjectName(nameString); registerMbean(cacheStatistics, name); } catch (MalformedObjectNameException e) { logger.warn(/* www .j a v a 2 s . c o m*/ "Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e); } catch (NullPointerException e) { logger.warn( "Failed to create ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e); } catch (InstanceAlreadyExistsException e) { logger.warn( "ObjectName {} is already registered, the corresponding CacheStatistics will not be registered with JMX", nameString, e); } catch (MBeanRegistrationException e) { logger.warn( "Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e); } catch (NotCompliantMBeanException e) { logger.warn( "Failed to register ObjectName {} the corresponding CacheStatistics will not be registered with JMX", nameString, e); } } } return cacheStatistics; }
From source file:org.apereo.portal.concurrency.caching.RequestCacheAspect.java
License:Apache License
protected CacheKey createCacheKey(ProceedingJoinPoint pjp, RequestCache requestCache) { final Signature signature = pjp.getSignature(); final Class<?> declaringType = signature.getDeclaringType(); final String signatureLongString = signature.toLongString(); final boolean[] keyMask = requestCache.keyMask(); final Object[] args = pjp.getArgs(); final Object[] keyArgs; if (keyMask.length == 0) { keyArgs = args;/* w w w .ja v a 2 s . c om*/ } else if (keyMask.length != args.length) { throw new AnnotationFormatError( "RequestCache.keyMask has an invalid length on: " + signature.toLongString()); } else { keyArgs = new Object[args.length]; for (int i = 0; i < args.length; i++) { if (keyMask[i]) { keyArgs[i] = args[i]; } } } return CacheKey.build(signatureLongString, declaringType, keyArgs); }
From source file:org.axonframework.samples.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 w w w .j av a2 s . c o m sw.start(pjp.getSignature().getName()); return pjp.proceed(); } finally { sw.stop(); System.out.println(sw.getLastTaskName() + sw.shortSummary()); } }