List of usage examples for org.aspectj.lang ProceedingJoinPoint getArgs
Object[] getArgs();
From source file:fr.scolomfr.recette.cli.commands.ConsoleTestCaseExecutionTrackingAspect.java
License:Open Source License
@Around("execution(* fr.scolomfr.recette.model.tests.execution.result.Result.setState(..))") public void messageAdded(ProceedingJoinPoint joinPoint) { State state = (State) joinPoint.getArgs()[0]; if (state.equals(State.FINAL)) { tracker.notifyTestCaseTermination((Result) joinPoint.getTarget()); }//from w w w .j av a2 s .c o m }
From source file:fr.scolomfr.recette.cli.commands.ConsoleTestCaseExecutionTrackingAspect.java
License:Open Source License
@Around("execution(* fr.scolomfr.recette.model.tests.execution.result.Result.setState(..))") public void testCaseStopped(ProceedingJoinPoint joinPoint) { State state = (State) joinPoint.getArgs()[0]; if (state.equals(State.FINAL)) { tracker.notifyTestCaseTermination((Result) joinPoint.getTarget()); }/*from w w w . ja va 2s. c om*/ }
From source file:fr.wirth.aspect.GlobalAspect.java
License:Apache License
@Around("execution(* fr.wirth..*(..))") public Object methodsWithArgumentsLogger(ProceedingJoinPoint joinPoint) throws Throwable { StringBuilder sb = new StringBuilder("Calling : "); sb.append(joinPoint.getSignature().getDeclaringType().getName()); sb.append("."); sb.append(joinPoint.getSignature().getName()); sb.append("("); sb.append(Arrays.toString(joinPoint.getArgs())); sb.append(")"); LOGGER.debug(sb.toString());/*from w w w . jav a2 s . c om*/ Object value = joinPoint.proceed(); sb = new StringBuilder("Result : "); sb.append(value); LOGGER.debug(sb.toString()); return value; }
From source file:fr.xebia.audit.AuditAspect.java
License:Apache License
@Around(value = "execution(* *(..)) && @annotation(audited)", argNames = "pjp,audited") public Object logMessage(ProceedingJoinPoint pjp, Audited audited) throws Throwable { long nanosBefore = System.nanoTime(); try {//from w ww .j a v a2s . c o m Object returned = pjp.proceed(); long durationInNanos = System.nanoTime() - nanosBefore; String message = buildMessage(audited.message(), pjp.getThis(), pjp.getArgs(), returned, null, durationInNanos); logger.info(message); return returned; } catch (Throwable t) { long durationInNanos = System.nanoTime() - nanosBefore; String message = buildMessage(audited.message(), pjp.getThis(), pjp.getArgs(), null, t, durationInNanos); logger.warn(message); throw t; } }
From source file:gov.fda.open.demo.service.loggable.LoggingAspect.java
License:Open Source License
/** * ********************.//from www. j a va 2s. c o m * * @param joinPoint * the join point * @param annotation * the annotation * @return the object * @throws Throwable * the throwable */ @Around(value = "@annotation(annotation)") public Object logAround(final ProceedingJoinPoint joinPoint, final Loggable annotation) throws Throwable { final Object returnVal; Class<? extends Object> clazz = joinPoint.getTarget().getClass(); String name = joinPoint.getSignature().getName(); Object[] args = joinPoint.getArgs(); if (args == null || args.length == 0) { logger.log(annotation.value(), clazz, null, BEFORE_STRING, name, constructArgumentsString(clazz, joinPoint.getArgs())); } else { logger.log(annotation.value(), clazz, null, BEFORE_WITH_PARAMS_STRING, name, constructArgumentsString(clazz, joinPoint.getArgs())); } returnVal = joinPoint.proceed(); // Now Do The After Logging Part afterReturningLog(joinPoint, annotation, returnVal); return returnVal; }
From source file:gov.nih.nci.cabig.caaers.tools.logging.CaaersLoggingAspect.java
License:BSD License
private void log(Log logger, boolean entry, ProceedingJoinPoint call, Object retVal, long time, String userName) {//w w w. j a v a 2s.c o m try { StringBuilder sb = new StringBuilder("[").append(userName).append("] - "); if (entry) { Object[] args = call.getArgs(); sb.append(entryMsgPrefix).append(" [").append(call.toShortString()).append(" ] with params { ") .append(String.valueOf(args != null && args.length > 0 ? args[0] : "")).append("}"); } else { sb.append(exitMsgPrefix).append(" [").append(call.toShortString()).append(" ] with return as: {") .append(String.valueOf(retVal)).append("} - executionTime : ").append(time); } logger.trace(sb.toString()); } catch (Exception e) { } }
From source file:gov.nih.nci.cabig.caaers.utils.MethodParamsTrackerAspect.java
License:BSD License
@Around("execution(public * gov.nih.nci.cabig.caaers.dao..*.merge*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.dao..*.reassociate*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.dao..*.lock*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.dao..*.save*(..))" + "|| execution(public * gov.nih.nci.cabig.caaers.dao..*.update*(..))") public Object captureParams(ProceedingJoinPoint call) throws Throwable { MethodParamsHolder.setParams(call.getArgs()); return call.proceed(); }
From source file:gov.nih.nci.cabig.ctms.acegi.csm.aop.DomainObjectOwnershipAssigner.java
License:BSD License
public Object assignOwner(ProceedingJoinPoint pjp, Object id) throws Throwable { Object domainObject = pjp.getArgs()[0]; // Object id = pjp.proceed(); String owner = SecurityContextHolder.getContext().getAuthentication().getName(); String objectId = generateId(domainObject, id); ProtectionElement pe = new ProtectionElement(); pe.setProtectionElementName(objectId); pe.setObjectId(objectId);//from w w w. java 2 s . c om getCsmAuthorizationManager().createProtectionElement(pe); getCsmAuthorizationManager().setOwnerForProtectionElement(objectId, new String[] { owner }); return id; }
From source file:gov.nih.nci.cabig.ctms.acegi.csm.authorization.CSMPrivilegeAndObjectRetrievalStrategy.java
License:BSD License
public PrivilegeAndObject retrieve(ProceedingJoinPoint pjp) { PrivilegeAndObject pao = null;//from w w w . j a v a 2 s . co m for (SignatureToPrivilegeMapping mapping : getMappings()) { if (mapping.matches(pjp.getSignature())) { Object[] args = pjp.getArgs(); Object object = getDomainObject(args); String privilege = mapping.getPrivilege(); pao = new PrivilegeAndObject(privilege, object); break; } } return pao; }
From source file:gov.nih.nci.ncicb.tcga.dcc.common.aspect.cache.CacheAspect.java
@Around("cache()") public Object aroundCachedMethods(ProceedingJoinPoint thisJoinPoint) throws Throwable { // generate the key under which cached value is stored // will look like package.class.method(arg1=val1;arg2=val2;) StringBuilder keyBuff = new StringBuilder(); // append name of the class keyBuff.append(thisJoinPoint.getTarget().getClass().getName()); // append name of the method keyBuff.append(".").append(thisJoinPoint.getSignature().getName()); keyBuff.append("("); // find method arguments for (final Object arg : thisJoinPoint.getArgs()) { // append argument type and value keyBuff.append(arg.getClass().getSimpleName() + "=" + arg + ";"); }/*from ww w . j a va 2s . c o m*/ keyBuff.append(")"); String key = keyBuff.toString(); Element element = cache.get(key); if (element == null) { logger.info("[" + Thread.currentThread().getId() + "] Result not yet cached for " + key + " let's proceed"); // Synchronizing calls to only getUUIDRows API. Because calling multiple getUUIDRows at the same time // might take more memory if (key.contains("UUIDBrowserDAOImpl.getUUIDRows()")) { synchronized (refreshDataLock) { // doing this one more time so that the threads that are waiting in this lock, will // use the cache instead of db element = cache.get(key); if (element == null) { element = storeDataInCache(thisJoinPoint, key); } } } else { element = storeDataInCache(thisJoinPoint, key); } } return (element != null) ? element.getValue() : null; }