0

Is it possible to get the invoked method name in JSF other than using PhaseListener? What i want is to log the invoke listener name and the url from the dao class. ie,

Bean --calls--> Service --calls--> Repository (executes query and need to write the invoked url and the invoked bean method name to log file).

Is this possible?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
mehere
  • 1,487
  • 5
  • 28
  • 50
  • What I did once was create an annotation and put that on each 'bean' method. At the same time create an interceptor that runs when this annotation is present and put the relevant info in a thread local variable. In the repository you can read this info an do with it you like. – Kukeltje Sep 10 '15 at 09:01
  • 1
    You can find it in call stack of the current thread. – BalusC Sep 10 '15 at 09:02
  • ss..got it..Thread.currentThread().getStackTrace().. Thank you @BalusC..:) – mehere Sep 10 '15 at 09:11
  • I tried the stacktrace to, but found it to be to inconvenient in the sense that you have to explicitly know package names, class names etc... and that (imo) the 'Repository' class should not explicitly know this. But if the methodName/className is all you need, it indeed does work. – Kukeltje Sep 10 '15 at 09:20
  • I tried the thread stacktrace by using package name. seems to work..I am trying the method suggested by you also..@Kukeltje.. – mehere Sep 10 '15 at 09:57

0 Answers0