List of usage examples for org.aspectj.lang ProceedingJoinPoint getTarget
Object getTarget();
From source file:org.biopax.validator.impl.ExceptionsAspect.java
License:Open Source License
@Around("execution(* org.biopax.paxtools.io.BioPAXIOHandler*+.convertFromOWL(*))") public Object adviseConvertFromOwl(ProceedingJoinPoint jp) { Object model = null;//w w w.j a va 2 s . c om try { model = jp.proceed(); } catch (Throwable ex) { reportException(ex, jp.getTarget(), "syntax.error", "BioPAXIOHandler.convertFromOWL interceptor", null); } return model; }
From source file:org.broadleafcommerce.common.vendor.service.cache.ServiceResponseCache.java
License:Apache License
public Object processRequest(ProceedingJoinPoint call) throws Throwable { CacheRequest cacheRequest = (CacheRequest) call.getArgs()[0]; Cache cache = ((ServiceResponseCacheable) call.getTarget()).getCache(); List<Serializable> cacheItemResponses = new ArrayList<Serializable>(); Iterator<CacheItemRequest> itr = cacheRequest.getCacheItemRequests().iterator(); while (itr.hasNext()) { CacheItemRequest itemRequest = itr.next(); if (cache.isKeyInCache(itemRequest.key())) { cacheItemResponses.add(cache.get(itemRequest.key()).getValue()); itr.remove();/*from ww w . j a v a 2s . c o m*/ } } CacheResponse returnValue = (CacheResponse) call.proceed(); Object[] responses = new Object[cacheItemResponses.size() + returnValue.getCacheItemResponses().length]; responses = cacheItemResponses.toArray(responses); for (int j = 0; j < returnValue.getCacheItemResponses().length; j++) { Element element = new Element(cacheRequest.getCacheItemRequests().get(j).key(), returnValue.getCacheItemResponses()[j]); cache.put(element); } System.arraycopy(returnValue.getCacheItemResponses(), 0, responses, cacheItemResponses.size(), returnValue.getCacheItemResponses().length); returnValue.setCacheItemResponses(responses); return returnValue; }
From source file:org.codelabor.system.advices.SnifferAdvice.java
License:Apache License
public Object getElapsedTime(ProceedingJoinPoint joinPoint) throws Throwable { String className = joinPoint.getTarget().getClass().getName(); String methodName = joinPoint.getSignature().getName() + "()"; StopWatch stopWatch = new StopWatch(getClass().getName()); stopWatch.start(joinPoint.toShortString()); Object returnValue = joinPoint.proceed(); stopWatch.stop();// www . j a va2s . com StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append("class: ").append(className); stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append("method: ").append(methodName); stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append("total time (millis): ").append(stopWatch.getTotalTimeMillis()); log.debug(stringBuilder.toString()); return returnValue; }
From source file:org.codelabor.system.sniffer.advice.SniffingAdvice.java
License:Apache License
/** * ? ./*from w w w . jav a2 s.co m*/ * * @param joinPoint * ? ?? * @return * @throws Throwable * */ public Object dumpElapsedTime(ProceedingJoinPoint joinPoint) throws Throwable { Object retrunValue = null; StopWatch stopWatch = null; if (logger.isDebugEnabled()) { stopWatch = new StopWatch(getClass().getName()); stopWatch.start(joinPoint.toShortString()); } retrunValue = joinPoint.proceed(); if (logger.isDebugEnabled()) { stopWatch.stop(); long totalTimeMillis = stopWatch.getTotalTimeMillis(); logger.debug("class: {}", joinPoint.getTarget().getClass().getName()); logger.debug("method: {}", joinPoint.getSignature().getName()); logger.debug("total time (millis): {}", totalTimeMillis); } return retrunValue; }
From source file:org.codelabor.system.sniffer.advices.SnifferAdvice.java
License:Apache License
public Object getElapsedTime(ProceedingJoinPoint joinPoint) throws Throwable { Object returnValue = null;/*from w w w . ja va2 s . c o m*/ if (log.isDebugEnabled()) { String className = joinPoint.getTarget().getClass().getName(); String methodName = joinPoint.getSignature().getName() + "()"; StopWatch stopWatch = new StopWatch(getClass().getName()); stopWatch.start(joinPoint.toShortString()); returnValue = joinPoint.proceed(); stopWatch.stop(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append("class: ").append(className); stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append("method: ").append(methodName); stringBuilder.append(System.getProperty("line.separator")); stringBuilder.append("total time (millis): ").append(stopWatch.getTotalTimeMillis()); log.debug(stringBuilder.toString()); } return returnValue; }
From source file:org.codelabor.system.sniffer.aspect.SniffingAspect.java
License:Apache License
/** * ? .//w w w. ja v a 2s . co m * * @param joinPoint * ? ?? * @return * @throws Throwable * */ public void dumpElapsedTime(ProceedingJoinPoint joinPoint) throws Throwable { if (logger.isInfoEnabled()) { StopWatch stopWatch = new StopWatch(getClass().getName()); stopWatch.start(joinPoint.toShortString()); joinPoint.proceed(); stopWatch.stop(); long totalTimeMillis = stopWatch.getTotalTimeMillis(); logger.info("target: {}", joinPoint.getTarget().getClass().getName()); logger.info("signature: {}", joinPoint.getSignature().getName()); logger.info("total time millis: {}", totalTimeMillis); } }
From source file:org.craftercms.commons.logging.LoggedAspect.java
License:Open Source License
@Around("@within(org.craftercms.commons.logging.Logged) || @annotation(org.craftercms.commons.logging.Logged)") public Object logMethod(ProceedingJoinPoint pjp) throws Throwable { String className = pjp.getTarget().getClass().getName(); String methodName = pjp.getSignature().getName(); Object[] args = pjp.getArgs(); methodLogger.logEntry(className, methodName, args); try {/*from www .j a v a 2 s . com*/ Object returnValue = pjp.proceed(); methodLogger.logExit(className, methodName, returnValue); return returnValue; } catch (Throwable e) { methodLogger.logException(className, methodName, e); throw e; } }
From source file:org.craftercms.commons.security.permissions.annotations.HasPermissionAnnotationHandler.java
License:Open Source License
protected HasPermission getHasPermissionAnnotation(Method method, ProceedingJoinPoint pjp) { HasPermission hasPermission = method.getAnnotation(HasPermission.class); if (hasPermission == null) { Class<?> targetClass = pjp.getTarget().getClass(); hasPermission = targetClass.getAnnotation(HasPermission.class); }//from www.java 2 s . co m return hasPermission; }
From source file:org.cybercat.automation.core.DataProviderAspect.java
License:Apache License
public Object applyData(ProceedingJoinPoint pjp) throws AutomationFrameworkException { String methodName = pjp.getSignature().getName(); Method[] methods = pjp.getTarget().getClass().getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].getName().equals(methodName)) { System.out.println("found"); try { Object[] arg = createData(methods[i], pjp.getArgs()); return pjp.proceed(arg); } catch (Throwable e) { throw new PageObjectException(e); }// w ww. ja v a2s . c o m } } return null; }
From source file:org.cybercat.automation.core.integration.IntegrationServiceAspect.java
License:Apache License
public Object invoke(ProceedingJoinPoint pjp) throws Throwable { if (pjp.getTarget() instanceof IIntegrationService && hasSession) { sManager.putCookieSnapshot();//from ww w . j a v a 2 s. c o m Object result = pjp.proceed(); sManager.makeCookieSnapshot(); return result; } else { return pjp.proceed(); } }