I want to inject a dependency inside my Mapper class.
Example Mapper Class:
public class Mapper() {
private MyInterface myObject;
public void map() {
// Map code here
}
}
I would like to inject an implementation of MyInterface to myObject using Spring. This is not possible directly using spring, since Hadoop framework itself instantiates the Mapper Objects.
Only way I can some up is to add a configure function to my Mapper class & then do something like:
public void configure() {
// create application context here, then
myObject= (MyInterface) applicationContext.getBean("bean.myImplementation1");
}
Is there a better way to do this ?
Thanks in advance