-
Notifications
You must be signed in to change notification settings - Fork 0
Event and response entity
Andrej Završnik edited this page Mar 8, 2017
·
2 revisions
Events receive the response entity as it is produced by the REST API.
Event can use this data as input parameters.
@GET
@Path("/register/{email}")
@RestEvent(description = "Send welcome email",
processor = SendWelcomeMail.class,
response = 200
)
@Produces(MediaType.APPLICATION_JSON)
public Response setStatus(@PathParam("email") String email) {
// do some registration
return Response.ok(email).status(code).build();
}
NOTE: the entity object must implement the
Serializable
interface
public class SendWelcomeMail implements RestEventProcessor {
@Override
public RestEventResult execute(Serializable entity, RestEventContext context) throws Exception {
if (entity instanceof String) { // check entity type
String email = (String)entity; // get entity as provided
sendWelcomeMailTo(email); // use entity to perform some action
}
return RestEventResult.ok();
}
}