comparison src/main/java/de/intevation/rest/RESTService.java @ 4:39b0b108036f

Added test RESTService to play around.
author Torsten Irländer <torsten.irlaender@intevation.de>
date Thu, 18 Apr 2013 11:36:35 +0200
parents
children 27839a25ee4c
comparison
equal deleted inserted replaced
3:79e1144949d9 4:39b0b108036f
1 package de.intevation.rest;
2
3 import javax.enterprise.context.RequestScoped;
4 import javax.ws.rs.GET;
5 import javax.ws.rs.Path;
6 import javax.ws.rs.Produces;
7
8 @Path("/default")
9 @RequestScoped
10 public class RESTService {
11
12 @GET
13 @Produces("text/xml")
14 public String listAll() {
15 return "Dies ist ein Test";
16 }
17 }
18
19 /**
20 * JAX-RS Example
21 *
22 * This class produces a RESTful service to read the contents of the members table.
23
24 @Path("/members")
25 @RequestScoped
26 public class MemberResourceRESTService {
27 @Inject
28 private EntityManager em;
29
30 @GET
31 @Produces("text/xml")
32 public List<Member> listAllMembers() {
33 // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of
34 // this query
35 @SuppressWarnings("unchecked")
36 // We recommend centralizing inline queries such as this one into @NamedQuery annotations on
37 // the @Entity class
38 // as described in the named query blueprint:
39 // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html
40 final List<Member> results = em.createQuery("select m from Member m order by m.name").getResultList();
41 return results;
42 }
43
44 @GET
45 @Path("/{id:[0-9][0-9]*}")
46 @Produces("text/xml")
47 public Member lookupMemberById(@PathParam("id") long id) {
48 return em.find(Member.class, id);
49 }
50 }
51 */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)