Event handler classes with @Before / @On / @After
EventHandler, @ServiceName, @Before, @On, @Aftercapire documents that CAP Java event handler methods are annotated with @Before, @On or @After to pick the phase, in classes implementing the EventHandler marker interface, with @ServiceName setting the default service; value "*" with type = ApplicationService.class registers on all application services. The Building Plugins guide states that because handlers are not tightly coupled to the request handling, a plugin can package handlers that react to common types, annotations or entity values in an external library.
@ServiceName(value = "*", type = ApplicationService.class)
public class SampleHandler implements EventHandler {
@After
public void handleSample(CdsReadEventContext context) {
// any custom Java code using the event context and CQL APIs
}
}