This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@Autowired and Static methods

Lucky J Verma
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am using @Autowired to inject some handler/translator instances(from Translator class) in my classes.
These translators do some exc conversion work once exception is thrown in methods.

Now i have some cases where methods are static methods and i need to handle these exceptions , i mean to translate.
what are my options.
Eg. This is rough code to show what i am trying to do .

I tried to create a static method in my translator class which i can directly call and use in my static methods.But then realized that is also used injected messageSource of Spring.
(Ie. @Autowired MessageSource -used to resolve messages).

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic