Archive for May, 2015


Basic REST web service example ..

May 08, 2015 in Java, REST, Web, WebServices


@Controller // --> Declare a Spring MVC Controller

@RequestMapping("/computer") // --> Map an URI with a controller or a method

@PathVariable // --> Read a variable in an Uri and assign this value to a java variable

@RequestBody // --> Declare a Pojo class to map the http request body  

@ResponseBody // --> Declare a Pojo class to generate Json content to return to the http client

// Declaration as this class as a controller

// Declaration that this controller handles requests on uri */computer

public class ComputerController {
  // Stores computers
  private static final ComputerStorage computerStorage = new ComputerStorage();
  // Declare a method that handle all GET request on */computer
  @RequestMapping(method = RequestMethod.GET)

  // Return a list of computer to the http client
  @ResponseBody public List<Computer> getComputers() {
   return computerStorage.getAll();

node.js learning with learnyounode .. solutions ..

May 08, 2015 in javascript, node.js

Exercise 4, asynchronous (async) file processing ..


var countLines = function (err, fileBuffer){
  // console.log(fileBuffer);

fs.readFile(process.argv[2], 'utf8', countLines);