Java Code Examples for org.aspectj.lang.ProceedingJoinPoint#getTarget()
The following examples show how to use
org.aspectj.lang.ProceedingJoinPoint#getTarget() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoTrackingAspect.java From secure-data-service with Apache License 2.0 | 6 votes |
@Around("call(* com.mongodb.DBCollection.*(..)) && !this(MongoTrackingAspect) && !within(org..*Test) && !within(org..*MongoPerfRepository)") public Object trackDBCollection(ProceedingJoinPoint pjp) throws Throwable { long start = System.currentTimeMillis(); Object result = pjp.proceed(); long end = System.currentTimeMillis(); if (isEnabled()) { DBCollection col = (DBCollection) pjp.getTarget(); proceedAndTrack(pjp, col.getDB().getName(), pjp.getSignature().getName(), col.getName(), start, end); } if (Boolean.valueOf(dbCallTracking)) { dbCallTracker.incrementHitCount(); // dbCallTracker.addMetric("t", pjp.getSignature().toShortString(), end-start); } return result; }
Example 2
Source File: GuardAspect2.java From oval with Eclipse Public License 2.0 | 6 votes |
@Around("execution((@net.sf.oval.guard.Guarded *).new(..))") public Object allConstructors(final ProceedingJoinPoint thisJoinPoint) throws Throwable { // CHECKSTYLE:IGNORE IllegalThrow final ConstructorSignature signature = (ConstructorSignature) thisJoinPoint.getSignature(); LOG.debug("aroundConstructor() {1}", signature); final Constructor<?> ctor = signature.getConstructor(); final Object[] args = thisJoinPoint.getArgs(); final Object target = thisJoinPoint.getTarget(); // pre conditions { guard.guardConstructorPre(target, ctor, args); } final Object result = thisJoinPoint.proceed(); // post conditions { guard.guardConstructorPost(target, ctor, args); } return result; }
Example 3
Source File: RateLimiterAspect.java From resilience4j with Apache License 2.0 | 5 votes |
@Nullable private RateLimiter getRateLimiterAnnotation(ProceedingJoinPoint proceedingJoinPoint) { if (proceedingJoinPoint.getTarget() instanceof Proxy) { logger.debug( "The rate limiter annotation is kept on a interface which is acting as a proxy"); return AnnotationExtractor .extractAnnotationFromProxy(proceedingJoinPoint.getTarget(), RateLimiter.class); } else { return AnnotationExtractor .extract(proceedingJoinPoint.getTarget().getClass(), RateLimiter.class); } }
Example 4
Source File: ActivityInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("onBackPressed()") public Object onBackPressedProcess(ProceedingJoinPoint joinPoint) throws Throwable { // Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Method onBackPressed = getRiggerMethod("onBackPressed", Object.class); return onBackPressed.invoke(getRiggerInstance(), puppet); }
Example 5
Source File: TraceActivity.java From ArgusAPM with Apache License 2.0 | 5 votes |
@Around("activityOnXXX()") public Object activityOnXXXAdvice(ProceedingJoinPoint proceedingJoinPoint) { Object result = null; try { Activity activity = (Activity) proceedingJoinPoint.getTarget(); // Log.d("AJAOP", "Aop Info" + activity.getClass().getCanonicalName() + // "\r\nkind : " + thisJoinPoint.getKind() + // "\r\nargs : " + thisJoinPoint.getArgs() + // "\r\nClass : " + thisJoinPoint.getClass() + // "\r\nsign : " + thisJoinPoint.getSignature() + // "\r\nsource : " + thisJoinPoint.getSourceLocation() + // "\r\nthis : " + thisJoinPoint.getThis() // ); long startTime = System.currentTimeMillis(); result = proceedingJoinPoint.proceed(); String activityName = activity.getClass().getCanonicalName(); Signature signature = proceedingJoinPoint.getSignature(); String sign = ""; String methodName = ""; if (signature != null) { sign = signature.toString(); methodName = signature.getName(); } if (!TextUtils.isEmpty(activityName) && !TextUtils.isEmpty(sign) && sign.contains(activityName)) { invoke(activity, startTime, methodName, sign); } } catch (Exception e) { e.printStackTrace(); } catch (Throwable throwable) { throwable.printStackTrace(); } return result; }
Example 6
Source File: ActivityInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("construct()") public Object constructProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Method onAttach = getRiggerMethod("onPuppetConstructor", Object.class); onAttach.invoke(getRiggerInstance(), puppet); return result; }
Example 7
Source File: ActivityInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("onSaveInstanceState()") public Object onSaveInstanceStateProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onSaveInstanceState = getRiggerMethod("onSaveInstanceState", Object.class, Bundle.class); onSaveInstanceState.invoke(getRiggerInstance(), puppet, args[0]); return result; }
Example 8
Source File: Auditor.java From jdal with Apache License 2.0 | 5 votes |
/** * Around advice to audit auditable models * * @param pjp to pjp * @return object result * @throws Throwable Exception */ public Object audit(ProceedingJoinPoint pjp) throws Throwable { LOG.debug("Auditing on method: " + pjp.toShortString()); Object result = pjp.proceed(); if (pjp.getTarget() instanceof Auditable) { Auditable auditable = (Auditable) (pjp.getTarget()); audit(auditable); } else { LOG.warn("Tried to audit a non-auditable object. Check your " + "AOP configuration on applicationContext.xml"); } return result; }
Example 9
Source File: ExecutorGrayAspect.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@Around("pointCut(command)") public Object executeAround(ProceedingJoinPoint joinpoint, Runnable command) throws Throwable { if (joinpoint.getTarget() instanceof GrayExecutor || joinpoint.getTarget() instanceof GrayExecutorService || command instanceof GrayRunnable) { return joinpoint.proceed(); } Runnable runnable = GrayConcurrentHelper.createDelegateRunnable(command); return joinpoint.proceed(new Object[]{runnable}); }
Example 10
Source File: RetryAspect.java From resilience4j with Apache License 2.0 | 5 votes |
/** * @param proceedingJoinPoint the aspect joint point * @return the retry annotation */ @Nullable private Retry getRetryAnnotation(ProceedingJoinPoint proceedingJoinPoint) { if (proceedingJoinPoint.getTarget() instanceof Proxy) { logger.debug("The retry annotation is kept on a interface which is acting as a proxy"); return AnnotationExtractor .extractAnnotationFromProxy(proceedingJoinPoint.getTarget(), Retry.class); } else { return AnnotationExtractor .extract(proceedingJoinPoint.getTarget().getClass(), Retry.class); } }
Example 11
Source File: ExecutorServiceGrayAspect.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@Around("invokeAllOrAnyPointCut(tasks)") public <V> Object invokeAllOrAnyAround(ProceedingJoinPoint joinpoint, Collection<? extends Callable<V>> tasks) throws Throwable { if (joinpoint.getTarget() instanceof GrayExecutorService) { return joinpoint.proceed(); } return joinpoint.proceed(new Object[]{GrayConcurrentHelper.mapDelegateCallables(tasks)}); }
Example 12
Source File: FeignTracingAutoConfiguration.java From java-spring-cloud with Apache License 2.0 | 5 votes |
@Around("execution (* feign.Client.*(..)) && !within(is(FinalType))") public Object feignClientWasCalled(final ProceedingJoinPoint pjp) throws Throwable { Object bean = pjp.getTarget(); if (!(bean instanceof TracingClient)) { Object[] args = pjp.getArgs(); return new TracingClientBuilder((Client) bean, tracer) .withFeignSpanDecorators(spanDecorators) .build() .execute((Request) args[0], (Request.Options) args[1]); } return pjp.proceed(); }
Example 13
Source File: FragmentInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("onSaveInstanceState()") public Object onSaveInstanceStateProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onSaveInstanceState = getRiggerMethod("onSaveInstanceState", Object.class, Bundle.class); onSaveInstanceState.invoke(getRiggerInstance(), puppet, args[0]); return result; }
Example 14
Source File: FragmentInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("setUserVisibleHint()") public Object setUserVisibleHintProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onDestroy = getRiggerMethod("setUserVisibleHint", Object.class, boolean.class); onDestroy.invoke(getRiggerInstance(), puppet, args[0]); return result; }
Example 15
Source File: DynamicDataSourceChangeAdvice.java From framework with Apache License 2.0 | 5 votes |
/** * Description: <br> * * @author 王伟<br> * @taskId <br> * @param joinPoint * @return Object * @throws Throwable <br> */ @Around("change()") public Object around(final ProceedingJoinPoint joinPoint) throws Throwable { MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); DataSource dataSource = method.getDeclaredAnnotation(DataSource.class); if (dataSource != null) { DynamicDataSourceManager.setDataSourceCode(dataSource.value()); } else { Object target = joinPoint.getTarget(); dataSource = target.getClass().getDeclaredAnnotation(DataSource.class); if (dataSource != null) { DynamicDataSourceManager.setDataSourceCode(dataSource.value()); } } try { return joinPoint.proceed(); } finally { if (dataSource != null) { DynamicDataSourceManager.setDataSourceCode(DynamicDataSourceManager.DEFAULT_DATASOURCE_CODE); } } }
Example 16
Source File: ActivityInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("onResume()") public Object onResumeProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Method onPause = getRiggerMethod("onResume", Object.class); onPause.invoke(getRiggerInstance(), puppet); return result; }
Example 17
Source File: ActivityInjection.java From FragmentRigger with MIT License | 5 votes |
@Around("onCreate()") public Object onCreateProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onCreate = getRiggerMethod("onCreate", Object.class, Bundle.class); onCreate.invoke(getRiggerInstance(), puppet, args[0]); return result; }
Example 18
Source File: RetryAop.java From sisyphus with Apache License 2.0 | 5 votes |
/** * 获取当前方法信息 * * @param point 切点 * @return 方法 */ private Method getCurrentMethod(ProceedingJoinPoint point) { try { Signature sig = point.getSignature(); MethodSignature msig = (MethodSignature) sig; Object target = point.getTarget(); return target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); } catch (NoSuchMethodException e) { throw new RetryException(e); } }
Example 19
Source File: RateLimiterAspect.java From SnowJena with Apache License 2.0 | 5 votes |
@Around("pointcut() && @annotation(limiter)") public Object around(ProceedingJoinPoint pjp, Limiter limiter) throws Throwable { cn.yueshutong.core.limiter.RateLimiter rateLimiter = RateLimiterObserver.getMap().get(limiter.value()); if (rateLimiter.tryAcquire()) { return pjp.proceed(); } Signature sig = pjp.getSignature(); if (!(sig instanceof MethodSignature)) { throw new IllegalArgumentException("This annotation can only be used in methods."); } MethodSignature msg = (MethodSignature) sig; Object target = pjp.getTarget(); Method fallback = target.getClass().getMethod(limiter.fallback(), msg.getParameterTypes()); return fallback.invoke(target,pjp.getArgs()); }
Example 20
Source File: IbisDebuggerAdvice.java From iaf with Apache License 2.0 | 4 votes |
private <M> M debugSenderInputOutputAbort(ProceedingJoinPoint proceedingJoinPoint, Message message, IPipeLineSession session, int messageParamIndex) throws Throwable { if (!isEnabled()) { return (M)proceedingJoinPoint.proceed(); } ISender sender = (ISender)proceedingJoinPoint.getTarget(); if (!sender.isSynchronous() && sender instanceof JmsSender) { // Ignore JmsSenders within JmsListeners (calling JmsSender without ParameterResolutionContext) within Receivers. return (M)proceedingJoinPoint.proceed(); } String messageId = session == null ? null : session.getMessageId(); message = ibisDebugger.senderInput(sender, messageId, message); M result = null; // result can be PipeRunResult (for StreamingSenders) or Message (for all other Senders) // For SenderWrapperBase continue even when it needs to be stubbed // because for SenderWrapperBase this will be checked when it calls // sendMessage on his senderWrapperProcessor, hence // debugSenderGetInputFrom will be called. if (!ibisDebugger.stubSender(sender, messageId) || sender instanceof SenderWrapperBase) { try { Object[] args = proceedingJoinPoint.getArgs(); args[messageParamIndex] = message; result = (M)proceedingJoinPoint.proceed(args); } catch(Throwable throwable) { throw ibisDebugger.senderAbort(sender, messageId, throwable); } } else { // Resolve parameters so they will be added to the report like when the sender was not stubbed and would // resolve parameters itself if (sender instanceof IWithParameters) { ParameterList parameterList = ((IWithParameters)sender).getParameterList(); if (parameterList!=null) { parameterList.getValues(message, session); } } } if (sender instanceof SenderWrapperBase && ((SenderWrapperBase)sender).isPreserveInput()) { // signal in the debugger that the result of the sender has been replaced with the original input result = (M)ibisDebugger.preserveInput(messageId, (Message)result); } if (result!=null && result instanceof PipeRunResult) { PipeRunResult prr = (PipeRunResult)result; prr.setResult(ibisDebugger.senderOutput(sender, messageId, prr.getResult())); return result; } return (M)ibisDebugger.senderOutput(sender, messageId, Message.asMessage(result)); }