Redirecting call to a stub with aspectj

View: New views
3 Messages — Rating Filter:   Alert me  

Redirecting call to a stub with aspectj

by Kristof Jozsa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'd like to use aspectj to intercept EJB calls and redirect the calls (if needed based on the interceptor configuration) to plain classes used as stubs. My question if it's possible to retrieve the exact arguments needed to find the correct method with the same signature on the stub class for a successful invokation.

I saw that thisJoinPointStaticPart.getSignature() includes the name of the class and the method getting intercepted, but what about the arguments types? For reflection I'd need all argument type classes to find the same signature method  - or is it any other way to get around this task besides reflection? Maybe I could alter the invocation context replacing the current target with the stub class and proceed with the call?

Thanks,
K

_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Re: Redirecting call to a stub with aspectj

by Andy Clement :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

how about this:

before(): execution(* C.foo(..)) {
        MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
        Class[] clazzes = sig.getParameterTypes();
        for (Class clazz: clazzes) {
                System.out.println(clazz.getName());
        }
}

Andy

2009/9/21 Kristof Jozsa <kristof.jozsa@...>:

> Hi,
>
> I'd like to use aspectj to intercept EJB calls and redirect the calls (if
> needed based on the interceptor configuration) to plain classes used as
> stubs. My question if it's possible to retrieve the exact arguments needed
> to find the correct method with the same signature on the stub class for a
> successful invokation.
>
> I saw that thisJoinPointStaticPart.getSignature() includes the name of the
> class and the method getting intercepted, but what about the arguments
> types? For reflection I'd need all argument type classes to find the same
> signature method  - or is it any other way to get around this task besides
> reflection? Maybe I could alter the invocation context replacing the current
> target with the stub class and proceed with the call?
>
> Thanks,
> K
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Re: Redirecting call to a stub with aspectj

by Kristof Jozsa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the quick answer, that made the trick. I didn't realize there's a subclass I can cast Signature to, but it makes sense now.

K

On Mon, Sep 21, 2009 at 8:45 PM, Andy Clement <andrew.clement@...> wrote:
how about this:

before(): execution(* C.foo(..)) {
       MethodSignature sig = (MethodSignature)thisJoinPoint.getSignature();
       Class[] clazzes = sig.getParameterTypes();
       for (Class clazz: clazzes) {
               System.out.println(clazz.getName());
       }
}

Andy

2009/9/21 Kristof Jozsa <kristof.jozsa@...>:
> Hi,
>
> I'd like to use aspectj to intercept EJB calls and redirect the calls (if
> needed based on the interceptor configuration) to plain classes used as
> stubs. My question if it's possible to retrieve the exact arguments needed
> to find the correct method with the same signature on the stub class for a
> successful invokation.
>
> I saw that thisJoinPointStaticPart.getSignature() includes the name of the
> class and the method getting intercepted, but what about the arguments
> types? For reflection I'd need all argument type classes to find the same
> signature method  - or is it any other way to get around this task besides
> reflection? Maybe I could alter the invocation context replacing the current
> target with the stub class and proceed with the call?
>
> Thanks,
> K
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@...
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users


_______________________________________________
aspectj-users mailing list
aspectj-users@...
https://dev.eclipse.org/mailman/listinfo/aspectj-users