This is a simple Java REST API based on Spring framework that answers to the prerequisite given by Alexander.
Action services implementations are defined in service package under each entity type :
- event
- fact
- observation
A new Action service implementation of interface ActionService can be added in the desired package and will be executed without modifying business logic.
Requirements :
JAVA 8+ / Maven 3
Run tests and build executable JAR :
mvn clean package
Execute standalone JAR and run web server (port 8080):
java -jar target/spring-boot-rest-api-0.0.1.jar
Execute some actions depending on a type. Return executed actions and execution order.
| Name | Type | Mandatory | Description |
|---|---|---|---|
| type | String |
Yes | The action target entity type, available values : OBSERVATION / FACT / EVENT |
Array of Objects :
| Name | Type | Mandatory | Description |
|---|---|---|---|
| name | String |
Yes | Executed action name aka. Action class Implementation |
| name | int |
Yes | Action execution order |
Curl command :
curl -X POST \
-H "accept: application/json" \
"http://localhost:8080/actions/OBSERVATION"Sample response (JSON):
[
{
"name": "DefaultObservationServiceImpl",
"order": 1
},
{
"name": "ComputeObservationServiceImpl",
"order": 2
},
{
"name": "PublishObservationServiceImpl",
"order": 3
}
]Display the number of performed /actions requests by entity type.
| Name | Type | Mandatory | Description |
|---|---|---|---|
| observation | int |
Yes | Number of requests performed with type OBSERVATION |
| fact | int |
Yes | Number of requests performed with type FACT |
| event | int |
Yes | Number of requests performed with type EVENT |
Curl command :
curl -H "accept: application/json" \
"http://localhost:8080/requests/stats"Sample response (JSON):
{
"observation": 5,
"fact": 0,
"event": 3
}