January 2018
Intermediate to advanced
350 pages
9h 7m
English
If we focus back on the Metrics library, we will find several CDI integrations. The global idea is to decorate the code with some annotation and automatically get the metrics associated with the executed code. Clearly, it will impact your code this way (using https://github.com/astefanutti/metrics-cdi for instance):
@Transactional@ApplicationScopedpublic class QuoteService { @PersistenceContext private EntityManager entityManager; @Timed(name = "create") public Quote create(final Quote newQuote) { entityManager.persist(newQuote); entityManager.flush(); return newQuote; }}
The @Timed annotation will automatically wrap the method execution in a Metrics timer and will therefore provide the statistics about the execution time ...
Read now
Unlock full access