Learn Java for Web Development

(Tina Meador) #1

222 CHAPTER 5: Building Java Web Applications with Spring Web MVC


Listing 5-23. BookService


package com.apress.books.service;


import java.util.List;


import com.apress.books.model.Book;


public interface BookService {
public List getAllBooks();


}


Listing 5-24 illustrates the BookService implementation.


Listing 5-24. BookService Implementation


package com.apress.books.service;


import java.util.List;


import com.apress.books.dao.BookDAO;
import com.apress.books.model.Book;


public class BookServiceImpl implements BookService{


private BookDAO bookDao ;


public void setBookDao(BookDAO bookDao) {
this.bookDao = bookDao;
}


public List getAllBooks() {
List bookList = bookDao.findAllBooks();


return bookList;
}
}


Listing 5-25 illustrates the BookDAO.


Listing 5-25. BookDAO


package com.apress.books.dao;


import java.util.List;


import com.apress.books.model.Book;
import com.apress.books.model.Category;

Free download pdf