Skip to content

Commit

Permalink
Added a controller to force the app to exit. Added app-level logging …
Browse files Browse the repository at this point in the history
…to the AlbumController.
  • Loading branch information
scottfrederick committed Mar 26, 2014
1 parent 16a4daa commit e846b34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Expand Up @@ -2,6 +2,8 @@

import org.cloudfoundry.samples.music.domain.Album;
import org.cloudfoundry.samples.music.repositories.AlbumRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
Expand All @@ -11,6 +13,7 @@
@Controller
@RequestMapping(value = "/albums")
public class AlbumController {
private static final Logger logger = LoggerFactory.getLogger(AlbumController.class);
private AlbumRepository repository;

@Autowired
Expand All @@ -27,24 +30,28 @@ public Iterable<Album> albums() {
@ResponseBody
@RequestMapping(method = RequestMethod.PUT)
public Album add(@RequestBody @Valid Album album) {
logger.info("Adding album " + album.getId());
return repository.save(album);
}

@ResponseBody
@RequestMapping(method = RequestMethod.POST)
public Album update(@RequestBody @Valid Album album) {
logger.info("Updating album " + album.getId());
return repository.save(album);
}

@ResponseBody
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public Album getById(@PathVariable String id) {
logger.info("Getting album " + id);
return repository.findOne(id);
}

@ResponseBody
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public void deleteById(@PathVariable String id) {
logger.info("Deleting album " + id);
repository.delete(id);
}
}
@@ -0,0 +1,14 @@
package org.cloudfoundry.samples.music.web.controllers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class DieController {
@ResponseBody
@RequestMapping(value = "/die")
public void die() {
System.exit(1);
}
}

0 comments on commit e846b34

Please sign in to comment.