• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

intercepting instances with reflection

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic