-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleAcmeResource.java
More file actions
40 lines (35 loc) · 1.07 KB
/
SimpleAcmeResource.java
File metadata and controls
40 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package org.javaee7.services;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import javax.persistence.Query;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.javaee7.entity.Jobs;
import org.javaee7.interfaces.Alerter;
/**
* Demonstrates a simple producer web service
* @author Juneau
*/
@Path("/acmeSimple")
public class SimpleAcmeResource {
@PersistenceContext(unitName = "IntroToJavaEE7PU")
private EntityManager em;
@GET
@Produces("text/html")
@Alerter
public String getJobs(){
Query qry = em.createQuery("select object(o) from Jobs o");
List<Jobs> jobList = qry.getResultList();
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.append("<p>");
for(Jobs job:jobList){
htmlBuilder.append(job.getTitle());
htmlBuilder.append("<br/>");
}
htmlBuilder.append("</p>");
return htmlBuilder.toString();
}
}