Announcement Announcement Module
Collapse
No announcement yet.
Interceptor for method with "output" parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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

      Comment

      Working...
      X