-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJobsService.java
More file actions
47 lines (37 loc) · 976 Bytes
/
JobsService.java
File metadata and controls
47 lines (37 loc) · 976 Bytes
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
41
42
43
44
45
46
47
package org.javaee7.chapter08;
import java.util.List;
import javax.ejb.EJB;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.javaee7.entity.Jobs;
import org.javaee7.jpa.session.JobsSession;
/**
*
* @author Juneau
*/
@Path("/jobsService")
public class JobsService {
@EJB
JobsSession jobsSession;
public JobsService(){
}
@GET
@Produces("text/html")
public String getAsHtml() {
List<Jobs> jobList = jobsSession.retrieveJobsSynchronously();
StringBuilder sb = new StringBuilder();
sb.append("<p>");
for (Jobs job:jobList){
sb.append(job.getJobId() + " = " + job.getTitle());
}
sb.append("<p>");
return sb.toString();
}
@GET
@Produces("application/xml")
public Jobs getAsJobs(){
List<Jobs> jobList = jobsSession.retrieveJobsSynchronously();
return jobList.get(1);
}
}