An example of CDI

When we use CDI, this is what the annotations on the different classes would look like. There is no change in how we create and launch the Spring application context.

CDI marks no differentiation between @Repository, @Controller, @Service, and @Component. We use @Named instead of all the preceding annotations.

In the example, we use @Named for DataServiceImpl and BusinessServiceImpl. We use @Inject to inject dataService into BusinessServiceImpl (instead of @Autowired):

    @Named //Instead of @Repository 
public class DataServiceImpl implements DataService
@Named //Instead of @Service
public class BusinessServiceImpl {
@Inject //Instead of @Autowired
private DataService dataService;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset