Package com.force.samples.controllers

Source Code of com.force.samples.controllers.RestController

package com.force.samples.controllers;

import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.force.samples.dao.BookDAO;
import com.force.samples.entity.Book;

@Controller
@RequestMapping(value="/rest")
public class RestController {
 
  private static Logger log = LoggerFactory.getLogger(RestController.class);

  @Inject
  private BookDAO bookDAO;
 
  @RequestMapping(method=RequestMethod.GET, value="/book/{bookId}")
  public @ResponseBody Book getBook (@PathVariable(value="bookId") long bookId, Model model) {
   
    log.info("Searching for book with id = " + bookId);
   
    Book book = bookDAO.getBookById(bookId);
    return book;
  }
}
TOP

Related Classes of com.force.samples.controllers.RestController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.