Announcement Announcement Module
Collapse
No announcement yet.
How to get parameter names at runtime? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to get parameter names at runtime?

    Hi,
    I desperately need help on this. I've have been looking all over for a way to do this.
    I am trying to use a @Before advice to print the names and values of the actual arguments of method pointcuts.
    First I thought simply compiling the class files with the -g option will do the trick. That didn't work.
    Then I read in a post somewhere that using AspectJ load-time weaving will for sure do the trick. So I did the following for Tomcat 7:

    In my context.xml
    Code:
    ...
    
      <Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/>
    ...
    In my config.xml
    Code:
    ...
        <context:load-time-weaver weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
    ...
    But still when I call MethodSignature.getParameterNames() it returns null.

    So my question is:
    Is there a way to get the parameter names of a method from within an advice? If so how?

  • #2
    Is LocalVariableTableParameterNameDiscoverer the solution?

    Comment


    • #3
      LocalVariableTableParameterNameDiscoverer doesn't seem to work either. Is there a solution to this that does not require annotating each and every single parameter on method pointcuts?
      HELLLLLLLLLLLLLLLLLLLLLLP!!!

      Comment


      • #4
        Can anybody help???

        Comment


        • #5
          Correction. LocalVariableTableParameterNameDiscoverer does indeed work. I think got caught out by proxies and/or interfaces classes when I tried to use it. However it requires files to be compiled with debug info which is less than desirable.

          Comment

          Working...
          X