Created
October 17, 2010 20:55
-
-
Save guilhermesilveira/631279 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Basket implements HypermediaResource { | |
| public void configureRelations(RelationBuilder builder) { | |
| builder.relation("self").uses(BasketsController.class).show(id); | |
| builder.relation("payment").uses(PaymentsController.class).create(id, null); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Get | |
| @Path("/items") | |
| public void list() { | |
| resource = restfulie.enhance(database.lista()); | |
| resource.relation("basket").uses(BasketsController.class) | |
| .create(null); | |
| result.use(representation()).from(resource, "items").serialize(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Resource | |
| public class SoftwareController { | |
| @Get @Path("/software/{id}") | |
| public Software show(long id) { | |
| Software retrieved = dao.search(id); | |
| return retrieved; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| My ${software.name} page | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is used on the English-language page http://www.caelumobjects.com/2010/10/18/jax-rs-2-0-how-to-improve-it/ but the second example has
database.lista()which I supposed was meant to bedatabase.list()...