If I had an abstract class that was inherited by many other classes, would @Inject
be alright on a protected object to use it in the children classes ?
Here is a shortened example:
Abstract class inherited from:
import javax.inject.Inject;
//Many imports
public abstract class FatherMessageHandler{
//All the neeeded code...
@Inject
protected MyMessageHandler messageHandler;
}
One of the child class:
public class UseMessageHandler extends FatherMessageHandler {
//All the neeeded code...
MyMessageHandler.getMessageAlert();
}
Is it good practice to do so ? Is it a no go ? Or is there a cleaner way ? I'm asking this as I'm quite new to injections !