Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Exposing a group of methods in session, Spring framework

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Is it possible in Spring framework, to expose group of methods in Configuration XML so these methods are available in all the controllers of application.

For example: I have a class TestUtil and in that there is a method getStackTrace(). Can I expose this method in Spring configuration file in any way so that in all the controllers I can directly say "getStackTrace()" that is making this method exposed in session.

Any help would be greatly appreciated.

Thanks,
Naresh Daswani
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Never heard of this type of functionality. I can't imagine it could be done, but please let us know if you come up w/ a solution.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could inject TestUtil into all your controllers to make that functionality available. It would instantiate one instance of TestUtil for all the controllers (sounds like what you want).

Best practice would be to define an interface that defines getStackTrace() and have TestUtil implement the interface.
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Naresh,

or you could make a superclass for all your Controllers,
and put the getStackTrace() method in there.

Herman
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic