I have the below static helper method. I am trying to refactor this method by using Spring's method injection.
public static MessageSender getMessageSender(){
return new MailMessageSender(getMailSession());
}
//getMailSession() is a private static method which used to refresh
//and return a Session object to the constructor
I tried to use beans in this context, but it won't work as my methods are static.
Here is what I have tried,(asked in a StackOverflow question)
Note: I have no clear idea how to call my getMailSession()
and pass that value to MailMessageSender
constructor while using method injection.
How can I make this above method to use Spring's method injection?