Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Accessing the TargetSource from a MethodInterceptor

  1. #11
    Join Date
    Aug 2005
    Posts
    16

    Default

    Do you mean, how do you get the proxy? I got it using AopContext.currentProxy().

  2. #12
    Join Date
    Aug 2005
    Posts
    2

    Default Thanks...

    A little introduction to my situation:

    I am facing the same problem that you had, but instead of swapping the target, I just needed to modify the method arguments. I created a PreInterceptor, where I have the following code:

    Object[] arguments = invocation.getArguments();
    Class object = (Class) arguments[0];
    object.setProperty = false;
    Advised advised = (Advised) AopContext.currentProxy();
    Object proxy = (Object) AopContext.currentProxy();
    Object target = (Object) advised.getTargetSource().getTarget();
    arguments[0] = object;

    //return invocation.getMethod().invoke(target,arguments);
    return invocation.getMethod().invoke(proxy,arguments);

    Note: I changed the actual Class, object and setProperty to generic words for the sample code.

    If I use "target" in the invoke method, the postInterceptor is skipped (which is what you found). If I use "proxy", it gets into a loop, calling the PreInterceptor over and over... Any ideas?

    Thanks in advance for your help

  3. #13
    Join Date
    Aug 2005
    Posts
    16

    Default

    I seem to recall that I wrote an interceptor that modified the arguments, and just calling methodInterceptor.proceed() worked properly.

Similar Threads

  1. Replies: 8
    Last Post: Jun 12th, 2007, 01:45 PM
  2. Accessing Service Objects in Actions
    By curtney in forum Web Flow
    Replies: 8
    Last Post: Dec 29th, 2006, 02:55 AM
  3. Accessing methods from beans in the Flow Scope
    By jackcholt in forum Web Flow
    Replies: 4
    Last Post: May 26th, 2005, 10:28 PM
  4. Replies: 2
    Last Post: May 12th, 2005, 03:54 PM
  5. Optional targetsource for a ProxyFactoryBean
    By steven.warren in forum Container
    Replies: 2
    Last Post: Mar 29th, 2005, 09:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •