List of usage examples for org.aspectj.lang ProceedingJoinPoint proceed
public Object proceed(Object[] args) throws Throwable;
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.//from w w w . ja va2s . 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.utest.domain.service.cache.CachedContextManager.java
License:Apache License
@Around(value = "@annotation(com.utest.annotations.CacheEvent) && @annotation(cacheEvent)") public Object processCacheEvent(final ProceedingJoinPoint joinPoint, final CacheEvent cacheEvent) throws Throwable { if (CacheEvent.CACHE_READ.equals(cacheEvent.operation())) { return checkCache(joinPoint, cacheEvent); }//from w w w .j a va 2 s. com final Object ret = joinPoint.proceed(joinPoint.getArgs()); if (CacheEvent.CACHE_REFRESH.equals(cacheEvent.operation())) { cleanCache(joinPoint, cacheEvent); } return ret; }
From source file:com.utest.domain.service.cache.CachedContextManager.java
License:Apache License
@SuppressWarnings("unchecked") private Object checkCache(final ProceedingJoinPoint joinPoint, final CacheEvent cacheEvent) throws Throwable { final Object[] args = joinPoint.getArgs(); Object cachedValue = null;/*from w w w. jav a 2s . c o m*/ if (CacheEvent.USER_MATCHING.equals(cacheEvent.type())) { final Integer userId = getUserFromArgs(args); if (userId != null) { cachedValue = holder.getTestCyclesForUser(userId); if (cachedValue == null) { cachedValue = joinPoint.proceed(args); holder.updateUserTestCycles(userId, (List<Integer>) cachedValue); } } } return cachedValue; }
From source file:com.willowtreeapps.respeeker.ResPeeker.java
License:Apache License
@Around("setOnTouchListener()") public Object aroundSetOnTouchListener(ProceedingJoinPoint joinPoint) throws Throwable { final View.OnTouchListener originalTouchListener = (View.OnTouchListener) joinPoint.getArgs()[0]; final View.OnTouchListener interceptTouchListener = getTouchListener(); View.OnTouchListener delegateTouchListener = new View.OnTouchListener() { @Override// ww w. j a v a 2 s . c o m public boolean onTouch(View v, MotionEvent event) { interceptTouchListener.onTouch(v, event); return originalTouchListener != null && originalTouchListener.onTouch(v, event); } }; return joinPoint.proceed(new Object[] { delegateTouchListener }); }
From source file:com.zhaimi.message.aop.AbstractSendMessageAdvice.java
License:Apache License
/** * SendMsg //from www . j a v a2 s. co m * @param pjp * @return * @throws Throwable */ public Object around(ProceedingJoinPoint pjp) throws Throwable { Object result = null; Method method = getMethod(pjp); String beforeTopic = getBeforeSendMsgTopicOnMethod(method); Object[] args = pjp.getArgs(); if (beforeTopic != null) { // if(log.isDebugEnabled()) // log.debug("BeforeTopic='{}',Method={} " ,beforeTopic, method); sendMessageBefore(method, beforeTopic, args); } String afterTopic = getAfterSendMsgTopicOnMethod(method); try { //? result = pjp.proceed(args); if (afterTopic != null) { // if(log.isDebugEnabled()) // log.debug("AfterTopic='{}', Method {}" ,afterTopic, method); sendMessageAfter(method, afterTopic, args, result); } } catch (Throwable e) { // if(log.isDebugEnabled()) // log.debug("sendMessageAfterException exception " + e); try { sendMessageAfterException(method, afterTopic, args, e); } catch (Throwable t) { /* do nothing */ } throw e; } if (log.isDebugEnabled()) log.debug("SendMsgBeforeInvokeAdvice result " + result); return result; }
From source file:cs544.videohouse.util.Welcome.java
@Around("execution(* cs544.videohouse.controller.VideoController.checkUploadVideo(..))") public String greet(ProceedingJoinPoint call) throws Throwable { Object[] args = call.getArgs(); // User u=(User) args[0]; // System.out.println("Before: Hi "+u.getFirstName()+"!"); String view = (String) call.proceed(args); // args= call.getArgs(); // u=(User) args[0]; if (view.contains("#")) { rId = Integer.valueOf(view.split("#")[2]); recentUpload = "Latest: " + view.split("#")[1] + "!"; view = view.split("#")[0]; }/*from w w w .j a v a 2s .c o m*/ System.out.println("Will go next to: " + view); System.out.println("Latest:" + recentUpload); return view; }
From source file:de.cosmocode.palava.core.aop.PalavaAspect.java
License:Apache License
/** * An advice around {@link Guice#createInjector(Module...)} to inject members on this aspect. * * @param point the proceeding joint point * @param modules the originally passed modules * @return the injector//from w w w . j a v a 2s. co m * @since 2.9 */ @Around("include() && moduleArray(modules)") public Object aroundModuleArray(ProceedingJoinPoint point, Module... modules) { try { return point.proceed(new Object[] { append(modules) }); /* CHECKSTYLE:OFF */ } catch (Throwable e) { /* CHECKSTYLE:ON */ throw Throwables.sneakyThrow(e); } }
From source file:de.cosmocode.palava.core.aop.PalavaAspect.java
License:Apache License
/** * An advice around {@link Guice#createInjector(Iterable)} to inject members on this aspect. * * @param point the proceeding joint point * @param modules the originally passed modules * @return the injector/*from w ww .ja va 2s . c o m*/ * @since 2.9 */ @Around("include() && moduleIterable(modules)") public Object aroundModuleIterable(ProceedingJoinPoint point, Iterable modules) { try { return point.proceed(new Object[] { Iterables.concat(modules, Collections.singleton(module)) }); /* CHECKSTYLE:OFF */ } catch (Throwable e) { /* CHECKSTYLE:ON */ throw Throwables.sneakyThrow(e); } }
From source file:de.cosmocode.palava.core.aop.PalavaAspect.java
License:Apache License
/** * An advice around {@link Guice#createInjector(Stage, Module...)} to inject members on this aspect. * * @param point the proceeding joint point * @param stage the originally passed stage * @param modules the originally passed modules * @return the injector//from ww w. j a v a 2 s . c om * @since 2.9 */ @Around("include() && stageAndModuleArray(stage, modules)") public Object aroundStageAndModuleArray(ProceedingJoinPoint point, Stage stage, Module... modules) { try { return point.proceed(new Object[] { stage, append(modules) }); /* CHECKSTYLE:OFF */ } catch (Throwable e) { /* CHECKSTYLE:ON */ throw Throwables.sneakyThrow(e); } }
From source file:de.cosmocode.palava.core.aop.PalavaAspect.java
License:Apache License
/** * An advice around {@link Guice#createInjector(Stage, Iterable)} to inject members on this aspect. * * @param point the proceeding joint point * @param stage the originally passed stage * @param modules the originally passed stage * @return the injector//from w ww. j av a 2s. c o m * @since 2.9 */ @Around("include() && stageAndModuleIterable(stage, modules)") public Object aroundStageAndModuleIterable(ProceedingJoinPoint point, Stage stage, Iterable modules) { try { return point.proceed(new Object[] { stage, Iterables.concat(modules, Collections.singleton(module)) }); /* CHECKSTYLE:OFF */ } catch (Throwable e) { /* CHECKSTYLE:ON */ throw Throwables.sneakyThrow(e); } }