List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:com.square.logs.aop.advice.GestionLogAdvice.java
License:Open Source License
/** * ajoute le log de l'appel service./*w ww . java 2 s . co m*/ * @param point l'appel intercept * @return Object retour de l'appel * @throws Throwable exception */ public Object log(ProceedingJoinPoint point) throws Throwable { Object retVal = null; final String methodName = point.getSignature().toLongString(); final Object[] args = point.getArgs(); final LogDto logDto = new LogDto(); logDto.setApplication(application); logDto.setProfondeur(profondeur); logDto.setDate(Calendar.getInstance()); logDto.setSignature(methodName); try { logDto.setParametres(Arrays.asList(args)); retVal = point.proceed(); logDto.setResultat(retVal); if (logLevel == LogLevel.INFO) { logService.ajouterLog(logDto); } return retVal; } catch (Throwable e) { if (logLevel != LogLevel.NONE) { logDto.setTraceException(e.getMessage()); logService.ajouterLog(logDto); } throw e; } }
From source file:com.square.synchro.aop.CreerEspaceClientAdvice.java
License:Open Source License
/** * {@inheritDoc}/* w w w. j ava2s . c o m*/ */ public Object transformationVivier(ProceedingJoinPoint pjp) throws Throwable { // Rcupration du paramtre & analyse des synchros lancer : final Long idPersonne = (Long) pjp.getArgs()[0]; final Object retVal = pjp.proceed(); try { creerEspaceClient(idPersonne); } catch (Exception e) { logger.fatal(messageSourceUtil.get(MessageKeyUtil.LOGGER_FATAL_CREATION_ESPACE_CLIENT_PP, new String[] { e.getMessage() }), e); } return retVal; }
From source file:com.stee.asm.aop.LoggerAdvice.java
License:Open Source License
@Around("servicePointCut()") public Object around(ProceedingJoinPoint pjp) throws Throwable { logger.doLog(LoggerLevel.INFO, "Invoke --> Class: " + pjp.getTarget().getClass().getSimpleName() + " -- Method: " + pjp.getSignature().getName() + " -- Args: " + Arrays.toString(pjp.getArgs())); long timeMills = System.currentTimeMillis(); Object proceed = pjp.proceed(); logger.doLog(LoggerLevel.INFO,//from ww w . j ava2 s.c om "Finish --> Return: " + proceed + " -- Cost: " + (System.currentTimeMillis() - timeMills)); return proceed; }
From source file:com.stratelia.webactiv.util.annotation.AnnotationUtil.java
License:Open Source License
/** * Provides a centralized way to extract annoted method parameter values. * @param invocationContext/*from w ww . j ava 2 s .co m*/ * @return * @throws Exception */ public static Map<Class<Annotation>, List<Object>> extractMethodAnnotedParameterValues( ProceedingJoinPoint invocationContext) throws Exception { return extractMethodAnnotedParameterValues(getMethodFromContext(invocationContext), invocationContext.getArgs()); }
From source file:com.stratio.qa.aspects.BrowsersDataProviderAspect.java
License:Apache License
/** * If a System property with FORCE_BROWSER exists then Methods in * BrowsersDataProvider will return its value. * * @param pjp ProceedingJoinPoint//from w ww . j a v a 2s.c o m * @return Object * @throws Throwable exception */ @Around(value = "availableBrowsersCallPointcut()") public Object availableBrowsersCalls(ProceedingJoinPoint pjp) throws Throwable { if (pjp.getArgs().length > 0) { if (pjp.getArgs()[0] instanceof ITestContext) { if (Arrays.asList(((ITestContext) pjp.getArgs()[0]).getIncludedGroups()).contains("mobile")) { return pjp.proceed(); } } } if (!"".equals(System.getProperty("FORCE_BROWSER", ""))) { List<String[]> lData = Lists.newArrayList(); lData.add(new String[] { System.getProperty("FORCE_BROWSER") }); logger.debug("Forcing browser to {}", System.getProperty("FORCE_BROWSER")); return lData.iterator(); } return pjp.proceed(); }
From source file:com.stratio.qa.aspects.RunOnTagAspect.java
License:Apache License
/** * Allows conditional scenario execution. * If the scenario contains the following tag: * <dl>//from w w w . j av a 2s . com * <dt>\@runOnEnv(param)</dt> *<dd>The scenario will only be executed if the param is defined when test is launched. Configuration map object. * More than one param can be passed in the tag. To do so, the params must be comma separated: * \@runOnEnv(param): The scenario will only be executed if the param is defined when test is launched. * \@runOnEnv(param1,param2,param3): The scenario will only be executed if ALL the params are defined. * </dd> * </dl> * Additionally, if the scenario contains the following tag: * <dl> * <dt>\@skipOnEnv(param)</dt> *<dd>The scenario will be omitted if the param is defined when test is launched. * More than one param can be passed in the tag. To do so, the params must be comma separated. * The scenario will omitted if ANY of params are defined. (OR)</dd> * *<dd>Or in separated lines to force ALL of the params to be defined in order to omit the execution</dd> * <dt> \@skipOnEnv(param1) * \@skipOnEnv(param2) * \@skipOnEnv(param3)</dt> *<dd>The scenario will omitted if ALL of params are defined. (AND)</dd> *</dl> * * @param pjp ProceedingJoinPoint * @param comments comments * @param tags tags of scenario * @param keyword keyword * @param name name * @param description description * @param line line * @param id id * @throws Throwable exception */ @Around(value = "AddRunOnTagPointcutScenario(comments, tags, keyword, name, description, line, id)") public void aroundAddRunOnTagPointcut(ProceedingJoinPoint pjp, List<Comment> comments, List<Tag> tags, String keyword, String name, String description, Integer line, String id) throws Throwable { Scenario linescn = (Scenario) pjp.getTarget(); Boolean exit = tagsIteration(tags, line); if (exit) { ThreadProperty.set("skippedOnParams" + pjp.getArgs()[3].toString() + linescn.getLine(), "true"); } }
From source file:com.tacitknowledge.flip.aspectj.FlipAbstractAspect.java
License:Apache License
/** * Intercept calls to the methods marked with {@link Flippable} annotation. * Firstly it processes the method parameters marked with {@link FlipParam} * annotation. Each parameter value is replaced with the value declared in * {@link FlipParam#disabledValue()} if the feature declared in {@link FlipParam#feature() } * is disabled.// w w w . j av a2 s.c o m * After properties evaluation this method checks if the feature marked in * {@link Flippable#feature() } is disabled then the value from {@link Flippable#disabledValue() } * is returned. * * @param flip the {@link Flippable} annotation instance which marks the method to intercept. * @param pjp the object obtained from AspectJ method interceptor. * @return the processed value of the method depending from feature state. * @throws Throwable */ @Around(value = "anyMethod() && @annotation(flip)", argNames = "flip") public Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip) throws Throwable { MethodSignature methodSignature = (MethodSignature) pjp.getSignature(); Method method = methodSignature.getMethod(); if (isFeatureEnabled(flip.feature())) { Annotation[][] paramAnnotations = method.getParameterAnnotations(); Object[] params = pjp.getArgs(); Class[] paramTypes = method.getParameterTypes(); for (int i = 0; i < paramAnnotations.length; i++) { FlipParam flipParam = findFlipParamAnnoattion(paramAnnotations[i]); if (!isFeatureEnabled(flipParam.feature())) { params[i] = getProcessedDisabledValue(paramTypes[i], flipParam.disabledValue(), pjp.getThis()); } } return pjp.proceed(params); } else { return getProcessedDisabledValue(method.getReturnType(), flip.disabledValue(), pjp.getThis()); } }
From source file:com.tasktop.c2c.server.common.service.ServiceLoggingAdvice.java
License:Open Source License
private void logCall(ProceedingJoinPoint pjp, Throwable t, Object result, StringBuilder msg) throws NoSuchMethodException { Method method = ((MethodSignature) pjp.getSignature()).getMethod(); msg.append(pjp.getSignature().getDeclaringType().getSimpleName()).append(".") .append(pjp.getSignature().getName()).append("("); if (method.getAnnotation(NoLog.class) != null) { msg.append("***)"); return;// w w w . j ava 2 s . co m } boolean needSep = false; int i = 0; for (Object arg : pjp.getArgs()) { if (needSep) { msg.append(", "); } else { needSep = true; } if (!shouldLog(i++, method)) { msg.append("***"); } else { msg.append(String.valueOf(arg)); } } msg.append(") -> "); if (t != null) { msg.append("threw ").append(t.toString()); } else { msg.append(result); } }
From source file:com.thesoftwareguild.mavenflooringmastery.aspects.AuditAspect.java
public Object logCreate(ProceedingJoinPoint jp) { Object retVal = null;/* w w w. j av a 2 s . co m*/ try { retVal = jp.proceed(); Order order = (Order) jp.getArgs()[0]; Date now = new Date(); AuditEntry entry = new AuditEntry(now, order, "CREATED"); dao.log(entry); } catch (Throwable ex) { Logger.getLogger(AuditAspect.class.getName()).log(Level.SEVERE, null, ex); } return retVal; }
From source file:com.thesoftwareguild.mavenflooringmastery.aspects.AuditAspect.java
public Object logUpdate(ProceedingJoinPoint jp) { Object retVal = null;//from w w w . jav a 2 s .com try { retVal = jp.proceed(); Order order = (Order) jp.getArgs()[0]; Date now = new Date(); AuditEntry entry = new AuditEntry(now, order, "UPDATED"); dao.log(entry); } catch (Throwable ex) { Logger.getLogger(AuditAspect.class.getName()).log(Level.SEVERE, null, ex); } return retVal; }