Although creating a POJO can be an efficient way of creating simple classes, it can be limiting to have a concrete class definition scattered through the class definitions. It is a better design to use either an abstract class or an interface as the service type.
Create a new interface in the
com.packtpub.e4.application
package, calledIStringService
. Define theprocess()
method as abstract:public interface IStringService { public abstract String process(String string); }
Modify the reference in the
Rainbow
class to refer to theIStringService
interface instead of theStringService
class:@Inject private IStringService stringService;
Run the application, switch to the Rainbow tab, and a dependency injection fault will be shown in the host Eclipse instance's Console view:
org.eclipse.e4.core.di.InjectionException: Unable to process "Rainbow.stringService": no actual value was found for the argument "IStringService".
Although the runtime knows that the...