concept BookService in category java

This is an excerpt from Manning's book Portlets in Action.
The BookCatalogPortlet class’s searchBook action method
is responsible for searching for books when the user clicks the Search button. The search criteria is saved to the PortletSession’s APPLICATION_SCOPE
for later use by the BookServlet servlet. The BookServlet’s doGet method creates an instance of BookServiceImpl
, passing ServletContext to the constructor, and it obtains the myaction request attribute from the request. The search criteria that was stored in the PortletSession’s APPLICATION_SCOPE at
is retrieved using the HttpSession object
, and the BookService’s searchBooks method is responsible for finding books matching the search criteria.
In this section, we’ll look at how the Spring JDBC (Java Database Connectivity) module simplifies interaction with the database and use it to implement the data access layer of the Book Catalog portlet. In the context of the Book Catalog portlet, we’ll look at how to configure the data source in a properties file or JNDI, how to access JNDI-bound data sources in Spring’s application context XML, and how to create data access objects (DAOs) that use Spring JDBC classes for executing SQL statements. We’ll wrap up this section by creating a Spring-based BookService service that uses DAOs to access the data source containing book catalog data.
The pointcut expression identifies the target object’s methods to which the advice must be applied—this example identifies the BookService object’s addBook method as the method to which the advice must be applied.
The next listing shows the LoggingAspect aspect, which makes use of the @Around advice to log messages at the entry and exit of methods defined in the BookService object.
The @Around advice annotation
specifies that the logMessage method is executed before and after the execution of the target object’s methods. The pointcut expression following the @Around advice annotation specifies that the advice applies to all the methods of the BookService object. The logMessage advice method accepts a ProceedingJoinPoint argument, which is mandatory for the @Around advice method. The ProceedingJoinPoint object lets the advice control the timing of the execution of the target object’s method. The ProceedingJoinPoint object’s getTarget method returns the target object on which the advice is currently being applied. The getClass method is used to get the class of the target object.
is responsible for searching for books when the user clicks the Search button. The search criteria is saved to the PortletSession’s APPLICATION_SCOPE
for later use by the BookServlet servlet. The BookServlet’s doGet method creates an instance of BookServiceImpl
, passing ServletContext to the constructor, and it obtains the myaction request attribute from the request. The search criteria that was stored in the PortletSession’s APPLICATION_SCOPE at
, and the BookService’s searchBooks method is responsible for finding books matching the search criteria.