Time for action – injecting subtypes

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.

  1. Create a new interface in the com.packtpub.e4.application package, called IStringService. Define the process method as abstract:
    public interface IStringService {
      public abstract String process(String string);
    }
  2. Modify the existing StringService so that it implements the IStringService interface:
    public class StringService implements IStringService {
      ...
    }
  3. Modify the reference in the Rainbow class to refer to the IStringService interface instead of the ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.