annotate src/main/java/de/intevation/rest/LProbeRESTService.java @ 11:ad22a59aa5d7

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