Example usage for org.aspectj.runtime.reflect Factory makeEncSJP

List of usage examples for org.aspectj.runtime.reflect Factory makeEncSJP

Introduction

In this page you can find the example usage for org.aspectj.runtime.reflect Factory makeEncSJP.

Prototype

public static JoinPoint.StaticPart makeEncSJP(Member member) 

Source Link

Usage

From source file:org.springframework.aop.aspectj.MethodInvocationProceedingJoinPointTests.java

License:Apache License

@Test
public void toShortAndLongStringFormedCorrectly() throws Exception {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
        @Override//from w w w  . j a v a 2 s . com
        public void before(Method method, Object[] args, 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());
        }
    });
    ITestBean itb = (ITestBean) pf.getProxy();
    itb.getAge();
    itb.setName("foo");
    itb.getDoctor();
    itb.getStringArray();
    itb.getSpouses();
    itb.setSpouse(new TestBean());
    try {
        itb.unreliableFileOperation();
    } catch (IOException ex) {
        // we don't realy care...
    }
}