• Post Reply Bookmark Topic Watch Topic
  • New Topic

intercepting instances with reflection  RSS feed

 
Robert Garrido
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a big web-app, this web-app uses a master ThreadPoolExecutor based class (named MasterExecutor) to run some heavy processes.

The MasterExecutor class has a method that prints out statistics (a method named 'printStats' that returns an String) of the work load of its threads. This stats are printed to logs upon thread execution, but we need to have a webpage that prints that information upon user request, that means, to monitor the MasterExecutor upon request.

Now, I wrote a JSP with reflection that is able to create an instance of the MasterExecutor and calls the 'printStats' method, however it prints the state of a new MasterExecutor instance:


How can I get the main and only instance of the web-app "MasterExecutor" running in tomcat with reflection?

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems to me a reference to this MasterExecutor instance belongs in the ServletContext where all JSP and servlets could get it.

When and how is the instance created?


Bill
 
Robert Garrido
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,

Thanks for your reply, both applications share the same Tomcat container, but they are different, for a reason that is long to explain they cannot reside in the same context.

I want to use reflection because I need stats from private members of the MasterExecutor; these member cannot have other access level.

Best regards.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!