Results 1 to 3 of 3

Thread: Interceptor for method with "output" parameters

  1. #1
    Join Date
    Jun 2008
    Posts
    2

    Default Interceptor for method with "output" parameters

    Hello,

    I have a method like
    public int retrieveSomething( String agentID, IntHolder value){
    value = new IntHolder();
    ...
    value = <assign something>
    }

    This method is intercepted, but there is a problem with "value" parameter. It is not updated by method.proceed() invocation.

    How can I walkaround this problem?

    best regards
    Piotr Rezmer

  2. #2

    Default

    I'm not sure what you're trying to do with the method interception, but you're trying to change a reference to an Object passed into your method (value = new IntHolder(). Which will work inside the method, but won't affect anything outside of it. So, you can't change the reference, but you can call setters on IntHolder to set value(s). If you Google for 'java pass by reference' there is a Java World article on this.

  3. #3
    Join Date
    Jun 2008
    Posts
    2

    Default

    Quote Originally Posted by David Winterfeldt View Post
    I'm not sure what you're trying to do with the method interception, but you're trying to change a reference to an Object passed into your method (value = new IntHolder().
    That's right. I had to pull out creation of IntHolder() outside the method, Then it works.

    best regards
    Piotr Rezmer

Posting Permissions

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