The tasks quickstart demonstrates how to implement a JAX-RS service that uses JPA 2.0 persistence deployed to Red Hat JBoss Enterprise Application Platform.
The application manages User and Task JPA entities. A user represents an authenticated principal and is associated with zero or more Tasks. Service methods validate that there is an authenticated principal and the first time a principal is seen, a JPA User entity is created to correspond to the principal. JAX-RS annotated methods are provided for associating Tasks with this User and for listing and removing Tasks.
Users and passwords are defined in configuration\application-users.properties and application-roles.properties. Users can be created using the JBoss add-users.sh shell script in a JBoss EAP installation.
Currently the following users are defined:
| User | Password |
|---|---|
tasks |
redhat1 |
redhat |
redhat1 |
gpte |
redhat1 |
This application understands an environment variable VERSION that will be used to display the current version in the title of the application.
The variable can be set on the Deployment Configuration.
-
Create a task with name {task_name}
curl -u tasks:redhat1 -H 'Content-Length: 0' -X POST http://{tasks_route}/ws/tasks/{task_name} -
Get a task by id
curl -u 'tasks:redhat1' -H "Accept: application/json" -X GET http://{tasks_route}/ws/tasks/{tasks_id}
-
Get all tasks for user
curl -u 'tasks:redhat1' -H "Accept: application/json" -X GET http://{tasks_route}/ws/tasks
-
Delete a task by id
curl -i -u 'tasks:redhat1' -X DELETE http://{tasks_route}/ws/tasks/{tasks_id} -
Generate CPU load. Last parameter is duration of load in seconds
# 5 seconds curl -X GET http://{tasks_route}/ws/demo/load/5