Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Monitoring RESTful web services using Jersey APIs


Jersey lets you register various event listeners to monitor the state of your JAX-RS application. Here are the two core listener interfaces that you may need to be aware of:

  • org.glassfish.jersey.server.monitoring.ApplicationEventListener: This is a Jersey-specific provider component that listens to application events such as initialization of application, start and stop of application, and so on. The implementation class can be registered as any standard JAX-RS provider.

  • org.glassfish.jersey.server.monitoring.RequestEventListener: The implementation of the interface will be called for request events when they occur. This is not a JAX-RS provider; an instance of RequestEventListener must be returned from the ApplicationEventListener::onRequest(RequestEvent).

Jersey also comes with the MonitoringStatistics JMX bean to collect the application state, which can be enabled by setting the following configuration property: jersey.config.server.monitoring...