@Override public Object getTarget() { return jp.getTarget(); }
public static <T extends Annotation> Optional<T> getAnnotation(JoinPoint joinPoint, Class<T> annotation) { return getAnnotation(joinPoint.getTarget().getClass(), annotation); }
public static <T extends Annotation> T findAnnotation(JoinPoint pjp, Class<T> annClass) { MethodSignature signature = (MethodSignature) pjp.getSignature(); Method m = signature.getMethod(); Class<?> targetClass = pjp.getTarget().getClass(); return findAnnotation(targetClass, m, annClass); }
/** * Gets a {@link Method} object from target object by specified method name. * * @param joinPoint the {@link JoinPoint} * @param methodName the method name * @return a {@link Method} object or null if method with specified <code>methodName</code> doesn't exist */ public static Method getMethodFromTarget(JoinPoint joinPoint, String methodName) { return getDeclaredMethod(joinPoint.getTarget().getClass(), methodName, getParameterTypes(joinPoint)); }
private static Method getAjcMethodFromTarget(JoinPoint joinPoint) { return getAjcMethodAroundAdvice(joinPoint.getTarget().getClass(), (MethodSignature) joinPoint.getSignature()); }
@Before("this(org.mp4parser.support.AbstractBox) && ((execution(public * * (..)) && !( " + "execution(* parseDetails()) || " + "execution(* getNumOfBytesToFirstChild()) || " + "execution(* getType()) || " + "execution(* isParsed()) || " + "execution(* getHeader(*)) || " + "execution(* parse()) || " + "execution(* getBox(*)) || " + "execution(* getSize()) || " + "execution(* getOffset()) || " + "execution(* setOffset(*)) || " + "execution(* parseDetails()) || " + "execution(* _parseDetails(*)) || " + "execution(* parse(*,*,*,*)) || " + "execution(* getIsoFile()) || " + "execution(* getParent()) || " + "execution(* setParent(*)) || " + "execution(* getUserType()) || " + "execution(* setUserType(*))) && " + "!@annotation(org.mp4parser.support.DoNotParseDetail)) || @annotation(org.mp4parser.support.ParseDetail))") public void before(JoinPoint joinPoint) { if (joinPoint.getTarget() instanceof AbstractBox) { if (!((AbstractBox) joinPoint.getTarget()).isParsed()) { //System.err.println(String.format("parsed detail %s", joinPoint.getTarget().getClass().getSimpleName())); ((AbstractBox) joinPoint.getTarget()).parseDetails(); } } else { throw new RuntimeException("Only methods in subclasses of " + AbstractBox.class.getName() + " can be annotated with ParseDetail"); } }
public void onError(JoinPoint jp, StepExecution stepExecution, Throwable t) { String msg = "Error in: " + jp.toShortString() + " with: " + stepExecution + " (" + t.getClass() + ":" + t.getMessage() + ")"; publish(jp.getTarget(), msg); }
public void before(JoinPoint jp, StepExecution stepExecution) { String msg = "Before: " + jp.toShortString() + " with: " + stepExecution; publish(jp.getTarget(), msg); }
public void after(JoinPoint jp, StepExecution stepExecution) { String msg = "After: " + jp.toShortString() + " with: " + stepExecution; publish(jp.getTarget(), msg); }
/** * Performs the method interception of the before advice at the specified joint point. * * @param aJoinPoint The joint point to intercept. * @throws Throwable If an error occurs berforming the method invocation. */ protected void performBeforeInterception(JoinPoint aJoinPoint) throws Throwable { if (log.isTraceEnabled()) log.trace("#### Invoking a method decorated with a Shiro annotation" + "\n\tkind : " + aJoinPoint.getKind() + "\n\tjoinPoint : " + aJoinPoint + "\n\tannotations: " + Arrays.toString(((MethodSignature) aJoinPoint.getSignature()).getMethod().getAnnotations()) + "\n\ttarget : " + aJoinPoint.getTarget() ); // 1. Adapt the join point into a method invocation BeforeAdviceMethodInvocationAdapter mi = BeforeAdviceMethodInvocationAdapter.createFrom(aJoinPoint); // 2. Delegate the authorization of the method call to the super class super.invoke(mi); } }
@After("onViewCreated()") public void onViewCreatedProcess(JoinPoint joinPoint) throws Throwable { Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onCreate = getRiggerMethod("onViewCreated", Object.class, View.class, Bundle.class); onCreate.invoke(getRiggerInstance(), puppet, args[0], args[1]); }
public void doBasicLogging(JoinPoint pjp) throws Throwable { Object[] args = pjp.getArgs(); StringBuilder output = new StringBuilder(); output.append(pjp.getTarget().getClass().getName()).append(": "); output.append(pjp.toShortString()).append(": "); for (Object arg : args) { output.append(arg).append(" "); } log.info("Basic: " + output.toString()); }
/** * Gets a {@link Method} object from target object (not proxy class). * * @param joinPoint the {@link JoinPoint} * @return a {@link Method} object or null if method doesn't exist or if the signature at a join point * isn't sub-type of {@link MethodSignature} */ public static Method getMethodFromTarget(JoinPoint joinPoint) { Method method = null; if (joinPoint.getSignature() instanceof MethodSignature) { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); method = getDeclaredMethod(joinPoint.getTarget().getClass(), signature.getName(), getParameterTypes(joinPoint)); } return method; }
if (correspondingGetter != null) { try { Object oldValue = correspondingGetter.invoke(jp.getTarget());
public void onError(JoinPoint jp, StepExecution stepExecution, Throwable t) { String msg = "Error in: " + jp.toShortString() + " with: " + stepExecution + " (" + t.getClass() + ":" + t.getMessage() + ")"; publish(jp.getTarget(), msg); }
MethodInvocationAdapter(JoinPoint jp) { this.jp = (ProceedingJoinPoint) jp; if (jp.getTarget() != null) { target = jp.getTarget(); } else { // SEC-1295: target may be null if an ITD is in use target = jp.getSignature().getDeclaringType(); } String targetMethodName = jp.getStaticPart().getSignature().getName(); Class<?>[] types = ((CodeSignature) jp.getStaticPart().getSignature()) .getParameterTypes(); Class<?> declaringType = jp.getStaticPart().getSignature().getDeclaringType(); method = findMethod(targetMethodName, declaringType, types); if (method == null) { throw new IllegalArgumentException( "Could not obtain target method from JoinPoint: '" + jp + "'"); } }
MethodInvocationAdapter(JoinPoint jp) { this.jp = (ProceedingJoinPoint) jp; if (jp.getTarget() != null) { target = jp.getTarget(); } else { // SEC-1295: target may be null if an ITD is in use target = jp.getSignature().getDeclaringType(); } String targetMethodName = jp.getStaticPart().getSignature().getName(); Class<?>[] types = ((CodeSignature) jp.getStaticPart().getSignature()) .getParameterTypes(); Class<?> declaringType = jp.getStaticPart().getSignature().getDeclaringType(); method = findMethod(targetMethodName, declaringType, types); if (method == null) { throw new IllegalArgumentException( "Could not obtain target method from JoinPoint: '" + jp + "'"); } }
public void before(JoinPoint jp, StepExecution stepExecution) { String msg = "Before: " + jp.toShortString() + " with: " + stepExecution; publish(jp.getTarget(), msg); }
public void after(JoinPoint jp, StepExecution stepExecution) { String msg = "After: " + jp.toShortString() + " with: " + stepExecution; publish(jp.getTarget(), msg); }