List of usage examples for org.aspectj.lang ProceedingJoinPoint getSignature
Signature getSignature();
getStaticPart().getSignature()
returns the same object From source file:net.greencoding.thysdrus.circuitbreaker.aspectj.CircuitBreakerAspect.java
License:Apache License
@Around(POINTCUT) public Object breakCircuit(final ProceedingJoinPoint pjp, final MonitoredByCircuitBreaker annotation) throws Throwable { String circuitBreakerKey = getCircuitBreakerKey(pjp.getSignature().toLongString(), annotation); logger.info("CB: {}", circuitBreakerKey); MethodInvocationResult methodInvocationResult = cbHandler.handleMethodInvocation(pjp, circuitBreakerKey); if (methodInvocationResult.getReturnObject() != null) { return methodInvocationResult.getReturnObject(); } else if (methodInvocationResult.getCause() != null) { throw methodInvocationResult.getCause(); } else {/* w w w.j a v a 2 s. c o m*/ return null; } }
From source file:net.joala.bdd.aop.JUnitAopStepsLogger.java
License:Open Source License
/** * <p>/*w w w .j a v a 2 s . co m*/ * Adviser to log steps. * </p> * * @param joinPoint where we are * @return the result of the step call * @throws Throwable in case of any error */ @Around("execution(* given_*(..))||execution(* when_*(..))||execution(* then_*(..))") public Object logGivenWhenThen(@Nonnull final ProceedingJoinPoint joinPoint) throws Throwable { // NOSONAR: Need to // deal with generic throwables here final String stepName = joinPoint.getSignature().getName(); final Object[] arguments = joinPoint.getArgs(); final Description stepDescription = describeStep(stepName, arguments); final Object result; try { LOG.info("{}", stepDescription); result = joinPoint.proceed(); } catch (Throwable throwable) { // NOSONAR: Need to deal with generic throwables here LOG.info("{} (FAILED)", stepDescription); throw throwable; } return result; }
From source file:net.jperf.aop.AbstractTimingAspect.java
License:Open Source License
protected Object runProfiledMethod(final ProceedingJoinPoint pjp, Profiled profiled) throws Throwable { //We just delegate to the super class, wrapping the AspectJ-specific ProceedingJoinPoint as an AbstractJoinPoint return runProfiledMethod(new AbstractJoinPoint() { public Object proceed() throws Throwable { return pjp.proceed(); }/*www .j a va2 s. c o m*/ public Object getExecutingObject() { return pjp.getThis(); } public Object[] getParameters() { return pjp.getArgs(); } public String getMethodName() { return pjp.getSignature().getName(); } public Class<?> getDeclaringClass() { return pjp.getSignature().getDeclaringType(); } }, profiled, newStopWatch(profiled.logger() + "", profiled.level())); }
From source file:net.maxiebyte.voxel.aspects.LoggableAspect.java
License:Open Source License
@Around("execution(* *(..)) && @annotation(net.maxiebyte.voxel.aspects.Loggable)") public Object wrapMethod(ProceedingJoinPoint point) throws Throwable { Method method = ((MethodSignature) point.getSignature()).getMethod(); Loggable loggableAnnotation = method.getAnnotation(Loggable.class); Loggable.Level level = loggableAnnotation.level(); Logger logger = LoggerFactory.getLogger(method.getDeclaringClass()); ENTERING_LEVEL_HANDLERS.get(level).accept(logger, loggableAnnotation.enteringPattern(), method.getName()); long time = System.currentTimeMillis(); Object result = point.proceed(); EXITING_LEVEL_HANDLERS.get(level).accept(logger, loggableAnnotation.exitingPattern(), method.getName(), System.currentTimeMillis() - time); return result; }
From source file:net.rrm.ehour.audit.aspect.AuditAspect.java
License:Open Source License
/** * Check if type is annotated with NonAuditable annotation * * @param pjp//from ww w . j a v a 2 s .co m * @return */ private boolean isAuditable(ProceedingJoinPoint pjp) { Annotation[] annotations = pjp.getSignature().getDeclaringType().getAnnotations(); boolean nonAuditable = false; for (Annotation annotation : annotations) { nonAuditable = annotation.annotationType() == NonAuditable.class; if (nonAuditable) { break; } } return !nonAuditable; }
From source file:net.rrm.ehour.audit.aspect.AuditAspect.java
License:Open Source License
private Audit createAudit(User user, Boolean success, AuditActionType auditActionType, ProceedingJoinPoint pjp) { String parameters = getAuditParameters(pjp); String page = null;/*www. j a va2s.c o m*/ RequestCycle cycle = RequestCycle.get(); if (cycle != null) { IPageRequestHandler lastHandler = PageRequestHandlerTracker.getLastHandler(cycle); if (lastHandler != null) { Class<? extends IRequestablePage> pageClass = lastHandler.getPageClass(); if (pageClass != null) { page = pageClass.getCanonicalName(); } } } return new Audit().setUser(user).setUserFullName(user != null ? user.getFullName() : null) .setDate(new Date()).setSuccess(success).setAction(pjp.getSignature().toShortString()) .setAuditActionType(auditActionType).setParameters(parameters).setPage(page); }
From source file:net.sf.dynamicreports.site.ExamplesAspect.java
License:Open Source License
@Around("build()") public void build(ProceedingJoinPoint pjp) throws Throwable { Class<?> design = pjp.getSignature().getDeclaringType(); name = design.getSimpleName();//from w ww . jav a 2s.c o m if (StringUtils.endsWith(name, "Design")) { name = StringUtils.substringBeforeLast(name, "Design"); } String path = design.getName().substring(Templates.class.getPackage().getName().length() + 1) .split("\\.")[0]; GenerateSite.addExample(name, path, design); pjp.proceed(); }
From source file:net.sf.gazpachoquest.aspects.ProfilingAdvise.java
License:Open Source License
private String createTaskName(final ProceedingJoinPoint proceedingJoinPoint) { return new StringBuffer(proceedingJoinPoint.getTarget().getClass().getSimpleName()).append(".") .append(proceedingJoinPoint.getSignature().getName()).toString(); }
From source file:net.sf.infrared.aspects.aj.AbstractApiAspect.java
License:Apache License
@SuppressWarnings("unchecked") @Around("apiExecution()") public Object around(ProceedingJoinPoint thisJoinPointStaticPart) throws Throwable { MonitorFacade facade = MonitorFactory.getFacade(); if (!isMonitoringEnabled(facade)) { return thisJoinPointStaticPart.proceed(); }// w w w. j a v a2s.c o m final Class classObj = thisJoinPointStaticPart.getSignature().getDeclaringType(); final String methodName = thisJoinPointStaticPart.getSignature().getName(); ApiContext ctx = new ApiContext(classObj.getName(), methodName, getLayer()); ExecutionTimer timer = new ExecutionTimer(ctx); StatisticsCollector collector = facade.recordExecutionBegin(timer); try { return thisJoinPointStaticPart.proceed(); } finally { facade.recordExecutionEnd(timer, collector); } }
From source file:net.sf.infrared.aspects.aj.InfraREDBaseAspect.java
License:Apache License
/** * Tracks the time taken by a method call and updates the statistics * @throws Throwable //from www . j a va2s. com **/ @SuppressWarnings("unchecked") @Around("condition()") public Object around(ProceedingJoinPoint thisJoinPointStaticPart) throws Throwable { final Class classObj = thisJoinPointStaticPart.getSignature().getDeclaringType(); final String methodName = thisJoinPointStaticPart.getSignature().getName(); final String apiType = getApiType(); Object returnVal; ApiContext ctx = new ApiContext(classObj.getName(), methodName, apiType); MonitorFacade facade = MonitorFactory.getFacade(); MonitorConfig cfg = facade.getConfiguration(); if (cfg.isMonitoringEnabled()) { ExecutionTimer timer = new ExecutionTimer(ctx); MonitorFactory.getFacade().recordExecutionBegin(timer); try { returnVal = thisJoinPointStaticPart.proceed(); } finally { MonitorFactory.getFacade().recordExecutionEnd(timer); } } else { returnVal = thisJoinPointStaticPart.proceed(); } return returnVal; }