/** * Overridden in around advice to return proceeding join point. */ protected JoinPoint getJoinPoint() { return currentJoinPoint(); }
@Test public void testingBindingWithJoinPoint() { try { AbstractAspectJAdvice.currentJoinPoint(); fail("Needs to be bound by interceptor action"); } catch (IllegalStateException ex) { // expected } }
@Test public void testingBindingWithProceedingJoinPoint() { try { AbstractAspectJAdvice.currentJoinPoint(); fail("Needs to be bound by interceptor action"); } catch (IllegalStateException ex) { // expected } }
@Override public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart(); assertEquals("Same static part must be returned on subsequent requests", staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart()); assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind()); assertSame(AbstractAspectJAdvice.currentJoinPoint().getSignature(), staticPart.getSignature()); assertEquals(AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(), staticPart.getSourceLocation()); } });
@Override public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint(); assertTrue("Method named in toString", jp.toString().contains(method.getName())); jp.toLongString(); assertSame(target, AbstractAspectJAdvice.currentJoinPoint().getTarget()); assertFalse(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getTarget())); ITestBean thisProxy = (ITestBean) AbstractAspectJAdvice.currentJoinPoint().getThis(); assertTrue(AopUtils.isAopProxy(AbstractAspectJAdvice.currentJoinPoint().getThis())); assertSame(thisProxy, AbstractAspectJAdvice.currentJoinPoint().getThis()); assertSame(target, raw); assertSame(method.getName(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getName()); assertEquals(method.getModifiers(), AbstractAspectJAdvice.currentJoinPoint().getSignature().getModifiers()); MethodSignature msig = (MethodSignature) AbstractAspectJAdvice.currentJoinPoint().getSignature(); assertSame("Return same MethodSignature repeatedly", msig, AbstractAspectJAdvice.currentJoinPoint().getSignature()); assertSame("Return same JoinPoint repeatedly", AbstractAspectJAdvice.currentJoinPoint(), AbstractAspectJAdvice.currentJoinPoint()); assertEquals(method.getDeclaringClass(), msig.getDeclaringType()); assertTrue(Arrays.equals(method.getParameterTypes(), msig.getParameterTypes()));
@Override public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation(); assertEquals("Same source location must be returned on subsequent requests", sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation()); assertEquals(TestBean.class, sloc.getWithinType()); try { sloc.getLine(); fail("Can't get line number"); } catch (UnsupportedOperationException ex) { // Expected } try { sloc.getFileName(); fail("Can't get file name"); } catch (UnsupportedOperationException ex) { // Expected } } });
@Override public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { // makeEncSJP, although meant for computing the enclosing join point, // it serves our purpose here JoinPoint.StaticPart aspectJVersionJp = Factory.makeEncSJP(method); JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint(); assertEquals(aspectJVersionJp.getSignature().toLongString(), jp.getSignature().toLongString()); assertEquals(aspectJVersionJp.getSignature().toShortString(), jp.getSignature().toShortString()); assertEquals(aspectJVersionJp.getSignature().toString(), jp.getSignature().toString()); assertEquals(aspectJVersionJp.toLongString(), jp.toLongString()); assertEquals(aspectJVersionJp.toShortString(), jp.toShortString()); assertEquals(aspectJVersionJp.toString(), jp.toString()); } });
/** * Overridden in around advice to return proceeding join point. */ protected JoinPoint getJoinPoint() { return currentJoinPoint(); }
/** * Overridden in around advice to return proceeding join point. */ protected JoinPoint getJoinPoint() { return currentJoinPoint(); }