torsten@4: package de.intevation.rest; torsten@4: torsten@4: import javax.enterprise.context.RequestScoped; torsten@4: import javax.ws.rs.GET; torsten@4: import javax.ws.rs.Path; torsten@4: import javax.ws.rs.Produces; torsten@4: torsten@4: @Path("/default") torsten@4: @RequestScoped torsten@4: public class RESTService { torsten@4: torsten@4: @GET torsten@5: @Produces("text/plain") torsten@4: public String listAll() { torsten@6: return "Hallo Welt!"; torsten@4: } torsten@4: } torsten@4: torsten@4: /** torsten@4: * JAX-RS Example torsten@4: * torsten@4: * This class produces a RESTful service to read the contents of the members table. torsten@4: torsten@4: @Path("/members") torsten@4: @RequestScoped torsten@4: public class MemberResourceRESTService { torsten@4: @Inject torsten@4: private EntityManager em; torsten@4: torsten@4: @GET torsten@4: @Produces("text/xml") torsten@4: public List listAllMembers() { torsten@4: // Use @SupressWarnings to force IDE to ignore warnings about "genericizing" the results of torsten@4: // this query torsten@4: @SuppressWarnings("unchecked") torsten@4: // We recommend centralizing inline queries such as this one into @NamedQuery annotations on torsten@4: // the @Entity class torsten@4: // as described in the named query blueprint: torsten@4: // https://blueprints.dev.java.net/bpcatalog/ee5/persistence/namedquery.html torsten@4: final List results = em.createQuery("select m from Member m order by m.name").getResultList(); torsten@4: return results; torsten@4: } torsten@4: torsten@4: @GET torsten@4: @Path("/{id:[0-9][0-9]*}") torsten@4: @Produces("text/xml") torsten@4: public Member lookupMemberById(@PathParam("id") long id) { torsten@4: return em.find(Member.class, id); torsten@4: } torsten@4: } torsten@4: */